From d47e1d14b7f5eecde1e46457a57fdb6bf78f9dae Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 1 Feb 2012 18:02:33 +0530 Subject: [PATCH] added related page and other cleanups --- erpnext/website/css/website.css | 9 ++++ .../about_us_settings/about_us_settings.py | 1 + erpnext/website/doctype/blog/template.html | 1 + .../contact_us_settings.py | 1 + .../doctype/home_settings/template.html | 2 +- .../website/doctype/related_page/__init__.py | 0 .../doctype/related_page/related_page.txt | 49 +++++++++++++++++++ .../website/doctype/web_page/template.html | 10 +++- erpnext/website/doctype/web_page/web_page.py | 27 ++++++++-- erpnext/website/doctype/web_page/web_page.txt | 28 +++++++++-- version.num | 2 +- 11 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 erpnext/website/doctype/related_page/__init__.py create mode 100644 erpnext/website/doctype/related_page/related_page.txt diff --git a/erpnext/website/css/website.css b/erpnext/website/css/website.css index c653c3be4f..146599bb27 100644 --- a/erpnext/website/css/website.css +++ b/erpnext/website/css/website.css @@ -3,6 +3,10 @@ margin: auto; } +.layout_wrapper { + padding: 20px; +} + footer { width: 900px; margin: auto; @@ -12,6 +16,11 @@ header .topbar .container { margin: auto; } +.web-home-banner { + width: 860px; + margin-bottom: 20px +} + .web-content input[type="text"], .web-content input[type="password"], .web-content select { min-width: 180px; } diff --git a/erpnext/website/doctype/about_us_settings/about_us_settings.py b/erpnext/website/doctype/about_us_settings/about_us_settings.py index 31a26ce031..8a31ff098e 100644 --- a/erpnext/website/doctype/about_us_settings/about_us_settings.py +++ b/erpnext/website/doctype/about_us_settings/about_us_settings.py @@ -20,4 +20,5 @@ class DocType: for t in self.doc.about_team: t['bio'] = markdown2.markdown(t['bio']) + webnotes.conn.set_value('Page', 'about', 'title', self.doc.headline) webnotes.conn.set_value('Page', 'about', 'content', make_template(self.doc, path)) diff --git a/erpnext/website/doctype/blog/template.html b/erpnext/website/doctype/blog/template.html index 8a22cc2ef3..80b030ae9c 100644 --- a/erpnext/website/doctype/blog/template.html +++ b/erpnext/website/doctype/blog/template.html @@ -7,6 +7,7 @@ {{ doc.content_html }}
+

All Blogs

diff --git a/erpnext/website/doctype/contact_us_settings/contact_us_settings.py b/erpnext/website/doctype/contact_us_settings/contact_us_settings.py index 65d50dbf7e..d2fc3c4c49 100644 --- a/erpnext/website/doctype/contact_us_settings/contact_us_settings.py +++ b/erpnext/website/doctype/contact_us_settings/contact_us_settings.py @@ -13,4 +13,5 @@ class DocType: import os path = os.path.join(os.path.dirname(__file__), 'template.html') + webnotes.conn.set_value('Page', 'contact', 'title', self.doc.headline) webnotes.conn.set_value('Page', 'contact', 'content', make_template(self.doc, path)) diff --git a/erpnext/website/doctype/home_settings/template.html b/erpnext/website/doctype/home_settings/template.html index d43f1efb7f..8129a509ba 100644 --- a/erpnext/website/doctype/home_settings/template.html +++ b/erpnext/website/doctype/home_settings/template.html @@ -4,7 +4,7 @@

{{ doc.headline }}

{% endif %} {% if doc.banner %} - + {% endif %}
{{ doc.main_section_html }} diff --git a/erpnext/website/doctype/related_page/__init__.py b/erpnext/website/doctype/related_page/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/website/doctype/related_page/related_page.txt b/erpnext/website/doctype/related_page/related_page.txt new file mode 100644 index 0000000000..3cb674fd53 --- /dev/null +++ b/erpnext/website/doctype/related_page/related_page.txt @@ -0,0 +1,49 @@ +# DocType, Related Page +[ + + # These values are common in all dictionaries + { + 'creation': '2012-02-01 16:16:47', + 'docstatus': 0, + 'modified': '2012-02-01 16:16:48', + 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all DocType + { + 'colour': 'White:FFF', + 'doctype': 'DocType', + 'istable': 1, + 'module': 'Website', + 'name': '__common__', + 'section_style': 'Simple', + 'show_in_menu': 0, + 'version': 1 + }, + + # These values are common for all DocField + { + 'doctype': 'DocField', + 'fieldname': 'page', + 'fieldtype': 'Link', + 'label': 'Page', + 'name': '__common__', + 'options': 'Page', + 'parent': 'Related Page', + 'parentfield': 'fields', + 'parenttype': 'DocType', + 'permlevel': 0 + }, + + # DocType, Related Page + { + 'doctype': 'DocType', + 'name': 'Related Page' + }, + + # DocField + { + 'doctype': 'DocField' + } +] \ No newline at end of file diff --git a/erpnext/website/doctype/web_page/template.html b/erpnext/website/doctype/web_page/template.html index 8b0049beda..c6e20144bc 100644 --- a/erpnext/website/doctype/web_page/template.html +++ b/erpnext/website/doctype/web_page/template.html @@ -4,10 +4,18 @@
{{ doc.main_section_html }} + {% if doc.next_page_html %} + {{ doc.next_page_html }} + {% endif %}
{{ doc.side_section_html }} + {% if doc.see_also %} +

See Also

+ {{ doc.see_also }} + {% endif %} +
+
-
\ No newline at end of file diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py index d2ad6d34a5..754d3b8c5e 100644 --- a/erpnext/website/doctype/web_page/web_page.py +++ b/erpnext/website/doctype/web_page/web_page.py @@ -18,13 +18,34 @@ class DocType: website.utils.markdown(self.doc, ['main_section', 'side_section']) + self.add_page_links() + with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f: p.content = Template(f.read()).render(doc=self.doc) p.save() website.utils.add_guest_access_to_page(p.name) + self.cleanup_temp() + + def add_page_links(self): + """add links for next_page and see_also""" + if self.doc.next_page: + self.doc.next_page_html = """
+

Next: + %(title)s

""" % {"name":self.doc.next_page, \ + "title": webnotes.conn.get_value("Page", self.doc.next_page, "title")} + + self.doc.see_also = '' + for l in webnotes.conn.sql("""select distinct t1.page, t2.title from + `tabRelated Page` t1, tabPage t2 where + t1.page = t2.name order by t2.title""", as_dict=1): + self.doc.see_also += """

%(title)s

""" % l - del self.doc.fields['main_section_html'] - del self.doc.fields['side_section_html'] - \ No newline at end of file + def cleanup_temp(self): + """cleanup temp fields""" + fl = ['main_section_html', 'side_section_html', 'see_also', 'next_page_html'] + for f in fl: + if f in self.doc.fields: + del self.doc.fields[f] + \ No newline at end of file diff --git a/erpnext/website/doctype/web_page/web_page.txt b/erpnext/website/doctype/web_page/web_page.txt index aa08a8eb9f..e2c839abd3 100644 --- a/erpnext/website/doctype/web_page/web_page.txt +++ b/erpnext/website/doctype/web_page/web_page.txt @@ -5,14 +5,14 @@ { 'creation': '2012-01-31 15:18:49', 'docstatus': 0, - 'modified': '2012-01-31 15:48:50', + 'modified': '2012-02-01 16:19:39', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1328003330', + '_last_update': '1328093309', 'allow_attach': 1, 'colour': 'White:FFF', 'description': 'A custom page is a simple page with the layout - headline, main section, side section\n\nEditing:\n\n- Editing is in [markdown format](http://daringfireball.net/projects/markdown/syntax)\n- You can also add images and embed html code\n\nAccessing the page:\n\n- The page can be accessed as #![page-name] after the main url\n\nIdeal for pages like FAQ, Terms, Help etc.\n\n', @@ -22,7 +22,7 @@ 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 3 + 'version': 5 }, # These values are common for all DocField @@ -97,6 +97,28 @@ 'label': 'Side Section' }, + # DocField + { + 'colour': 'White:FFF', + 'description': 'Link for next page appears at the bottom of the page', + 'doctype': 'DocField', + 'fieldname': 'next_page', + 'fieldtype': 'Link', + 'label': 'Next Page', + 'options': 'Page' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Related pages appear on the right side of the link and are linked both ways.', + 'doctype': 'DocField', + 'fieldname': 'related_pages', + 'fieldtype': 'Table', + 'label': 'Related Pages', + 'options': 'Related Page' + }, + # DocField { 'doctype': 'DocField', diff --git a/version.num b/version.num index 98c1572f67..cfd6ea5ae4 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -327 \ No newline at end of file +335 \ No newline at end of file