From 87eed83ff38a0a4cbb1a58a6690893ba0ddbe031 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 25 Dec 2013 15:18:48 +0530 Subject: [PATCH] Redesigned templates. Now all templates must be inside templates/pages templates/generators --- webnotes/__init__.py | 7 +- .../core/page/applications/applications.js | 2 +- webnotes/public/js/legacy/form.js | 4 +- webnotes/public/js/wn/form/control.js | 2 +- webnotes/public/js/wn/form/grid.js | 111 ++++++++++-------- webnotes/public/js/wn/form/layout.js | 12 +- webnotes/public/js/wn/model/model.js | 9 +- webnotes/sessions.py | 4 +- webnotes/{core => }/templates/__init__.py | 0 webnotes/{website => }/templates/base.html | 4 +- .../generators}/__init__.py | 0 .../templates/generators/blog_post.html | 8 +- .../templates/generators/blog_post.py | 0 .../templates/generators/web_page.html | 6 +- .../templates/generators/web_page.py | 0 .../includes}/__init__.py | 0 .../templates/includes/blog.css | 0 .../blog_post => }/templates/includes/blog.js | 2 +- .../templates/includes/blog_footer.html | 0 .../templates/includes/blog_subscribe.html | 0 .../templates/includes/blogger.html | 0 .../templates/includes/comment.html | 0 .../templates/includes/comments.html | 4 +- .../templates/includes/comments.py | 2 +- .../templates/includes/contact.js | 0 .../templates/includes/footer.html | 4 +- .../{website => }/templates/includes/login.js | 0 .../templates/includes/navbar.html | 0 .../templates/includes/slideshow.html | 0 .../{website => }/templates/pages/404.html | 0 .../templates => templates/pages}/__init__.py | 0 .../templates/pages/about.html | 0 .../templates/pages/about.py | 0 webnotes/{core => }/templates/pages/app.html | 0 webnotes/{core => }/templates/pages/app.py | 0 .../blog_post => }/templates/pages/blog.html | 6 +- .../blog_post => }/templates/pages/blog.py | 0 .../templates/pages/contact.html | 2 +- .../templates/pages/contact.py | 0 .../{website => }/templates/pages/error.html | 0 .../{website => }/templates/pages/error.py | 0 .../{website => }/templates/pages/login.html | 2 +- .../templates/pages/message.html | 0 .../{website => }/templates/pages/message.py | 0 .../{website => }/templates/pages/print.html | 0 .../{website => }/templates/pages/print.py | 0 webnotes/{website => }/templates/pages/rss.py | 0 .../{website => }/templates/pages/rss.xml | 0 .../{website => }/templates/pages/sitemap.py | 0 .../{website => }/templates/pages/sitemap.xml | 0 .../pages/style_settings.css} | 0 .../pages/style_settings.py} | 0 .../templates/pages/update-password.html | 0 .../templates/pages/update_password.py | 0 .../pages/website_script.js} | 0 .../pages/website_script.py} | 0 .../blogger => }/templates/pages/writers.html | 4 +- .../blogger => }/templates/pages/writers.py | 0 .../templates/pages/__init__.py | 0 .../doctype/blog_post/templates/__init__.py | 0 .../templates/generators/__init__.py | 0 .../blog_post/templates/includes/__init__.py | 0 .../blog_post/templates/pages/__init__.py | 0 .../doctype/blogger/templates/__init__.py | 0 .../blogger/templates/pages/__init__.py | 0 .../contact_us_settings/templates/__init__.py | 0 .../templates/pages/__init__.py | 0 .../style_settings/templates/__init__.py | 0 .../templates/pages/__init__.py | 0 .../doctype/web_page/templates/__init__.py | 0 .../web_page/templates/generators/__init__.py | 0 .../website_script/templates/__init__.py | 0 .../templates/pages/__init__.py | 0 .../website_sitemap_config.py | 22 ++-- .../website/templates/includes/__init__.py | 0 webnotes/website/templates/pages/__init__.py | 1 - webnotes/webutils.py | 2 +- 77 files changed, 116 insertions(+), 104 deletions(-) rename webnotes/{core => }/templates/__init__.py (100%) rename webnotes/{website => }/templates/base.html (86%) rename webnotes/{core/templates/pages => templates/generators}/__init__.py (100%) rename webnotes/{website/doctype/blog_post => }/templates/generators/blog_post.html (76%) rename webnotes/{website/doctype/blog_post => }/templates/generators/blog_post.py (100%) rename webnotes/{website/doctype/web_page => }/templates/generators/web_page.html (90%) rename webnotes/{website/doctype/web_page => }/templates/generators/web_page.py (100%) rename webnotes/{website/doctype/about_us_settings/templates => templates/includes}/__init__.py (100%) rename webnotes/{website/doctype/blog_post => }/templates/includes/blog.css (100%) rename webnotes/{website/doctype/blog_post => }/templates/includes/blog.js (96%) rename webnotes/{website/doctype/blog_post => }/templates/includes/blog_footer.html (100%) rename webnotes/{website/doctype/blog_post => }/templates/includes/blog_subscribe.html (100%) rename webnotes/{website/doctype/blog_post => }/templates/includes/blogger.html (100%) rename webnotes/{website => }/templates/includes/comment.html (100%) rename webnotes/{website => }/templates/includes/comments.html (95%) rename webnotes/{website => }/templates/includes/comments.py (95%) rename webnotes/{website/doctype/contact_us_settings => }/templates/includes/contact.js (100%) rename webnotes/{website => }/templates/includes/footer.html (92%) rename webnotes/{website => }/templates/includes/login.js (100%) rename webnotes/{website => }/templates/includes/navbar.html (100%) rename webnotes/{website/doctype/website_slideshow => }/templates/includes/slideshow.html (100%) rename webnotes/{website => }/templates/pages/404.html (100%) rename webnotes/{website/templates => templates/pages}/__init__.py (100%) rename webnotes/{website/doctype/about_us_settings => }/templates/pages/about.html (100%) rename webnotes/{website/doctype/about_us_settings => }/templates/pages/about.py (100%) rename webnotes/{core => }/templates/pages/app.html (100%) rename webnotes/{core => }/templates/pages/app.py (100%) rename webnotes/{website/doctype/blog_post => }/templates/pages/blog.html (77%) rename webnotes/{website/doctype/blog_post => }/templates/pages/blog.py (100%) rename webnotes/{website/doctype/contact_us_settings => }/templates/pages/contact.html (95%) rename webnotes/{website/doctype/contact_us_settings => }/templates/pages/contact.py (100%) rename webnotes/{website => }/templates/pages/error.html (100%) rename webnotes/{website => }/templates/pages/error.py (100%) rename webnotes/{website => }/templates/pages/login.html (97%) rename webnotes/{website => }/templates/pages/message.html (100%) rename webnotes/{website => }/templates/pages/message.py (100%) rename webnotes/{website => }/templates/pages/print.html (100%) rename webnotes/{website => }/templates/pages/print.py (100%) rename webnotes/{website => }/templates/pages/rss.py (100%) rename webnotes/{website => }/templates/pages/rss.xml (100%) rename webnotes/{website => }/templates/pages/sitemap.py (100%) rename webnotes/{website => }/templates/pages/sitemap.xml (100%) rename webnotes/{website/doctype/style_settings/templates/pages/wn-web.css => templates/pages/style_settings.css} (100%) rename webnotes/{website/doctype/style_settings/templates/pages/wn_web.py => templates/pages/style_settings.py} (100%) rename webnotes/{website => }/templates/pages/update-password.html (100%) rename webnotes/{website => }/templates/pages/update_password.py (100%) rename webnotes/{website/doctype/website_script/templates/pages/wn-web.js => templates/pages/website_script.js} (100%) rename webnotes/{website/doctype/website_script/templates/pages/wn_web.py => templates/pages/website_script.py} (100%) rename webnotes/{website/doctype/blogger => }/templates/pages/writers.html (69%) rename webnotes/{website/doctype/blogger => }/templates/pages/writers.py (100%) delete mode 100644 webnotes/website/doctype/about_us_settings/templates/pages/__init__.py delete mode 100644 webnotes/website/doctype/blog_post/templates/__init__.py delete mode 100644 webnotes/website/doctype/blog_post/templates/generators/__init__.py delete mode 100644 webnotes/website/doctype/blog_post/templates/includes/__init__.py delete mode 100644 webnotes/website/doctype/blog_post/templates/pages/__init__.py delete mode 100644 webnotes/website/doctype/blogger/templates/__init__.py delete mode 100644 webnotes/website/doctype/blogger/templates/pages/__init__.py delete mode 100644 webnotes/website/doctype/contact_us_settings/templates/__init__.py delete mode 100644 webnotes/website/doctype/contact_us_settings/templates/pages/__init__.py delete mode 100644 webnotes/website/doctype/style_settings/templates/__init__.py delete mode 100644 webnotes/website/doctype/style_settings/templates/pages/__init__.py delete mode 100644 webnotes/website/doctype/web_page/templates/__init__.py delete mode 100644 webnotes/website/doctype/web_page/templates/generators/__init__.py delete mode 100644 webnotes/website/doctype/website_script/templates/__init__.py delete mode 100644 webnotes/website/doctype/website_script/templates/pages/__init__.py delete mode 100644 webnotes/website/templates/includes/__init__.py delete mode 100644 webnotes/website/templates/pages/__init__.py diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 97cd0fae71..09f9aa9da2 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -102,6 +102,7 @@ def init(site, sites_path=None): local.rollback_observers = [] local.module_app = None local.app_modules = None + local.user = None setup_module_map() @@ -263,8 +264,10 @@ def clear_cache(user=None, doctype=None): def get_roles(username=None): import webnotes.profile - if not username or username==session.user: - return user.get_roles() + if not local.session: + return ["Guest"] + elif not username or username==local.session.user: + return local.user.get_roles() else: return webnotes.profile.Profile(username).get_roles() diff --git a/webnotes/core/page/applications/applications.js b/webnotes/core/page/applications/applications.js index 2515f9a272..41d991d1ae 100644 --- a/webnotes/core/page/applications/applications.js +++ b/webnotes/core/page/applications/applications.js @@ -52,7 +52,7 @@ wn.pages['applications'].onload = function(wrapper) { if(!r.exc) { msgprint(" Installed"); msgprint("Refreshing..."); - setTimeout(2000, window.location.reload) + setTimeout(window.location.reload, 2000) } } }) diff --git a/webnotes/public/js/legacy/form.js b/webnotes/public/js/legacy/form.js index 2d76628288..bdceb9bf7b 100644 --- a/webnotes/public/js/legacy/form.js +++ b/webnotes/public/js/legacy/form.js @@ -432,7 +432,7 @@ _f.Frm.prototype.refresh_field = function(fname) { } _f.Frm.prototype.refresh_fields = function() { - this.layout.refresh(); + this.layout.refresh(this.doc); this.layout.primary_button = $(this.wrapper).find(".btn-primary"); // cleanup activities after refresh @@ -634,7 +634,7 @@ _f.Frm.prototype.save = function(save_action, callback, btn, on_error) { $(document.activeElement).blur(); // let any pending js process finish - setTimeout(10, this._save(save_action, callback, btn, on_error)); + setTimeout(100, this._save(save_action, callback, btn, on_error)); } _f.Frm.prototype._save = function(save_action, callback, btn, on_error) { diff --git a/webnotes/public/js/wn/form/control.js b/webnotes/public/js/wn/form/control.js index 21d5453d21..df46570d12 100644 --- a/webnotes/public/js/wn/form/control.js +++ b/webnotes/public/js/wn/form/control.js @@ -187,7 +187,7 @@ wn.ui.form.ControlInput = wn.ui.form.Control.extend({ if(me.doctype && me.docname) { me.value = wn.model.get_value(me.doctype, me.docname, me.df.fieldname); } - + if(me.disp_status=="Write") { me.disp_area && $(me.disp_area).toggle(false); $(me.input_area).toggle(true); diff --git a/webnotes/public/js/wn/form/grid.js b/webnotes/public/js/wn/form/grid.js index 0966dc9369..c93079ad52 100644 --- a/webnotes/public/js/wn/form/grid.js +++ b/webnotes/public/js/wn/form/grid.js @@ -229,9 +229,7 @@ wn.ui.form.GridRow = Class.extend({ // refersh form fields if(this.show) { - $.each(this.fields, function(i, f) { - f.refresh(); - }); + this.layout.refresh(this.doc); } }, make_static_display: function() { @@ -400,54 +398,67 @@ wn.ui.form.GridRow = Class.extend({ this.make_form(); this.form_area.empty(); - var me = this, - make_row = function(label) { - if(label) - $('

'+ label +'

\ -
') - .appendTo(me.form_area); - - var row = $('
') - .appendTo(me.form_area); - - var col_spans = 6; - if(row.parents(".form-column:first").hasClass("col-md-6")) - col_spans = 12; - - var col1 = $('
').appendTo(row), - col2 = $('
').appendTo(row); - - return [col1, col2]; - }, - cols = make_row(), - cnt = 0; - - $.each(me.docfields, function(ci, df) { - if(!df.hidden) { - if(df.fieldtype=="Section Break") { - cols = make_row(df.label); - cnt = 0; - return; - } - var fieldwrapper = $('
') - .appendTo(cols[cnt % 2]) - var fieldobj = make_field(df, me.parent_df.options, - fieldwrapper.get(0), me.frm); - fieldobj.docname = me.doc.name; - fieldobj.refresh(); - fieldobj.input && - $(fieldobj.input).css({"max-height": "100px"}); - - // set field properties - // used for setting custom get queries in links - if(me.grid.fieldinfo[df.fieldname]) - $.extend(fieldobj, me.grid.fieldinfo[df.fieldname]); - - me.fields.push(fieldobj); - me.fields_dict[df.fieldname] = fieldobj; - cnt++; - } + this.layout = new wn.ui.form.Layout({ + fields: this.docfields, + body: this.form_area, + no_submit_on_enter: true, + frm: this.frm, }); + this.layout.make(); + this.layout.refresh(this.doc) + + this.fields = this.layout.fields; + this.fields_dict = this.layout.fields_dict; + + + // var me = this, + // make_row = function(label) { + // if(label) + // $('

'+ label +'

\ + //
') + // .appendTo(me.form_area); + // + // var row = $('
') + // .appendTo(me.form_area); + // + // var col_spans = 6; + // if(row.parents(".form-column:first").hasClass("col-md-6")) + // col_spans = 12; + // + // var col1 = $('
').appendTo(row), + // col2 = $('
').appendTo(row); + // + // return [col1, col2]; + // }, + // cols = make_row(), + // cnt = 0; + // + // $.each(me.docfields, function(ci, df) { + // if(!df.hidden) { + // if(df.fieldtype=="Section Break") { + // cols = make_row(df.label); + // cnt = 0; + // return; + // } + // var fieldwrapper = $('
') + // .appendTo(cols[cnt % 2]) + // var fieldobj = make_field(df, me.parent_df.options, + // fieldwrapper.get(0), me.frm); + // fieldobj.docname = me.doc.name; + // fieldobj.refresh(); + // fieldobj.input && + // $(fieldobj.input).css({"max-height": "100px"}); + // + // // set field properties + // // used for setting custom get queries in links + // if(me.grid.fieldinfo[df.fieldname]) + // $.extend(fieldobj, me.grid.fieldinfo[df.fieldname]); + // + // me.fields.push(fieldobj); + // me.fields_dict[df.fieldname] = fieldobj; + // cnt++; + // } + // }); this.toggle_add_delete_button_display(this.wrapper.find(".panel:first")); diff --git a/webnotes/public/js/wn/form/layout.js b/webnotes/public/js/wn/form/layout.js index e74e5ffa95..4a7f424f6e 100644 --- a/webnotes/public/js/wn/form/layout.js +++ b/webnotes/public/js/wn/form/layout.js @@ -36,13 +36,15 @@ wn.ui.form.Layout = Class.extend({ this.wrapper.toggle(true); } }, - refresh: function() { + refresh: function(doc) { var me = this; + if(doc) this.doc = doc; $.each(this.fields_list, function(i, fieldobj) { - if(me.frm) { - fieldobj.docname = me.frm.docname; - fieldobj.df = wn.meta.get_docfield(me.frm.doctype, - fieldobj.df.fieldname, me.frm.docname); + if(me.doc) { + fieldobj.doctype = me.doc.doctype; + fieldobj.docname = me.doc.name; + fieldobj.df = wn.meta.get_docfield(me.doc.doctype, + fieldobj.df.fieldname, me.doc.name); // on form change, permissions can change fieldobj.perm = me.frm.perm; }; diff --git a/webnotes/public/js/wn/model/model.js b/webnotes/public/js/wn/model/model.js index d578f22cc4..90a104fa46 100644 --- a/webnotes/public/js/wn/model/model.js +++ b/webnotes/public/js/wn/model/model.js @@ -184,10 +184,10 @@ $.extend(wn.model, { /* help: Set a value locally (if changed) and execute triggers */ if(!name) name = doctype; var doc = locals[doctype] && locals[doctype][name] || null; + if(doc && doc[fieldname] !== value) { doc[fieldname] = value; - // trigger this after an interval since this will stop propogation - setTimeout(10, function() { wn.model.trigger(fieldname, value, doc); }); + wn.model.trigger(fieldname, value, doc); return true; } else { // execute link triggers (want to reselect to execute triggers) @@ -206,7 +206,7 @@ $.extend(wn.model, { raise "CustomerAgeError"; } }) */ - + console.log([doctype, fieldname]) wn.provide("wn.model.events." + doctype); if(!wn.model.events[doctype][fieldname]) { wn.model.events[doctype][fieldname] = []; @@ -215,12 +215,13 @@ $.extend(wn.model, { }, trigger: function(fieldname, value, doc) { + var run = function(events, event_doc) { $.each(events || [], function(i, fn) { fn && fn(fieldname, value, event_doc || doc); }); }; - + if(wn.model.events[doc.doctype]) { // field-level diff --git a/webnotes/sessions.py b/webnotes/sessions.py index 0d181c6eb6..a907df8379 100644 --- a/webnotes/sessions.py +++ b/webnotes/sessions.py @@ -151,8 +151,8 @@ class Session: else: self.start_as_guest() - webnotes.local.lang = webnotes.cache().get_value("lang:" + data.user, - lambda: webnotes.translate.get_user_lang(data.user)) + webnotes.local.lang = webnotes.cache().get_value("lang:" + self.data.user, + lambda: webnotes.translate.get_user_lang(self.data.user)) def get_session_record(self): """get session record, or return the standard Guest Record""" diff --git a/webnotes/core/templates/__init__.py b/webnotes/templates/__init__.py similarity index 100% rename from webnotes/core/templates/__init__.py rename to webnotes/templates/__init__.py diff --git a/webnotes/website/templates/base.html b/webnotes/templates/base.html similarity index 86% rename from webnotes/website/templates/base.html rename to webnotes/templates/base.html index 7708a81177..f119120f04 100644 --- a/webnotes/website/templates/base.html +++ b/webnotes/templates/base.html @@ -27,10 +27,10 @@ {% block banner %}{{ banner_html or "" }}{% endblock %} - {% block navbar %}{% include "website/templates/includes/navbar.html" %}{% endblock %} + {% block navbar %}{% include "templates/includes/navbar.html" %}{% endblock %}
{% block content %}{% endblock %}
- {% block footer %}{% include "website/templates/includes/footer.html" %}{% endblock %} + {% block footer %}{% include "templates/includes/footer.html" %}{% endblock %} \ No newline at end of file diff --git a/webnotes/core/templates/pages/__init__.py b/webnotes/templates/generators/__init__.py similarity index 100% rename from webnotes/core/templates/pages/__init__.py rename to webnotes/templates/generators/__init__.py diff --git a/webnotes/website/doctype/blog_post/templates/generators/blog_post.html b/webnotes/templates/generators/blog_post.html similarity index 76% rename from webnotes/website/doctype/blog_post/templates/generators/blog_post.html rename to webnotes/templates/generators/blog_post.html index 5250cd1408..1ddf7d5ac5 100644 --- a/webnotes/website/doctype/blog_post/templates/generators/blog_post.html +++ b/webnotes/templates/generators/blog_post.html @@ -15,21 +15,21 @@ {% if blogger_info %}
- {% include "website/doctype/blog_post/templates/includes/blogger.html" %} + {% include "templates/includes/blogger.html" %} {% endif %}

Comments

- {% include 'website/templates/includes/comments.html' %} + {% include 'templates/includes/comments.html' %}
-{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} +{% include 'templates/includes/blog_footer.html' %} {% endblock %} \ No newline at end of file diff --git a/webnotes/website/doctype/blog_post/templates/generators/blog_post.py b/webnotes/templates/generators/blog_post.py similarity index 100% rename from webnotes/website/doctype/blog_post/templates/generators/blog_post.py rename to webnotes/templates/generators/blog_post.py diff --git a/webnotes/website/doctype/web_page/templates/generators/web_page.html b/webnotes/templates/generators/web_page.html similarity index 90% rename from webnotes/website/doctype/web_page/templates/generators/web_page.html rename to webnotes/templates/generators/web_page.html index 8cd2167518..5b9e277fba 100644 --- a/webnotes/website/doctype/web_page/templates/generators/web_page.html +++ b/webnotes/templates/generators/web_page.html @@ -15,7 +15,7 @@ {%- endif %} {%- endblock %} - {% include "website/doctype/website_slideshow/templates/includes/slideshow.html" %} + {% include "templates/includes/slideshow.html" %}
{{ main_section or "" }}
@@ -50,7 +50,7 @@ {% if enable_comments -%}

Discuss

- {% include 'website/templates/includes/comments.html' %} + {% include 'templates/includes/comments.html' %} {%- endif %} {%- endblock %}
@@ -58,7 +58,7 @@ $(function() { if(window.logged_in && getCookie("system_user")==="yes") { wn.has_permission("Web Page", "{{ name }}", "write", function(r) { - wn.require("js/wn/website/editable.js"); + wn.require("assets/webnotes/js/wn/website/editable.js"); wn.make_editable($(".web-page-content"), "Web Page", "{{ name }}", "main_section"); }); } diff --git a/webnotes/website/doctype/web_page/templates/generators/web_page.py b/webnotes/templates/generators/web_page.py similarity index 100% rename from webnotes/website/doctype/web_page/templates/generators/web_page.py rename to webnotes/templates/generators/web_page.py diff --git a/webnotes/website/doctype/about_us_settings/templates/__init__.py b/webnotes/templates/includes/__init__.py similarity index 100% rename from webnotes/website/doctype/about_us_settings/templates/__init__.py rename to webnotes/templates/includes/__init__.py diff --git a/webnotes/website/doctype/blog_post/templates/includes/blog.css b/webnotes/templates/includes/blog.css similarity index 100% rename from webnotes/website/doctype/blog_post/templates/includes/blog.css rename to webnotes/templates/includes/blog.css diff --git a/webnotes/website/doctype/blog_post/templates/includes/blog.js b/webnotes/templates/includes/blog.js similarity index 96% rename from webnotes/website/doctype/blog_post/templates/includes/blog.js rename to webnotes/templates/includes/blog.js index 4ab97b0920..edde41566e 100644 --- a/webnotes/website/doctype/blog_post/templates/includes/blog.js +++ b/webnotes/templates/includes/blog.js @@ -28,7 +28,7 @@ var blog = { method: "GET", url: "/", data: { - cmd: "website.doctype.blog_post.blog_post.get_blog_list", + cmd: "webnotes.website.doctype.blog_post.blog_post.get_blog_list", start: blog.start, by: get_url_arg("by"), category: get_url_arg("category") diff --git a/webnotes/website/doctype/blog_post/templates/includes/blog_footer.html b/webnotes/templates/includes/blog_footer.html similarity index 100% rename from webnotes/website/doctype/blog_post/templates/includes/blog_footer.html rename to webnotes/templates/includes/blog_footer.html diff --git a/webnotes/website/doctype/blog_post/templates/includes/blog_subscribe.html b/webnotes/templates/includes/blog_subscribe.html similarity index 100% rename from webnotes/website/doctype/blog_post/templates/includes/blog_subscribe.html rename to webnotes/templates/includes/blog_subscribe.html diff --git a/webnotes/website/doctype/blog_post/templates/includes/blogger.html b/webnotes/templates/includes/blogger.html similarity index 100% rename from webnotes/website/doctype/blog_post/templates/includes/blogger.html rename to webnotes/templates/includes/blogger.html diff --git a/webnotes/website/templates/includes/comment.html b/webnotes/templates/includes/comment.html similarity index 100% rename from webnotes/website/templates/includes/comment.html rename to webnotes/templates/includes/comment.html diff --git a/webnotes/website/templates/includes/comments.html b/webnotes/templates/includes/comments.html similarity index 95% rename from webnotes/website/templates/includes/comments.html rename to webnotes/templates/includes/comments.html index a7c6e8fbf6..88b28a95a2 100644 --- a/webnotes/website/templates/includes/comments.html +++ b/webnotes/templates/includes/comments.html @@ -6,7 +6,7 @@
{% for comment in comment_list %} - {% include "website/templates/includes/comment.html" %} + {% include "templates/includes/comment.html" %} {% endfor %}
@@ -65,7 +65,7 @@ $(document).ready(function() { wn.call({ btn: this, type: "POST", - method: "website.templates.includes.comments.add_comment", + method: "webnotes.templates.includes.comments.add_comment", args: args, callback: function(r) { if(r.exc) { diff --git a/webnotes/website/templates/includes/comments.py b/webnotes/templates/includes/comments.py similarity index 95% rename from webnotes/website/templates/includes/comments.py rename to webnotes/templates/includes/comments.py index fb2f7ae688..00a47afe9e 100644 --- a/webnotes/website/templates/includes/comments.py +++ b/webnotes/templates/includes/comments.py @@ -52,7 +52,7 @@ def add_comment(args=None): message='%(comment)s

By %(comment_by_fullname)s

' % args, ref_doctype=comment.doc.comment_doctype, ref_docname=comment.doc.comment_docname) - template = webnotes.get_template("lib/website/templates/includes/comment.html") + template = webnotes.get_template("templates/includes/comment.html") return template.render({"comment": comment.doc.fields}) \ No newline at end of file diff --git a/webnotes/website/doctype/contact_us_settings/templates/includes/contact.js b/webnotes/templates/includes/contact.js similarity index 100% rename from webnotes/website/doctype/contact_us_settings/templates/includes/contact.js rename to webnotes/templates/includes/contact.js diff --git a/webnotes/website/templates/includes/footer.html b/webnotes/templates/includes/footer.html similarity index 92% rename from webnotes/website/templates/includes/footer.html rename to webnotes/templates/includes/footer.html index 3bcf809be7..b02a4e66d5 100644 --- a/webnotes/website/templates/includes/footer.html +++ b/webnotes/templates/includes/footer.html @@ -44,7 +44,7 @@ {# powered #}
@@ -52,6 +52,6 @@
- {% block extension %}{% endblock %} + {% block extension %}{% include "templates/includes/footer_extension.html" %}{% endblock %}
\ No newline at end of file diff --git a/webnotes/website/templates/includes/login.js b/webnotes/templates/includes/login.js similarity index 100% rename from webnotes/website/templates/includes/login.js rename to webnotes/templates/includes/login.js diff --git a/webnotes/website/templates/includes/navbar.html b/webnotes/templates/includes/navbar.html similarity index 100% rename from webnotes/website/templates/includes/navbar.html rename to webnotes/templates/includes/navbar.html diff --git a/webnotes/website/doctype/website_slideshow/templates/includes/slideshow.html b/webnotes/templates/includes/slideshow.html similarity index 100% rename from webnotes/website/doctype/website_slideshow/templates/includes/slideshow.html rename to webnotes/templates/includes/slideshow.html diff --git a/webnotes/website/templates/pages/404.html b/webnotes/templates/pages/404.html similarity index 100% rename from webnotes/website/templates/pages/404.html rename to webnotes/templates/pages/404.html diff --git a/webnotes/website/templates/__init__.py b/webnotes/templates/pages/__init__.py similarity index 100% rename from webnotes/website/templates/__init__.py rename to webnotes/templates/pages/__init__.py diff --git a/webnotes/website/doctype/about_us_settings/templates/pages/about.html b/webnotes/templates/pages/about.html similarity index 100% rename from webnotes/website/doctype/about_us_settings/templates/pages/about.html rename to webnotes/templates/pages/about.html diff --git a/webnotes/website/doctype/about_us_settings/templates/pages/about.py b/webnotes/templates/pages/about.py similarity index 100% rename from webnotes/website/doctype/about_us_settings/templates/pages/about.py rename to webnotes/templates/pages/about.py diff --git a/webnotes/core/templates/pages/app.html b/webnotes/templates/pages/app.html similarity index 100% rename from webnotes/core/templates/pages/app.html rename to webnotes/templates/pages/app.html diff --git a/webnotes/core/templates/pages/app.py b/webnotes/templates/pages/app.py similarity index 100% rename from webnotes/core/templates/pages/app.py rename to webnotes/templates/pages/app.py diff --git a/webnotes/website/doctype/blog_post/templates/pages/blog.html b/webnotes/templates/pages/blog.html similarity index 77% rename from webnotes/website/doctype/blog_post/templates/pages/blog.html rename to webnotes/templates/pages/blog.html index 6cfa1d9a75..ab654e3b9a 100644 --- a/webnotes/website/doctype/blog_post/templates/pages/blog.html +++ b/webnotes/templates/pages/blog.html @@ -2,13 +2,13 @@ {% block javascript %} {% endblock %} {% block css %} {% endblock %} @@ -33,5 +33,5 @@ style="display:none;">More... -{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} +{% include 'templates/includes/blog_footer.html' %} {% endblock %} \ No newline at end of file diff --git a/webnotes/website/doctype/blog_post/templates/pages/blog.py b/webnotes/templates/pages/blog.py similarity index 100% rename from webnotes/website/doctype/blog_post/templates/pages/blog.py rename to webnotes/templates/pages/blog.py diff --git a/webnotes/website/doctype/contact_us_settings/templates/pages/contact.html b/webnotes/templates/pages/contact.html similarity index 95% rename from webnotes/website/doctype/contact_us_settings/templates/pages/contact.html rename to webnotes/templates/pages/contact.html index 13c41e856c..b5e725f783 100644 --- a/webnotes/website/doctype/contact_us_settings/templates/pages/contact.html +++ b/webnotes/templates/pages/contact.html @@ -2,7 +2,7 @@ {% block javascript %} {% endblock %} diff --git a/webnotes/website/doctype/contact_us_settings/templates/pages/contact.py b/webnotes/templates/pages/contact.py similarity index 100% rename from webnotes/website/doctype/contact_us_settings/templates/pages/contact.py rename to webnotes/templates/pages/contact.py diff --git a/webnotes/website/templates/pages/error.html b/webnotes/templates/pages/error.html similarity index 100% rename from webnotes/website/templates/pages/error.html rename to webnotes/templates/pages/error.html diff --git a/webnotes/website/templates/pages/error.py b/webnotes/templates/pages/error.py similarity index 100% rename from webnotes/website/templates/pages/error.py rename to webnotes/templates/pages/error.py diff --git a/webnotes/website/templates/pages/login.html b/webnotes/templates/pages/login.html similarity index 97% rename from webnotes/website/templates/pages/login.html rename to webnotes/templates/pages/login.html index c9ebc3b25f..0aa957ab89 100644 --- a/webnotes/website/templates/pages/login.html +++ b/webnotes/templates/pages/login.html @@ -5,7 +5,7 @@ {% block javascript %} {% endblock %} diff --git a/webnotes/website/templates/pages/message.html b/webnotes/templates/pages/message.html similarity index 100% rename from webnotes/website/templates/pages/message.html rename to webnotes/templates/pages/message.html diff --git a/webnotes/website/templates/pages/message.py b/webnotes/templates/pages/message.py similarity index 100% rename from webnotes/website/templates/pages/message.py rename to webnotes/templates/pages/message.py diff --git a/webnotes/website/templates/pages/print.html b/webnotes/templates/pages/print.html similarity index 100% rename from webnotes/website/templates/pages/print.html rename to webnotes/templates/pages/print.html diff --git a/webnotes/website/templates/pages/print.py b/webnotes/templates/pages/print.py similarity index 100% rename from webnotes/website/templates/pages/print.py rename to webnotes/templates/pages/print.py diff --git a/webnotes/website/templates/pages/rss.py b/webnotes/templates/pages/rss.py similarity index 100% rename from webnotes/website/templates/pages/rss.py rename to webnotes/templates/pages/rss.py diff --git a/webnotes/website/templates/pages/rss.xml b/webnotes/templates/pages/rss.xml similarity index 100% rename from webnotes/website/templates/pages/rss.xml rename to webnotes/templates/pages/rss.xml diff --git a/webnotes/website/templates/pages/sitemap.py b/webnotes/templates/pages/sitemap.py similarity index 100% rename from webnotes/website/templates/pages/sitemap.py rename to webnotes/templates/pages/sitemap.py diff --git a/webnotes/website/templates/pages/sitemap.xml b/webnotes/templates/pages/sitemap.xml similarity index 100% rename from webnotes/website/templates/pages/sitemap.xml rename to webnotes/templates/pages/sitemap.xml diff --git a/webnotes/website/doctype/style_settings/templates/pages/wn-web.css b/webnotes/templates/pages/style_settings.css similarity index 100% rename from webnotes/website/doctype/style_settings/templates/pages/wn-web.css rename to webnotes/templates/pages/style_settings.css diff --git a/webnotes/website/doctype/style_settings/templates/pages/wn_web.py b/webnotes/templates/pages/style_settings.py similarity index 100% rename from webnotes/website/doctype/style_settings/templates/pages/wn_web.py rename to webnotes/templates/pages/style_settings.py diff --git a/webnotes/website/templates/pages/update-password.html b/webnotes/templates/pages/update-password.html similarity index 100% rename from webnotes/website/templates/pages/update-password.html rename to webnotes/templates/pages/update-password.html diff --git a/webnotes/website/templates/pages/update_password.py b/webnotes/templates/pages/update_password.py similarity index 100% rename from webnotes/website/templates/pages/update_password.py rename to webnotes/templates/pages/update_password.py diff --git a/webnotes/website/doctype/website_script/templates/pages/wn-web.js b/webnotes/templates/pages/website_script.js similarity index 100% rename from webnotes/website/doctype/website_script/templates/pages/wn-web.js rename to webnotes/templates/pages/website_script.js diff --git a/webnotes/website/doctype/website_script/templates/pages/wn_web.py b/webnotes/templates/pages/website_script.py similarity index 100% rename from webnotes/website/doctype/website_script/templates/pages/wn_web.py rename to webnotes/templates/pages/website_script.py diff --git a/webnotes/website/doctype/blogger/templates/pages/writers.html b/webnotes/templates/pages/writers.html similarity index 69% rename from webnotes/website/doctype/blogger/templates/pages/writers.html rename to webnotes/templates/pages/writers.html index 78107e851c..91cb3f3f99 100644 --- a/webnotes/website/doctype/blogger/templates/pages/writers.html +++ b/webnotes/templates/pages/writers.html @@ -10,9 +10,9 @@ {% endif %}
{% for blogger_info in bloggers %} - {% include "website/doctype/blog_post/templates/includes/blogger.html" %} + {% include "templates/includes/blogger.html" %} {% if not loop.last %}
{% endif %} {% endfor %} -{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} +{% include 'templates/includes/blog_footer.html' %} {% endblock %} \ No newline at end of file diff --git a/webnotes/website/doctype/blogger/templates/pages/writers.py b/webnotes/templates/pages/writers.py similarity index 100% rename from webnotes/website/doctype/blogger/templates/pages/writers.py rename to webnotes/templates/pages/writers.py diff --git a/webnotes/website/doctype/about_us_settings/templates/pages/__init__.py b/webnotes/website/doctype/about_us_settings/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blog_post/templates/__init__.py b/webnotes/website/doctype/blog_post/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blog_post/templates/generators/__init__.py b/webnotes/website/doctype/blog_post/templates/generators/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blog_post/templates/includes/__init__.py b/webnotes/website/doctype/blog_post/templates/includes/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blog_post/templates/pages/__init__.py b/webnotes/website/doctype/blog_post/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blogger/templates/__init__.py b/webnotes/website/doctype/blogger/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/blogger/templates/pages/__init__.py b/webnotes/website/doctype/blogger/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/contact_us_settings/templates/__init__.py b/webnotes/website/doctype/contact_us_settings/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/contact_us_settings/templates/pages/__init__.py b/webnotes/website/doctype/contact_us_settings/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/style_settings/templates/__init__.py b/webnotes/website/doctype/style_settings/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/style_settings/templates/pages/__init__.py b/webnotes/website/doctype/style_settings/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/web_page/templates/__init__.py b/webnotes/website/doctype/web_page/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/web_page/templates/generators/__init__.py b/webnotes/website/doctype/web_page/templates/generators/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/website_script/templates/__init__.py b/webnotes/website/doctype/website_script/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/website_script/templates/pages/__init__.py b/webnotes/website/doctype/website_script/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/doctype/website_sitemap_config/website_sitemap_config.py b/webnotes/website/doctype/website_sitemap_config/website_sitemap_config.py index c084913a4d..cc681d6239 100644 --- a/webnotes/website/doctype/website_sitemap_config/website_sitemap_config.py +++ b/webnotes/website/doctype/website_sitemap_config/website_sitemap_config.py @@ -39,21 +39,16 @@ def rebuild_website_sitemap_config(): def build_website_sitemap_config(app): config = {"pages": {}, "generators":{}} basepath = webnotes.get_pymodule_path(app) - for path, folders, files in os.walk(basepath, followlinks=True): - for dontwalk in ('locale', 'public', '.git', app+".egg-info"): - if dontwalk in folders: - folders.remove(dontwalk) - - if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates": - for fname in files: + + # pages + for config_type in ("pages", "generators"): + path = os.path.join(basepath, "templates", config_type) + if os.path.exists(path): + for fname in os.listdir(path): fname = webnotes.utils.cstr(fname) if fname.split(".")[-1] in ("html", "xml", "js", "css"): - name = add_website_sitemap_config("Page", app, path, fname, basepath) - - if os.path.basename(path)=="generators" and os.path.basename(os.path.dirname(path))=="templates": - for fname in files: - if fname.endswith(".html"): - name = add_website_sitemap_config("Generator", app, path, fname, basepath) + name = add_website_sitemap_config("Page" if config_type=="pages" else "Generator", + app, path, fname, basepath) webnotes.conn.commit() @@ -73,6 +68,7 @@ def add_website_sitemap_config(page_or_generator, app, path, fname, basepath): wsc.controller = app + "." + os.path.relpath(controller_path[:-3], basepath).replace(os.path.sep, ".") if wsc.controller: + # verbose print wsc.controller module = webnotes.get_module(wsc.controller) wsc.no_cache = getattr(module, "no_cache", 0) wsc.no_sitemap = wsc.no_cache or getattr(module, "no_sitemap", 0) diff --git a/webnotes/website/templates/includes/__init__.py b/webnotes/website/templates/includes/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/webnotes/website/templates/pages/__init__.py b/webnotes/website/templates/pages/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/webnotes/website/templates/pages/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/webnotes/webutils.py b/webnotes/webutils.py index 830bf403e7..522f174b0a 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -105,7 +105,7 @@ def build_page(page_name): context.update(get_website_settings()) jenv = webnotes.get_jenv() - context["base_template"] = jenv.get_template("portal/templates/base.html") + context["base_template"] = jenv.get_template("templates/base.html") template_name = page_options['template_path'] context["_"] = webnotes._