Merge pull request #613 from rmehta/develop

added feature to set link to next page in templates/statics
This commit is contained in:
Rushabh Mehta 2014-06-13 15:25:18 +05:30
commit 2ea809f75b
3 changed files with 20 additions and 1 deletions

View file

@ -224,6 +224,7 @@ def get_messages_from_page_or_report(doctype, name, module=None):
module = frappe.db.get_value(doctype, name, "module")
file_path = frappe.get_module_path(module, doctype, name, name)
messages = get_messages_from_file(file_path + ".js")
messages = get_messages_from_file(file_path + ".html")
return clean(messages)

View file

@ -83,3 +83,11 @@ def get_route_children(pathname, home_page=None):
children = [frappe.get_doc("Website Route", pathname)] + children
return children
def get_next(route):
siblings = get_route_children(frappe.db.get_value("Website Route",
route, "parent_website_route"))
for i, r in enumerate(siblings):
if i < len(siblings) - 1:
if route==r.name:
return siblings[i+1]

View file

@ -7,7 +7,7 @@ import frappe, os, time
from frappe import _
from frappe.utils import cint
from markdown2 import markdown
from frappe.website.sitemap import get_route_children
from frappe.website.sitemap import get_route_children, get_next
def sync_statics():
s = sync()
@ -200,6 +200,16 @@ def get_static_content(fpath, docname, route):
"items":children})
content = content.replace("{index}", html)
if "{next}" in content:
next_item = get_next(route)
html = ""
if next_item:
html = '''<p>
<br><a href="{name}" class="btn btn-primary">
{page_title} <i class="icon-chevron-right"></i></a>
</p>'''.format(**next_item)
content = content.replace("{next}", html)
content = markdown(content)
d.main_section = unicode(content.encode("utf-8"), 'utf-8')