This commit is contained in:
Rushabh Mehta 2014-06-17 15:55:39 +05:30
parent c49f517e96
commit a2aaba7d9e
10 changed files with 161 additions and 163 deletions

View file

@ -418,17 +418,16 @@ def latest(rebuild_website=True, quiet=False):
frappe.modules.patch_handler.run_all()
# sync
frappe.model.sync.sync_all(verbose=verbose)
frappe.translate.clear_cache()
sync_fixtures()
sync = statics.sync()
sync.start()
sync.start(rebuild=True)
# build website config if any changes in templates etc.
if rebuild_website:
build_website()
frappe.translate.clear_cache()
finally:
frappe.destroy()

View file

@ -71,6 +71,7 @@ frappe.request.call = function(opts) {
500: function() {
msgprint(__("Server Error: Please check your server logs or contact tech support."))
opts.error && opts.error();
}
},
async: opts.async
@ -144,7 +145,6 @@ frappe.request.prepare = function(opts) {
}
frappe.request.cleanup = function(opts, r) {
// stop button indicator
if(opts.btn) $(opts.btn).done_working();

View file

@ -10,8 +10,7 @@ from frappe.website.render import clear_cache
from frappe.utils import today, cint, global_date_format, get_fullname
from frappe.website.utils import find_first_image, get_comment_list
sort_by = "published_on"
sort_order = "desc"
order_by = "`tabBlog Post`.published_on desc"
condition_field = "published"
template = "templates/generators/blog_post.html"

View file

@ -18,6 +18,7 @@ $.extend(cur_frm.cscript, {
},
refresh: function(doc) {
cur_frm.cscript.layout(doc);
cur_frm.set_intro("");
if (!doc.__islocal && doc.published) {
cur_frm.set_intro(__("Published on website at: {0}",
[repl('<a href="/%(website_route)s" target="_blank">/%(website_route)s</a>', doc.__onload)]));

View file

@ -1,173 +1,180 @@
{
"allow_attach": 1,
"creation": "2013-03-28 10:35:30",
"description": "Page to show on the website\n",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Transaction",
"allow_attach": 1,
"creation": "2013-03-28 10:35:30",
"description": "Page to show on the website\n",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Transaction",
"fields": [
{
"fieldname": "section_title",
"fieldtype": "Section Break",
"label": "Title",
"fieldname": "section_title",
"fieldtype": "Section Break",
"label": "Title",
"permlevel": 0
},
},
{
"description": "Title / headline of your page",
"fieldname": "title",
"fieldtype": "Data",
"label": "Title",
"permlevel": 0,
"description": "Title / headline of your page",
"fieldname": "title",
"fieldtype": "Data",
"label": "Title",
"permlevel": 0,
"reqd": 1
},
},
{
"description": "Page url name (auto-generated)",
"fieldname": "page_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Page Name",
"permlevel": 0,
"description": "Page url name (auto-generated)",
"fieldname": "page_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Page Name",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Page",
"options": "Website Route",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Page",
"options": "Website Route",
"permlevel": 0
},
},
{
"fieldname": "published",
"fieldtype": "Check",
"label": "Published",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published",
"permlevel": 0
},
},
{
"fieldname": "cb1",
"fieldtype": "Column Break",
"permlevel": 0,
"description": "0 is highest",
"fieldname": "idx",
"fieldtype": "Int",
"label": "Priority",
"permlevel": 0
},
{
"fieldname": "cb1",
"fieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
},
{
"description": "Description for page header.",
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description",
"description": "Description for page header.",
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description",
"permlevel": 0
},
},
{
"description": "Page content",
"fieldname": "sb1",
"fieldtype": "Section Break",
"label": "Content",
"description": "Page content",
"fieldname": "sb1",
"fieldtype": "Section Break",
"label": "Content",
"permlevel": 0
},
},
{
"description": "Begin this page with a slideshow of images",
"fieldname": "slideshow",
"fieldtype": "Link",
"label": "Slideshow",
"options": "Website Slideshow",
"description": "Begin this page with a slideshow of images",
"fieldname": "slideshow",
"fieldtype": "Link",
"label": "Slideshow",
"options": "Website Slideshow",
"permlevel": 0
},
},
{
"description": "Content in markdown format that appears on the main side of your page",
"fieldname": "main_section",
"fieldtype": "Text Editor",
"label": "Main Section",
"description": "Content in markdown format that appears on the main side of your page",
"fieldname": "main_section",
"fieldtype": "Text Editor",
"label": "Main Section",
"permlevel": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"description": "Link to other pages in the side bar and next section",
"fieldname": "sb2",
"fieldtype": "Section Break",
"label": "More",
"depends_on": "eval:!doc.__islocal",
"description": "Link to other pages in the side bar and next section",
"fieldname": "sb2",
"fieldtype": "Section Break",
"label": "More",
"permlevel": 0
},
},
{
"description": "HTML for header section. Optional",
"fieldname": "header",
"fieldtype": "Text",
"label": "Header",
"description": "HTML for header section. Optional",
"fieldname": "header",
"fieldtype": "Text",
"label": "Header",
"permlevel": 0
},
},
{
"fieldname": "enable_comments",
"fieldtype": "Check",
"label": "Enable Comments",
"fieldname": "enable_comments",
"fieldtype": "Check",
"label": "Enable Comments",
"permlevel": 0
},
},
{
"fieldname": "text_align",
"fieldtype": "Select",
"label": "Text Align",
"options": "Left\nCenter\nRight",
"fieldname": "text_align",
"fieldtype": "Select",
"label": "Text Align",
"options": "Left\nCenter\nRight",
"permlevel": 0
},
},
{
"fieldname": "custom_javascript",
"fieldtype": "Section Break",
"label": "Custom Javascript",
"fieldname": "custom_javascript",
"fieldtype": "Section Break",
"label": "Custom Javascript",
"permlevel": 0
},
},
{
"description": "Add code as &lt;script&gt;",
"fieldname": "insert_code",
"fieldtype": "Check",
"label": "Insert Code",
"description": "Add code as &lt;script&gt;",
"fieldname": "insert_code",
"fieldtype": "Check",
"label": "Insert Code",
"permlevel": 0
},
},
{
"depends_on": "insert_code",
"fieldname": "javascript",
"fieldtype": "Code",
"label": "Javascript",
"options": "Javascript",
"depends_on": "insert_code",
"fieldname": "javascript",
"fieldtype": "Code",
"label": "Javascript",
"options": "Javascript",
"permlevel": 0
},
},
{
"fieldname": "custom_css",
"fieldtype": "Section Break",
"label": "Custom CSS",
"fieldname": "custom_css",
"fieldtype": "Section Break",
"label": "Custom CSS",
"permlevel": 0
},
},
{
"fieldname": "insert_style",
"fieldtype": "Check",
"label": "Insert Style",
"fieldname": "insert_style",
"fieldtype": "Check",
"label": "Insert Style",
"permlevel": 0
},
},
{
"depends_on": "insert_style",
"fieldname": "css",
"fieldtype": "Code",
"label": "CSS",
"options": "CSS",
"depends_on": "insert_style",
"fieldname": "css",
"fieldtype": "Code",
"label": "CSS",
"options": "CSS",
"permlevel": 0
}
],
"icon": "icon-file-alt",
"idx": 1,
"max_attachments": 20,
"modified": "2014-05-26 03:36:51.942919",
"modified_by": "Administrator",
"module": "Website",
"name": "Web Page",
"owner": "Administrator",
],
"icon": "icon-file-alt",
"idx": 1,
"max_attachments": 20,
"modified": "2014-06-17 05:56:30.267409",
"modified_by": "Administrator",
"module": "Website",
"name": "Web Page",
"owner": "Administrator",
"permissions": [
{
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Website Manager",
"submit": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Website Manager",
"submit": 0,
"write": 1
}
]
}
}

View file

@ -88,10 +88,12 @@ class WebsiteRoute(NestedSet):
def clear_cache(self, name=None):
from frappe.website.render import clear_cache
clear_cache(name or self.name)
if self.parent_website_route:
if name:
clear_cache(name)
elif self.parent_website_route:
clear_cache(self.parent_website_route)
else:
clear_cache(self.name)
def remove_sitemap(page_name=None, ref_doctype=None, docname=None):
if page_name:

View file

@ -164,7 +164,9 @@ def clear_cache(path=None):
if path:
delete_page_cache(path)
for p in frappe.db.sql_list('''select name from
`tabWebsite Route` where name like "{0}/%"'''.format(path.replace('"', '\"'))):
delete_page_cache(p)
else:
for p in frappe.db.sql_list("""select name from `tabWebsite Route`"""):
if p is not None:

View file

@ -74,16 +74,15 @@ def get_route_children(pathname, home_page=None):
if children:
# if children are from generator and sort order is specified, then get that condition
module = frappe.get_module(children[0].controller)
if hasattr(module, "sort_by") and module.sort_by!="name":
if hasattr(module, "sort_by"):
children = frappe.db.sql("""select t1.* from
`tabWebsite Route` t1, `tab{ref_doctype}` t2
where ifnull(t1.parent_website_route,'')=%s
and t1.public_read=1
and t1.docname = t2.name
order by t2.{sort_by} {sort_order}""".format(
order by {sort_by}""".format(
ref_doctype = children[0].ref_doctype,
sort_by = module.sort_by,
sort_order = module.sort_order),
sort_by = module.sort_by),
pathname, as_dict=True)
children = [frappe.get_doc("Website Route", pathname)] + children

View file

@ -36,7 +36,7 @@ def render_blocks(context):
if "title" not in out:
out["title"] = context.get("title")
if not out.get("header") and out.get("title"):
if "header" not in out and out.get("title"):
out["header"] = out["title"]
if out.get("header") and not out["header"].startswith("<h"):

View file

@ -20,20 +20,8 @@ class WebsiteGenerator(Document):
self.get("__onload").website_route = frappe.db.get_value("Website Route",
{"ref_doctype": self.doctype, "docname": self.name})
def set_page_name(self):
"""set page name based on parent page_name and title"""
page_name = cleanup_page_name(self.get_page_title())
page_name_field = getattr(self, "page_name_field", "page_name")
if self.is_new():
self.set(page_name_field, page_name)
else:
frappe.db.set(page_name_field, page_name)
return page_name
def get_parent_website_route(self):
return self.parent_website_route
return self.get("parent_website_route", "")
def on_update(self):
self.update_sitemap()
@ -98,18 +86,19 @@ class WebsiteGenerator(Document):
route.public_read = 1
def get_page_name(self):
page_name = self._get_page_name()
return self.get_or_make_page_name()
def get_page_name_field(self):
return self.page_name_field if hasattr(self, "page_name_field") else "page_name"
def get_or_make_page_name(self):
page_name = self.get(self.get_page_name_field())
if not page_name:
page_name = self.set_page_name()
page_name = cleanup_page_name(self.get_page_title())
if self.is_new():
self.set(self.get_page_name_field(), page_name)
return self._get_page_name()
def _get_page_name(self):
if hasattr(self, "page_name_field") and self.meta.get_field(self.page_name_field):
parent = self.get_parent_website_route()
return ((parent + "/") if parent else "") + self.get(self.page_name_field)
else:
return cleanup_page_name(self.get_page_title())
return page_name
def get_page_title(self):
return self.get("title") or (self.name.replace("-", " ").replace("_", " ").title())