From 7018b19f426cfd8589f95813efd4e2c8c9d9e046 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 Feb 2012 13:42:28 +0530 Subject: [PATCH] added website settings, refactored home --- erpnext/patches/jan_mar_2012/website.py | 5 +- erpnext/startup/event_handlers.py | 7 +- erpnext/startup/modules.js | 17 +- erpnext/startup/startup.css | 8 +- erpnext/startup/startup.js | 6 + .../website/Module Def/Website/Website.txt | 34 ++-- erpnext/website/css/website.css | 19 ++- erpnext/website/doctype/blog/blog.py | 2 +- erpnext/website/doctype/blog/template.html | 2 +- .../doctype/home_settings/home_settings.py | 17 -- .../doctype/home_settings/home_settings.txt | 118 ------------- .../doctype/home_settings/template.html | 17 -- .../__init__.py | 0 .../style_settings/custom_template.css | 31 ++++ .../doctype/style_settings/style_settings.js | 6 + .../doctype/style_settings/style_settings.py | 17 ++ .../doctype/style_settings/style_settings.txt | 156 ++++++++++++++++++ .../website/doctype/web_page/template.html | 7 +- erpnext/website/doctype/web_page/web_page.py | 5 +- erpnext/website/doctype/web_page/web_page.txt | 16 +- .../__init__.py | 0 .../website_settings/website_settings.py | 20 +++ .../website_settings.txt} | 40 ++++- erpnext/website/js/topbar.js | 11 +- erpnext/website/page/home/__init__.py | 0 erpnext/website/page/home/home.txt | 42 ----- version.num | 2 +- 27 files changed, 349 insertions(+), 256 deletions(-) delete mode 100644 erpnext/website/doctype/home_settings/home_settings.py delete mode 100644 erpnext/website/doctype/home_settings/home_settings.txt delete mode 100644 erpnext/website/doctype/home_settings/template.html rename erpnext/website/doctype/{home_settings => style_settings}/__init__.py (100%) create mode 100644 erpnext/website/doctype/style_settings/custom_template.css create mode 100644 erpnext/website/doctype/style_settings/style_settings.js create mode 100644 erpnext/website/doctype/style_settings/style_settings.py create mode 100644 erpnext/website/doctype/style_settings/style_settings.txt rename erpnext/website/doctype/{top_bar_settings => website_settings}/__init__.py (100%) create mode 100644 erpnext/website/doctype/website_settings/website_settings.py rename erpnext/website/doctype/{top_bar_settings/top_bar_settings.txt => website_settings/website_settings.txt} (72%) delete mode 100644 erpnext/website/page/home/__init__.py delete mode 100644 erpnext/website/page/home/home.txt diff --git a/erpnext/patches/jan_mar_2012/website.py b/erpnext/patches/jan_mar_2012/website.py index 55a1aefabe..29209bc740 100644 --- a/erpnext/patches/jan_mar_2012/website.py +++ b/erpnext/patches/jan_mar_2012/website.py @@ -11,8 +11,8 @@ def execute(): from webnotes.modules import reload_doc reload_doc('website', 'Role', 'Website Manager') reload_doc('website', 'Module Def', 'Website') - reload_doc('website', 'doctype', 'home_settings') - reload_doc('website', 'doctype', 'top_bar_settings') + reload_doc('website', 'doctype', 'website_settings') + reload_doc('website', 'doctype', 'style_settings') reload_doc('website', 'doctype', 'top_bar_item') reload_doc('website', 'doctype', 'contact_us_settings') reload_doc('website', 'doctype', 'about_us_settings') @@ -22,7 +22,6 @@ def execute(): reload_doc('website', 'doctype', 'product') reload_doc('website', 'doctype', 'web_page') - reload_doc('website', 'page', 'home') reload_doc('website', 'page', 'contact') reload_doc('website', 'page', 'about') reload_doc('website', 'page', 'blog') diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 1bdbcb4b09..d9fb4511a8 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -40,10 +40,11 @@ def boot_session(bootinfo): import webnotes.model.doc if webnotes.session['user']=='Guest': - bootinfo['topbar'] = webnotes.model.doc.getsingle('Top Bar Settings') - bootinfo['topbaritems'] = webnotes.conn.sql("""select label, std_page, custom_page, + bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings') + bootinfo['website_menus'] = webnotes.conn.sql("""select label, std_page, custom_page, parent_label, parentfield - from `tabTop Bar Item` where parent='Top Bar Settings' order by idx asc""", as_dict=1) + from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1) + bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' else: bootinfo['letter_heads'] = get_letter_heads() diff --git a/erpnext/startup/modules.js b/erpnext/startup/modules.js index 9503dbe70d..c22aee00b2 100644 --- a/erpnext/startup/modules.js +++ b/erpnext/startup/modules.js @@ -55,7 +55,7 @@ pscript.select_sidebar_menu = function(t, dt, dn) { var body_background = '#e2e2e2'; MenuPointer = function(parent, label) { - + var me = this; this.wrapper = $a(parent, 'div', '', {padding:'0px', cursor:'pointer', margin:'2px 0px'}); $br(this.wrapper, '3px'); @@ -73,8 +73,10 @@ MenuPointer = function(parent, label) { $(this.wrapper) .hover( - function() { if(!this.selected)$bg(this, '#eee'); } , - function() { if(!this.selected)$bg(this, body_background); } + function() { if(!me.selected) + $bg(this, '#eee'); } , + function() { if(!me.selected) + $bg(this, body_background); } ) $y($td(this.tab, 0, 0), {borderBottom:'1px solid #ddd'}); @@ -84,9 +86,10 @@ MenuPointer = function(parent, label) { // ==================================================================== MenuPointer.prototype.select = function(grey) { - $y($td(this.tab, 0, 0), {color:'#fff', borderBottom:'0px solid #000'}); - //$gr(this.wrapper, '#F84', '#F63'); - $gr(this.wrapper, '#888', '#666'); + $y($td(this.tab, 0, 0), { + color:'#fff', borderBottom:'0px solid #000' + }); + $(this.wrapper).css('background-color', '#999'); this.selected = 1; if(cur_menu_pointer && cur_menu_pointer != this) @@ -99,7 +102,7 @@ MenuPointer.prototype.select = function(grey) { MenuPointer.prototype.deselect = function() { $y($td(this.tab, 0, 0), {color:'#444', borderBottom:'1px solid #ddd'}); - $gr(this.wrapper, body_background, body_background); + $(this.wrapper).css('background-color', body_background); this.selected = 0; } diff --git a/erpnext/startup/startup.css b/erpnext/startup/startup.css index 24d380053b..4f665190ee 100644 --- a/erpnext/startup/startup.css +++ b/erpnext/startup/startup.css @@ -1,13 +1,17 @@ -h1, h2, h3, h4 { +h1, h2, h3, h4, h5 { font-family: Tahoma, Arial, Verdana, sans-serif; font-weight: bold; } -body, span, div, td, input, textarea, button, select { +body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 12px; } +span, div, td, input, textarea, button, select { + font-family: inherit; +} + body { background-color: #e2e2e2; } diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 70dcfc44f5..cbb03a1fba 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -19,6 +19,12 @@ erpnext.startup.start = function() { $dh(page_body.left_sidebar); wn.require('erpnext/website/css/website.css'); wn.require('erpnext/website/js/topbar.js'); + if(wn.boot.custom_css) { + set_style(wn.boot.custom_css); + } + if(wn.boot.website_settings.title_prefix) { + wn.title_prefix = wn.boot.website_settings.title_prefix; + } } else { // modules wn.require('erpnext/startup/modules.js'); diff --git a/erpnext/website/Module Def/Website/Website.txt b/erpnext/website/Module Def/Website/Website.txt index 8ac31c7361..e4238699e0 100644 --- a/erpnext/website/Module Def/Website/Website.txt +++ b/erpnext/website/Module Def/Website/Website.txt @@ -5,7 +5,7 @@ { 'creation': '2012-01-23 17:05:32', 'docstatus': 0, - 'modified': '2012-01-31 15:19:28', + 'modified': '2012-02-02 13:23:41', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -44,14 +44,6 @@ 'name': 'Website' }, - # Module Def Item - { - 'display_name': 'Top Bar Settings', - 'doc_name': 'Top Bar Settings', - 'doc_type': 'Single DocType', - 'doctype': 'Module Def Item' - }, - # Module Def Item { 'display_name': 'Web Page', @@ -76,6 +68,22 @@ 'doctype': 'Module Def Item' }, + # Module Def Item + { + 'display_name': 'Style Settings', + 'doc_name': 'Style Settings', + 'doc_type': 'Single DocType', + 'doctype': 'Module Def Item' + }, + + # Module Def Item + { + 'display_name': 'Website Settings', + 'doc_name': 'Website Settings', + 'doc_type': 'Single DocType', + 'doctype': 'Module Def Item' + }, + # Module Def Item { 'display_name': 'Home Settings', @@ -100,14 +108,6 @@ 'doctype': 'Module Def Item' }, - # Module Def Item - { - 'display_name': 'About Us Settings', - 'doc_name': 'About Us Settings', - 'doc_type': 'Single DocType', - 'doctype': 'Module Def Item' - }, - # Module Def Item { 'display_name': 'Products Settings', diff --git a/erpnext/website/css/website.css b/erpnext/website/css/website.css index 146599bb27..cdea087701 100644 --- a/erpnext/website/css/website.css +++ b/erpnext/website/css/website.css @@ -7,6 +7,10 @@ padding: 20px; } +h1 { + margin-bottom: 15px; +} + footer { width: 900px; margin: auto; @@ -16,8 +20,7 @@ header .topbar .container { margin: auto; } -.web-home-banner { - width: 860px; +.web-head-section { margin-bottom: 20px } @@ -40,9 +43,13 @@ header .topbar .container { overflow-x: hidden; } +footer { + color: #777; +} + .web-footer { + color: inherit; text-align: center; - color: #777; margin: 10px; line-height: 1.7; } @@ -54,11 +61,11 @@ header .topbar .container { .web-footer-menu { margin-bottom: 7px; } -.web-footer a, .web-footer a:visited { +footer a, footer a:visited { color: #777; } -.web-footer a:hover { +footer a:hover { background-color: #777; color: #fff; } @@ -75,5 +82,5 @@ header .topbar .container { } .web-footer-menu ul li:last-child { - border-right: 0px solid #777; + border-right: 0px solid #777 !important; } \ No newline at end of file diff --git a/erpnext/website/doctype/blog/blog.py b/erpnext/website/doctype/blog/blog.py index e9c0d74448..05391eecde 100644 --- a/erpnext/website/doctype/blog/blog.py +++ b/erpnext/website/doctype/blog/blog.py @@ -30,7 +30,7 @@ class DocType(): with open(os.path.join(os.path.dirname(__file__), 'blog_page.js'), 'r') as f: p.script = Template(f.read()).render(doc=self.doc) - + p.save() website.utils.add_guest_access_to_page(p.name) diff --git a/erpnext/website/doctype/blog/template.html b/erpnext/website/doctype/blog/template.html index 80b030ae9c..8c33d83cae 100644 --- a/erpnext/website/doctype/blog/template.html +++ b/erpnext/website/doctype/blog/template.html @@ -1,9 +1,9 @@

Blog

-

{{ doc.title }}

+
{{ doc.content_html }}
diff --git a/erpnext/website/doctype/home_settings/home_settings.py b/erpnext/website/doctype/home_settings/home_settings.py deleted file mode 100644 index 520b81008f..0000000000 --- a/erpnext/website/doctype/home_settings/home_settings.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -generate html -""" -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - """make home html""" - from website.utils import make_template - import os - path = os.path.join(os.path.dirname(__file__), 'template.html') - - webnotes.conn.set_value('Page', 'home', 'content', make_template(self.doc, path)) - \ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/home_settings.txt b/erpnext/website/doctype/home_settings/home_settings.txt deleted file mode 100644 index 413f63fcc4..0000000000 --- a/erpnext/website/doctype/home_settings/home_settings.txt +++ /dev/null @@ -1,118 +0,0 @@ -# DocType, Home Settings -[ - - # These values are common in all dictionaries - { - 'creation': '2012-01-24 15:56:06', - 'docstatus': 0, - 'modified': '2012-01-25 13:31:56', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': '1327476129', - 'allow_attach': 1, - 'colour': 'White:FFF', - 'doctype': 'DocType', - 'issingle': 1, - 'max_attachments': 5, - 'module': 'Website', - 'name': '__common__', - 'section_style': 'Simple', - 'show_in_menu': 0, - 'version': 4 - }, - - # These values are common for all DocField - { - 'doctype': 'DocField', - 'name': '__common__', - 'parent': 'Home Settings', - 'parentfield': 'fields', - 'parenttype': 'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'create': 1, - 'doctype': 'DocPerm', - 'name': '__common__', - 'parent': 'Home Settings', - 'parentfield': 'permissions', - 'parenttype': 'DocType', - 'permlevel': 0, - 'read': 1, - 'write': 1 - }, - - # DocType, Home Settings - { - 'doctype': 'DocType', - 'name': 'Home Settings' - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'role': 'System Manager' - }, - - # DocPerm - { - 'doctype': 'DocPerm', - 'role': 'Website Manager' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'HTML that will appear on the top part of the home page. For no headline, leave blank', - 'doctype': 'DocField', - 'fieldname': 'headline', - 'fieldtype': 'Text', - 'label': 'Headline' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'banner', - 'fieldtype': 'Select', - 'label': 'Banner', - 'options': 'attach_files:' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'For formatting, use \nmarkdown', - 'doctype': 'DocField', - 'fieldname': 'main_section', - 'fieldtype': 'Code', - 'label': 'Main Section' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'For formatting, use \nmarkdown', - 'doctype': 'DocField', - 'fieldname': 'side_section', - 'fieldtype': 'Code', - 'label': 'Side Section' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'file_list', - 'fieldtype': 'Text', - 'hidden': 1, - 'label': 'File List', - 'no_copy': 1, - 'print_hide': 1 - } -] \ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/template.html b/erpnext/website/doctype/home_settings/template.html deleted file mode 100644 index 8129a509ba..0000000000 --- a/erpnext/website/doctype/home_settings/template.html +++ /dev/null @@ -1,17 +0,0 @@ -
-
- {% if doc.headline %} -

{{ doc.headline }}

- {% endif %} - {% if doc.banner %} - - {% endif %} -
- {{ doc.main_section_html }} -
-
- {{ doc.side_section_html }} -
-
-
-
\ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/__init__.py b/erpnext/website/doctype/style_settings/__init__.py similarity index 100% rename from erpnext/website/doctype/home_settings/__init__.py rename to erpnext/website/doctype/style_settings/__init__.py diff --git a/erpnext/website/doctype/style_settings/custom_template.css b/erpnext/website/doctype/style_settings/custom_template.css new file mode 100644 index 0000000000..e6eeeb34fa --- /dev/null +++ b/erpnext/website/doctype/style_settings/custom_template.css @@ -0,0 +1,31 @@ +body { +{% if doc.background_image %} + background: url("files/{{ doc.background_image }}") repeat !important; +{% elif doc.background_color %} + background-color: #{{ doc.background_color }}; +{% endif %} +{% if doc.font %} + font-family: {{ doc.font }} !important; +{% endif %} +{% if doc.font_size %} + font-size: {{ doc.font_size }} !important; +{% endif %} +} + +{% if doc.footer_font_color %} +footer { + color: {{ doc.footer_font_color }}; +} +footer a, footer a:visited, footer a:hover { + color: {{ doc.footer_font_color }}; +} +.web-footer-menu ul li { + border-right: 1px solid {{ doc.footer_font_color }}; +} +{% endif %} + +{% if doc.heading_font %} +h1, h2, h3, h4, h5 { + font-family: {{ doc.heading_font}} !important; +} +{% endif %} diff --git a/erpnext/website/doctype/style_settings/style_settings.js b/erpnext/website/doctype/style_settings/style_settings.js new file mode 100644 index 0000000000..95c4143c72 --- /dev/null +++ b/erpnext/website/doctype/style_settings/style_settings.js @@ -0,0 +1,6 @@ +wn.require('lib/js/lib/jscolor/jscolor.js'); + +cur_frm.cscript.onload_post_render = function() { + cur_frm.fields_dict.background_color.input.className = 'color'; + jscolor.bind(); +} \ No newline at end of file diff --git a/erpnext/website/doctype/style_settings/style_settings.py b/erpnext/website/doctype/style_settings/style_settings.py new file mode 100644 index 0000000000..4aefbf6bf9 --- /dev/null +++ b/erpnext/website/doctype/style_settings/style_settings.py @@ -0,0 +1,17 @@ +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + """make custom css""" + from jinja2 import Template + + with open('erpnext/website/doctype/style_settings/custom_template.css', 'r') as f: + temp = Template(f.read()) + + self.doc.custom_css = temp.render(doc = self.doc) + + from webnotes.session_cache import clear_cache + clear_cache('Guest') + + \ No newline at end of file diff --git a/erpnext/website/doctype/style_settings/style_settings.txt b/erpnext/website/doctype/style_settings/style_settings.txt new file mode 100644 index 0000000000..f07a9479ca --- /dev/null +++ b/erpnext/website/doctype/style_settings/style_settings.txt @@ -0,0 +1,156 @@ +# DocType, Style Settings +[ + + # These values are common in all dictionaries + { + 'creation': '2012-02-02 09:57:25', + 'docstatus': 0, + 'modified': '2012-02-02 10:47:38', + 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all DocType + { + '_last_update': '1328159294', + 'allow_attach': 1, + 'colour': 'White:FFF', + 'description': 'Set your background color, font and image (tiled)', + 'doctype': 'DocType', + 'issingle': 1, + 'max_attachments': 1, + 'module': 'Website', + 'name': '__common__', + 'section_style': 'Simple', + 'show_in_menu': 0, + 'version': 9 + }, + + # These values are common for all DocField + { + 'doctype': 'DocField', + 'name': '__common__', + 'parent': 'Style Settings', + 'parentfield': 'fields', + 'parenttype': 'DocType' + }, + + # These values are common for all DocPerm + { + 'doctype': 'DocPerm', + 'name': '__common__', + 'parent': 'Style Settings', + 'parentfield': 'permissions', + 'parenttype': 'DocType', + 'read': 1, + 'role': 'Website Manager' + }, + + # DocType, Style Settings + { + 'doctype': 'DocType', + 'name': 'Style Settings' + }, + + # DocPerm + { + 'create': 1, + 'doctype': 'DocPerm', + 'permlevel': 0, + 'write': 1 + }, + + # DocPerm + { + 'doctype': 'DocPerm', + 'permlevel': 1 + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Solid background color (default light gray)', + 'doctype': 'DocField', + 'fieldname': 'background_color', + 'fieldtype': 'Data', + 'label': 'Background Color', + 'permlevel': 0 + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'If image is selected, color will be ignored (attach first)', + 'doctype': 'DocField', + 'fieldname': 'background_image', + 'fieldtype': 'Select', + 'label': 'Background Image', + 'options': 'attach_files:', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'font', + 'fieldtype': 'Select', + 'label': 'Font', + 'options': '\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'font_size', + 'fieldtype': 'Select', + 'label': 'Font Size', + 'options': '\n12px\n13px\n14px', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'heading_font', + 'fieldtype': 'Select', + 'label': 'Heaing Font', + 'options': '\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma', + 'permlevel': 0 + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Select a white footer foreground color if you have a dark background', + 'doctype': 'DocField', + 'fieldname': 'footer_font_color', + 'fieldtype': 'Select', + 'label': 'Footer Font Color', + 'options': '\nwhite', + 'permlevel': 0 + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'Auto generated', + 'doctype': 'DocField', + 'fieldname': 'custom_css', + 'fieldtype': 'Code', + 'label': 'Custom CSS', + 'permlevel': 1 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'file_list', + 'fieldtype': 'Text', + 'hidden': 1, + 'label': 'File List', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 + } +] \ 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 c6e20144bc..faacca1566 100644 --- a/erpnext/website/doctype/web_page/template.html +++ b/erpnext/website/doctype/web_page/template.html @@ -1,7 +1,10 @@
-

{{ doc.title }}

-
+ {% if doc.head_section %} +
+ {{ doc.head_section_html }} +
+ {% endif %}
{{ doc.main_section_html }} {% if doc.next_page_html %} diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py index 754d3b8c5e..14a082b091 100644 --- a/erpnext/website/doctype/web_page/web_page.py +++ b/erpnext/website/doctype/web_page/web_page.py @@ -16,7 +16,7 @@ class DocType: from jinja2 import Template import os - website.utils.markdown(self.doc, ['main_section', 'side_section']) + website.utils.markdown(self.doc, ['head_section','main_section', 'side_section']) self.add_page_links() @@ -44,7 +44,8 @@ class DocType: def cleanup_temp(self): """cleanup temp fields""" - fl = ['main_section_html', 'side_section_html', 'see_also', 'next_page_html'] + fl = ['main_section_html', 'side_section_html', 'see_also', \ + 'next_page_html', 'head_section_html'] for f in fl: if f in self.doc.fields: del self.doc.fields[f] diff --git a/erpnext/website/doctype/web_page/web_page.txt b/erpnext/website/doctype/web_page/web_page.txt index e2c839abd3..0bacc43d67 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-02-01 16:19:39', + 'modified': '2012-02-02 13:15:36', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1328093309', + '_last_update': '1328093379', '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': 5 + 'version': 6 }, # These values are common for all DocField @@ -77,6 +77,16 @@ 'reqd': 1 }, + # DocField + { + 'colour': 'White:FFF', + 'description': 'Section that will span 2 columns, formatted as markdown. If no head, leave blank. If you are displaying a banner, it must be 860px', + 'doctype': 'DocField', + 'fieldname': 'head_section', + 'fieldtype': 'Text', + 'label': 'Head Section' + }, + # DocField { 'colour': 'White:FFF', diff --git a/erpnext/website/doctype/top_bar_settings/__init__.py b/erpnext/website/doctype/website_settings/__init__.py similarity index 100% rename from erpnext/website/doctype/top_bar_settings/__init__.py rename to erpnext/website/doctype/website_settings/__init__.py diff --git a/erpnext/website/doctype/website_settings/website_settings.py b/erpnext/website/doctype/website_settings/website_settings.py new file mode 100644 index 0000000000..0cbc97d24e --- /dev/null +++ b/erpnext/website/doctype/website_settings/website_settings.py @@ -0,0 +1,20 @@ +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + """clear cache""" + # set home page + import webnotes + from webnotes.model.doc import Document + + webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""") + + d = Document('Default Home Page') + d.parent = 'Control Panel' + d.role = 'Guest' + d.home_page = self.doc.home_page + d.save() + + from webnotes.session_cache import clear_cache + clear_cache('Guest') \ No newline at end of file diff --git a/erpnext/website/doctype/top_bar_settings/top_bar_settings.txt b/erpnext/website/doctype/website_settings/website_settings.txt similarity index 72% rename from erpnext/website/doctype/top_bar_settings/top_bar_settings.txt rename to erpnext/website/doctype/website_settings/website_settings.txt index ad9a158cc5..aaa7327257 100644 --- a/erpnext/website/doctype/top_bar_settings/top_bar_settings.txt +++ b/erpnext/website/doctype/website_settings/website_settings.txt @@ -1,18 +1,18 @@ -# DocType, Top Bar Settings +# DocType, Website Settings [ # These values are common in all dictionaries { - 'creation': '2012-01-24 10:21:41', + 'creation': '2012-02-02 13:19:50', 'docstatus': 0, - 'modified': '2012-01-31 15:55:34', + 'modified': '2012-02-02 13:31:24', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1327382102', + '_last_update': '1328169455', 'allow_attach': 1, 'colour': 'White:FFF', 'doctype': 'DocType', @@ -23,14 +23,14 @@ 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 4 + 'version': 3 }, # These values are common for all DocField { 'doctype': 'DocField', 'name': '__common__', - 'parent': 'Top Bar Settings', + 'parent': 'Website Settings', 'parentfield': 'fields', 'parenttype': 'DocType', 'permlevel': 0 @@ -41,7 +41,7 @@ 'create': 1, 'doctype': 'DocPerm', 'name': '__common__', - 'parent': 'Top Bar Settings', + 'parent': 'Website Settings', 'parentfield': 'permissions', 'parenttype': 'DocType', 'permlevel': 0, @@ -49,10 +49,10 @@ 'write': 1 }, - # DocType, Top Bar Settings + # DocType, Website Settings { 'doctype': 'DocType', - 'name': 'Top Bar Settings' + 'name': 'Website Settings' }, # DocPerm @@ -74,6 +74,28 @@ 'label': 'Top Bar' }, + # DocField + { + 'colour': 'White:FFF', + 'description': 'The name of your company / website as you want to appear on browser title bar. All pages will have this as the prefix to the title.', + 'doctype': 'DocField', + 'fieldname': 'title_prefix', + 'fieldtype': 'Data', + 'label': 'Title Prefix' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'The "Web Page" that is the website home page', + 'doctype': 'DocField', + 'fieldname': 'home_page', + 'fieldtype': 'Link', + 'label': 'Home Page', + 'options': 'Web Page', + 'reqd': 1 + }, + # DocField { 'colour': 'White:FFF', diff --git a/erpnext/website/js/topbar.js b/erpnext/website/js/topbar.js index d7cba89554..8a7870c7de 100644 --- a/erpnext/website/js/topbar.js +++ b/erpnext/website/js/topbar.js @@ -13,14 +13,14 @@ wn.require('lib/js/bootstrap/bootstrap-dropdown.js'); erpnext.topbar.TopBar = Class.extend({ init: function() { this.make(); - $('.brand').html(wn.boot.topbar.brand_html); + $('.brand').html(wn.boot.website_settings.brand_html); this.make_items(); }, make: function() { $('header').append('
\
\
\ - [brand]\ + [brand]\ \ \ @@ -30,9 +30,10 @@ erpnext.topbar.TopBar = Class.extend({
\
\
'); + $('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page')) }, make_items: function() { - var items = wn.boot.topbaritems + var items = wn.boot.website_menus for(var i=0;i© %(copyright)s
\ \ -
', wn.boot.topbar)); +
', wn.boot.website_settings)); this.make_items(); }, make_items: function() { - var items = wn.boot.topbaritems + var items = wn.boot.website_menus for(var i=0;i