From 80b4ca88c387ccdc2eb981840992e6919a48f03f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Feb 2014 16:55:35 +0530 Subject: [PATCH] fix to static sync --- webnotes/website/doctype/web_page/web_page.py | 21 ++++++++++--------- webnotes/webutils.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/webnotes/website/doctype/web_page/web_page.py b/webnotes/website/doctype/web_page/web_page.py index 48ed889e58..68105b507d 100644 --- a/webnotes/website/doctype/web_page/web_page.py +++ b/webnotes/website/doctype/web_page/web_page.py @@ -48,7 +48,7 @@ def _sync_statics(): def sync_file(fname, fpath, statics_path, priority=0): url = os.path.relpath(fpath, statics_path).rsplit(".", 1)[0] - if fname.rsplit(".", 1)[0]=="index": + if fname.rsplit(".", 1)[0]=="index" and os.path.dirname(fpath) != statics_path: url = os.path.dirname(url) parent_website_sitemap = os.path.dirname(url) @@ -100,20 +100,21 @@ def _sync_statics(): with open(os.path.join(basepath, "index.txt"), "r") as indexfile: index = indexfile.read().splitlines() - for fname in files: - page_name = fname.rsplit(".", 1)[0] - if page_name=="index" and fname!="index.txt": - sync_file(fname, os.path.join(basepath, fname), statics_path) - has_index = True - break + if basepath!=statics_path: + for fname in files: + page_name = fname.rsplit(".", 1)[0] + if page_name=="index" and fname!="index.txt": + sync_file(fname, os.path.join(basepath, fname), statics_path) + has_index = True + break - if not has_index: - continue + if not has_index: + continue # other files for fname in files: page_name = fname.rsplit(".", 1)[0] - if page_name!="index": + if not (page_name=="index" and basepath!=statics_path): sync_file(fname, os.path.join(basepath, fname), statics_path, index.index(page_name) if page_name in index else 0) diff --git a/webnotes/webutils.py b/webnotes/webutils.py index 4e9e76135d..f8c3a66a15 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -147,7 +147,7 @@ def build_sitemap_options(path): sitemap_options.children = webnotes.conn.sql("""select * from `tabWebsite Sitemap` where parent_website_sitemap=%s - and public_read=1 order by idx asc""", (sitemap_options.name,), as_dict=True) + and public_read=1 order by idx asc, page_title asc""", (sitemap_options.name,), as_dict=True) # determine templates to be used if not sitemap_options.base_template_path: