From 7f98f5516eeee56a374eeb371603ce21fea6c75b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 21 Jul 2011 10:02:59 +0530 Subject: [PATCH] fixes for sitemp.xml --- cgi-bin/webnotes/utils/sitemap.py | 15 ++++++---- cgi-bin/webnotes/widgets/page_body.py | 41 +++++---------------------- 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/cgi-bin/webnotes/utils/sitemap.py b/cgi-bin/webnotes/utils/sitemap.py index fd489f6d64..916aaa1eb1 100644 --- a/cgi-bin/webnotes/utils/sitemap.py +++ b/cgi-bin/webnotes/utils/sitemap.py @@ -16,19 +16,24 @@ def generate_xml(conn, site_prefix): max_items = 1000 site_map = '' + page_list = [] if site_prefix: - # list of all Guest pages (static content) - for r in conn.sql("SELECT name, modified FROM tabPage WHERE ifnull(publish,0)=1 ORDER BY modified DESC"): - page_url = site_prefix + '#!' + urllib.quote(r[0]) - site_map += link_xml % (page_url, r[1].strftime('%Y-%m-%d')) - # list of all Records that are viewable by guests (Blogs, Articles etc) try: from startup.event_handlers import get_sitemap_items for i in get_sitemap_items(site_prefix): site_map += link_xml % (i[0], i[1]) + ('/' in i[0]) and page_list.append(i[0].split('/')[1]) or i[0] except ImportError, e: pass + # list of all Guest pages (static content) + for r in conn.sql("SELECT name, modified FROM tabPage WHERE ifnull(publish,0)=1 ORDER BY modified DESC"): + #check for double + if r[0] not in page_list: + page_url = site_prefix + '#!' + urllib.quote(r[0]) + site_map += link_xml % (page_url, r[1].strftime('%Y-%m-%d')) + + return frame_xml % site_map diff --git a/cgi-bin/webnotes/widgets/page_body.py b/cgi-bin/webnotes/widgets/page_body.py index f221511209..8e19ad0716 100644 --- a/cgi-bin/webnotes/widgets/page_body.py +++ b/cgi-bin/webnotes/widgets/page_body.py @@ -90,12 +90,10 @@ def scrub_ids(content): return content -# -# load the page content and meta tags -# def get_page_content(page): """ - Gets the HTML content from `static_content` or `content` property of a `Page` + Gets the HTML content from `static_content` or `content` property of a `Page` + and loads it in global `page_properties` """ from webnotes.model.code import get_code from webnotes.model.doc import Document @@ -125,9 +123,6 @@ def get_page_content(page): except: pass -# -# load metatags -# def load_page_metatags(doc): global page_properties @@ -143,25 +138,6 @@ def load_page_metatags(doc): page_properties['add_in_head'] = getattr(startup, 'add_in_head', '') page_properties['add_in_body'] = getattr(startup, 'add_in_body', '') -# -# load the form as page (deprecated) -# -def get_doc_content(dt, dn): - """ - Gets the HTML content of a document record by using the overridden or standard :method: `doclist.to_html` - """ - import webnotes.model.code - - if dt in webnotes.user.get_read_list(): - # generate HTML - do = webnotes.model.code.get_obj(dt, dn, with_children = 1) - if hasattr(do, 'to_html'): - return dn, do.to_html() - else: - import webnotes.model.doclist - return dn, webnotes.model.doclist.to_html(do.doclist) - else: - return 'Forbidden - 404', '

Forbidden - 404

' # find the page to load as static # ------------------------------- @@ -171,17 +147,14 @@ def load_properties(): import urllib page_url = webnotes.form_dict.get('_escaped_fragment_', webnotes.form_dict.get('page', '')) + + if pag_url and page_url.lower().startswith('page/'): + page_url = page_url[5:] if page_url: - if page_url.startswith('Page/'): - page_url = page_url[5:] - page_url = ['Page', urllib.unquote(page_url)] + get_page_content(urllib.unquote(page_url)) else: - page_url = ['Page', webnotes.user.get_home_page()] - - # load content - # ----------------- - get_page_content(page_url[1]) + get_page_content(webnotes.user.get_home_page()) # generate the page # -----------------