From 6241012f08157d2d3c58b020566699bdfdae4de1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 22 May 2013 12:37:50 +0530 Subject: [PATCH 1/2] [website] [slideshow] clear website cache on update of a slide show --- website/doctype/website_slideshow/website_slideshow.py | 7 ++++++- website/templates/html/slideshow.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py index 928aa9ff9f..86bd2a0433 100644 --- a/website/doctype/website_slideshow/website_slideshow.py +++ b/website/doctype/website_slideshow/website_slideshow.py @@ -5,4 +5,9 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + + def on_update(self): + # a slide show can be in use and any change in it should get reflected + from webnotes.webutils import clear_cache + clear_cache() \ No newline at end of file diff --git a/website/templates/html/slideshow.html b/website/templates/html/slideshow.html index e0e9038d9f..b26338c5e5 100644 --- a/website/templates/html/slideshow.html +++ b/website/templates/html/slideshow.html @@ -8,7 +8,7 @@ {% if slide.heading or slide.description %} {% endif %} From 488a821534099ffde11da31c72fbde1fabaa2e66 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 22 May 2013 15:51:47 +0530 Subject: [PATCH 2/2] [website] [fix] fixes in sitemap and rss generators --- startup/website.py | 4 ++-- website/helpers/blog_feed.py | 8 +++++--- website/helpers/sitemap.py | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/startup/website.py b/startup/website.py index be8eba6def..5e6c3118c2 100644 --- a/startup/website.py +++ b/startup/website.py @@ -1,5 +1,5 @@ import webnotes, conf, os -from webnotes.utils import cint, cstr +from webnotes.utils import cint, cstr, encode def get_templates_path(): return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") @@ -72,7 +72,7 @@ def update_template_args(page_name, args): args[k] = cint(args.get(k) or 0) args.url = quote(str(get_request_site_address(full_address=True)), str("")) - args.encoded_title = quote(str(args.title or ""), str("")) + args.encoded_title = quote(encode(args.title or ""), str("")) return args \ No newline at end of file diff --git a/website/helpers/blog_feed.py b/website/helpers/blog_feed.py index 41c203e0ad..c79c5cc3bb 100644 --- a/website/helpers/blog_feed.py +++ b/website/helpers/blog_feed.py @@ -49,9 +49,10 @@ rss_item = u""" def generate(): """generate rss feed""" - import webnotes, os + import os, urllib + import webnotes from webnotes.model.doc import Document - from website.helpers.blog import get_blog_content + from webnotes.utils import escape_html host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST') @@ -62,7 +63,8 @@ def generate(): order by published_on desc limit 20""", as_dict=1) for blog in blog_list: - blog.link = host + '/' + blog.name + '.html' + blog.link = urllib.quote(host + '/' + blog.name + '.html') + blog.content = escape_html(blog.content or "") items += rss_item % blog diff --git a/website/helpers/sitemap.py b/website/helpers/sitemap.py index c8b6fd0a53..3956da1a70 100644 --- a/website/helpers/sitemap.py +++ b/website/helpers/sitemap.py @@ -2,6 +2,7 @@ # License: GNU General Public License (v3). For more information see license.txt from __future__ import unicode_literals + frame_xml = """ %s """ @@ -32,10 +33,11 @@ def generate(domain): for p in pages: if count >= max_items: break - page_url = os.path.join(domain, urllib.quote(p[0])) - modified = p[1].strftime('%Y-%m-%d') - site_map += link_xml % (page_url, modified) - count += 1 + if p[0]: + page_url = os.path.join(domain, urllib.quote(p[0])) + modified = p[1].strftime('%Y-%m-%d') + site_map += link_xml % (page_url, modified) + count += 1 if count >= max_items: break