From 308913fd03c64ffd7df9d40d0859d1455cd5de86 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 1 Jan 2016 11:12:41 +0530 Subject: [PATCH 1/2] [website] load js after html --- frappe/templates/autodoc/base_template.html | 12 +++++------ frappe/templates/base.html | 24 +++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/frappe/templates/autodoc/base_template.html b/frappe/templates/autodoc/base_template.html index 362e4fe460..f5bdbd5a3b 100644 --- a/frappe/templates/autodoc/base_template.html +++ b/frappe/templates/autodoc/base_template.html @@ -12,11 +12,6 @@ - - - - - {% block favicon %}
  • - + Frappe Apps
  • @@ -120,6 +115,11 @@ + + + + + {%- block script %} - {% block favicon %} {%- endblock -%} {%- endblock -%} - {%- if js_globals is defined %} - - {% endif -%}
    @@ -97,6 +86,19 @@
    + + + + {%- if js_globals is defined %} + + {% endif -%} + {%- for link in web_include_js %} {%- endfor -%} From eac452a926ab73007b92d0dc9672bfc72edb446a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 1 Jan 2016 17:17:27 +0530 Subject: [PATCH 2/2] [cleanup] web templates, now using standard jinja architecture and removed push-state --- .../api/website/frappe.website.render.html | 32 --- .../api/website/frappe.website.template.html | 16 -- frappe/docs/current/models/core/user.html | 2 + .../docs/current/models/website/web_page.html | 57 +++++ frappe/hooks.py | 6 - frappe/public/build.json | 4 - frappe/public/css/nprogress.css | 85 ------- frappe/public/js/lib/nprogress.js | 220 ------------------ frappe/templates/autodoc/base_template.html | 33 +-- frappe/templates/base.html | 47 ++-- .../templates/generators/blog_category.html | 4 +- frappe/templates/generators/blog_post.html | 16 +- frappe/templates/generators/web_form.html | 4 +- frappe/templates/generators/web_page.html | 26 ++- frappe/templates/includes/blog/blog.html | 10 +- .../templates/includes/list/row_template.html | 2 +- frappe/templates/includes/login/login.js | 8 +- frappe/templates/includes/navbar/navbar.html | 1 - .../includes/navbar/navbar_items.html | 7 - frappe/templates/includes/page_content.html | 30 --- frappe/templates/includes/sidebar.html | 23 -- frappe/templates/pages/404.html | 4 +- frappe/templates/pages/about.html | 4 +- frappe/templates/pages/complete_signup.html | 10 +- frappe/templates/pages/contact.html | 4 +- frappe/templates/pages/error.html | 4 +- frappe/templates/pages/list.html | 8 +- frappe/templates/pages/login.html | 14 +- frappe/templates/pages/me.html | 4 +- frappe/templates/pages/message.html | 4 +- frappe/templates/pages/update-password.html | 6 +- frappe/templates/web.html | 31 +++ frappe/utils/jinja.py | 1 + frappe/utils/setup_docs.py | 3 +- frappe/website/context.py | 38 +-- frappe/website/doctype/web_page/web_page.py | 95 +++++++- frappe/website/js/website.js | 179 +------------- frappe/website/render.py | 38 +-- frappe/website/template.py | 163 ------------- frappe/website/utils.py | 2 +- 40 files changed, 327 insertions(+), 918 deletions(-) delete mode 100644 frappe/public/css/nprogress.css delete mode 100644 frappe/public/js/lib/nprogress.js delete mode 100644 frappe/templates/includes/page_content.html delete mode 100644 frappe/templates/includes/sidebar.html create mode 100644 frappe/templates/web.html delete mode 100644 frappe/website/template.py diff --git a/frappe/docs/current/api/website/frappe.website.render.html b/frappe/docs/current/api/website/frappe.website.render.html index 0b45cee97b..acb3b6e9e3 100644 --- a/frappe/docs/current/api/website/frappe.website.render.html +++ b/frappe/docs/current/api/website/frappe.website.render.html @@ -64,22 +64,6 @@ -

    - - - frappe.website.render.build_json - (path) -

    -

    No docs

    -
    -
    - - - - - - -

    @@ -144,22 +128,6 @@ -

    - - - frappe.website.render.is_ajax - () -

    -

    No docs

    -
    -
    - - - - - - -

    diff --git a/frappe/docs/current/api/website/frappe.website.template.html b/frappe/docs/current/api/website/frappe.website.template.html index 6c55adf387..b154b8fc03 100644 --- a/frappe/docs/current/api/website/frappe.website.template.html +++ b/frappe/docs/current/api/website/frappe.website.template.html @@ -114,22 +114,6 @@ Hero elements get full page width.

    -

    - - - frappe.website.template.set_sidebar - (out, context) -

    -

    Include sidebar (deprecated)

    -
    -
    - - - - - - -

    diff --git a/frappe/docs/current/models/core/user.html b/frappe/docs/current/models/core/user.html index f51f81074d..52f57c0ca4 100644 --- a/frappe/docs/current/models/core/user.html +++ b/frappe/docs/current/models/core/user.html @@ -1595,6 +1595,8 @@ The mentions will be separated by non-word characters or may appear at the start + + diff --git a/frappe/docs/current/models/website/web_page.html b/frappe/docs/current/models/website/web_page.html index d7acc0e721..215b7e2a14 100644 --- a/frappe/docs/current/models/website/web_page.html +++ b/frappe/docs/current/models/website/web_page.html @@ -423,6 +423,35 @@ Right +

    + + + add_hero + (self, context) +

    +

    Add a hero element if specified in content or hooks. +Hero elements get full page width.

    +
    +
    + + + + + +

    + + + add_index + (self, context) +

    +

    Add index, next button if {index}, {next} is present.

    +
    +
    + + + + +

    @@ -507,6 +536,20 @@ Right +

    + + + set_breadcrumbs + (self, context) +

    +

    Build breadcrumbs template (deprecated)

    +
    +
    + + + + +

    @@ -521,6 +564,20 @@ Right +

    + + + set_title_and_header + (self, context) +

    +

    Extract and set title and header from content or context.

    +
    +
    + + + + +

    diff --git a/frappe/hooks.py b/frappe/hooks.py index 76d975d919..84000d96e6 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -45,12 +45,6 @@ website_route_rules = [ {"from_route": "/blog/", "to_route": "Blog Post"} ] -website_context = { - "hero": { - "blog": "templates/includes/blog/hero.html" - } -} - write_file_keys = ["file_url", "file_name"] notification_config = "frappe.core.notifications.get_notification_config" diff --git a/frappe/public/build.json b/frappe/public/build.json index 9f6241b56b..f7507eba50 100644 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -2,14 +2,12 @@ "css/frappe-web.css": [ "public/css/font-awesome.css", "public/css/octicons/octicons.css", - "public/css/nprogress.css", "public/css/website.css" ], "js/frappe-web.min.js": [ "public/js/lib/bootstrap.min.js", "public/js/frappe/provide.js", "public/js/frappe/misc/number_format.js", - "public/js/lib/nprogress.js", "public/js/frappe/translate.js", "public/js/frappe/misc/pretty_date.js", "public/js/lib/moment/moment.min.js", @@ -38,7 +36,6 @@ "public/css/sidebar.css", "public/css/page.css", "public/css/tree.css", - "public/css/nprogress.css", "public/css/desktop.css", "public/css/form.css", "public/css/mobile.css" @@ -49,7 +46,6 @@ "public/js/lib/tag-it.min.js", "public/js/lib/notify.js", "public/js/lib/bootstrap.min.js", - "public/js/lib/nprogress.js", "public/js/lib/moment/moment-with-locales.min.js", "public/js/lib/moment/moment-timezone-with-data.min.js", "public/js/lib/socket.io.min.js", diff --git a/frappe/public/css/nprogress.css b/frappe/public/css/nprogress.css deleted file mode 100644 index 1eaeae9210..0000000000 --- a/frappe/public/css/nprogress.css +++ /dev/null @@ -1,85 +0,0 @@ -/* Make clicks pass-through */ -#nprogress { - pointer-events: none; - -webkit-pointer-events: none; -} - -/* Make the entire page show a busy cursor */ -.nprogress-busy body { - cursor: wait; -} - -#nprogress .bar { - background: #36414C; - - position: fixed; - z-index: 1050; - top: 0; - left: 0; - - width: 100%; - height: 2px; -} - -/* Fancy blur effect */ -#nprogress .peg { - display: block; - position: absolute; - right: 0px; - width: 100px; - height: 100%; - /*box-shadow: 0 0 10px #2ecc71, 0 0 5px #2ecc71;*/ - opacity: 1.0; - - -webkit-transform: rotate(3deg) translate(0px, -4px); - -moz-transform: rotate(3deg) translate(0px, -4px); - -ms-transform: rotate(3deg) translate(0px, -4px); - -o-transform: rotate(3deg) translate(0px, -4px); - transform: rotate(3deg) translate(0px, -4px); -} - -/* Remove these to get rid of the spinner -#nprogress .spinner { - display: block; - position: fixed; - z-index: 1050; - top: 7px; - right: 15px; -} - -#nprogress .spinner-icon { - width: 14px; - height: 14px; - - border: solid 2px transparent; - border-top-color: #fff; - border-left-color: #fff; - border-radius: 10px; - - -webkit-animation: nprogress-spinner 400ms linear infinite; - -moz-animation: nprogress-spinner 400ms linear infinite; - -ms-animation: nprogress-spinner 400ms linear infinite; - -o-animation: nprogress-spinner 400ms linear infinite; - animation: nprogress-spinner 400ms linear infinite; -} - -@-webkit-keyframes nprogress-spinner { - 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } - 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } -} -@-moz-keyframes nprogress-spinner { - 0% { -moz-transform: rotate(0deg); transform: rotate(0deg); } - 100% { -moz-transform: rotate(360deg); transform: rotate(360deg); } -} -@-o-keyframes nprogress-spinner { - 0% { -o-transform: rotate(0deg); transform: rotate(0deg); } - 100% { -o-transform: rotate(360deg); transform: rotate(360deg); } -} -@-ms-keyframes nprogress-spinner { - 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); } - 100% { -ms-transform: rotate(360deg); transform: rotate(360deg); } -} -@keyframes nprogress-spinner { - 0% { transform: rotate(0deg); transform: rotate(0deg); } - 100% { transform: rotate(360deg); transform: rotate(360deg); } -}*/ diff --git a/frappe/public/js/lib/nprogress.js b/frappe/public/js/lib/nprogress.js deleted file mode 100644 index 1a05eaf57b..0000000000 --- a/frappe/public/js/lib/nprogress.js +++ /dev/null @@ -1,220 +0,0 @@ -/*! NProgress (c) 2013, Rico Sta. Cruz - * http://ricostacruz.com/nprogress */ - -;(function(factory) { - - if (typeof module === 'object') { - module.exports = factory(this.jQuery || require('dom')); - } else { - this.NProgress = factory(this.jQuery); - } - -})(function($) { - var NProgress = {}; - - NProgress.version = '0.1.0'; - - var Settings = NProgress.settings = { - minimum: 0.08, - easing: 'ease', - speed: 200, - trickle: true, - trickleRate: 0.02, - trickleSpeed: 800, - template: '

    ' - }; - - /** - * Updates configuration. - * - * NProgress.configure({ - * minimum: 0.1 - * }); - */ - NProgress.configure = function(options) { - $.extend(Settings, options); - return this; - }; - - /** - * Last number. - */ - - NProgress.status = null; - - /** - * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`. - * - * NProgress.set(0.4); - * NProgress.set(1.0); - */ - - NProgress.set = function(n) { - var started = NProgress.isStarted(); - - n = clamp(n, Settings.minimum, 1); - NProgress.status = (n === 1 ? null : n); - - var $progress = NProgress.render(!started), - $bar = $progress.find('[role="bar"]'), - speed = Settings.speed, - ease = Settings.easing; - - $progress[0].offsetWidth; /* Repaint */ - - $progress.queue(function(next) { - $bar.css({ - transition: 'all '+speed+'ms '+ease, - transform: 'translate3d('+toBarPerc(n)+'%,0,0)' - }); - - if (n === 1) { - // Fade out - $progress.css({ transition: 'none', opacity: 1 }); - $progress[0].offsetWidth; /* Repaint */ - - setTimeout(function() { - $progress.css({ transition: 'all '+speed+'ms linear', opacity: 0 }); - setTimeout(function() { - NProgress.remove(); - next(); - }, speed); - }, speed); - } else { - setTimeout(next, speed); - } - }); - - return this; - }; - - NProgress.isStarted = function() { - return typeof NProgress.status === 'number'; - }; - - /** - * Shows the progress bar. - * This is the same as setting the status to 0%, except that it doesn't go backwards. - * - * NProgress.start(); - * - */ - NProgress.start = function() { - if (!NProgress.status) NProgress.set(0); - - var work = function() { - setTimeout(function() { - if (!NProgress.status) return; - NProgress.trickle(); - work(); - }, Settings.trickleSpeed); - }; - - if (Settings.trickle) work(); - - return this; - }; - - /** - * Hides the progress bar. - * This is the *sort of* the same as setting the status to 100%, with the - * difference being `done()` makes some placebo effect of some realistic motion. - * - * NProgress.done(); - * - * If `true` is passed, it will show the progress bar even if its hidden. - * - * NProgress.done(true); - */ - - NProgress.done = function(force) { - if (!force && !NProgress.status) return this; - - return NProgress.inc(0.3 + 0.5 * Math.random()).set(1); - }; - - /** - * Increments by a random amount. - */ - - NProgress.inc = function(amount) { - var n = NProgress.status; - - if (!n) { - return NProgress.start(); - } else { - if (typeof amount !== 'number') { - amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95); - } - - n = clamp(n + amount, 0, 0.994); - return NProgress.set(n); - } - }; - - NProgress.trickle = function() { - return NProgress.inc(Math.random() * Settings.trickleRate); - }; - - /** - * (Internal) renders the progress bar markup based on the `template` - * setting. - */ - - NProgress.render = function(fromStart) { - if (NProgress.isRendered()) return $("#nprogress"); - $('html').addClass('nprogress-busy'); - - var $el = $("
    ") - .html(Settings.template); - - var perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0); - - $el.find('[role="bar"]').css({ - transition: 'all 0 linear', - transform: 'translate3d('+perc+'%,0,0)' - }); - - $el.appendTo(document.body); - - return $el; - }; - - /** - * (Internal) Removes the element. Opposite of render(). - */ - - NProgress.remove = function() { - $('html').removeClass('nprogress-busy'); - $('#nprogress').remove(); - }; - - /** - * Checks if the progress bar is rendered. - */ - - NProgress.isRendered = function() { - return ($("#nprogress").length > 0); - }; - - /** - * Helpers - */ - - function clamp(n, min, max) { - if (n < min) return min; - if (n > max) return max; - return n; - } - - /** - * (Internal) converts a percentage (`0..1`) to a bar translateX - * percentage (`-100%..0%`). - */ - - function toBarPerc(n) { - return (-1 + n) * 100; - } - - return NProgress; -}); diff --git a/frappe/templates/autodoc/base_template.html b/frappe/templates/autodoc/base_template.html index f5bdbd5a3b..0c38dae4ee 100644 --- a/frappe/templates/autodoc/base_template.html +++ b/frappe/templates/autodoc/base_template.html @@ -4,7 +4,7 @@ - {{ title }} + {% block title %} {{ title }} {% endblock %} @@ -32,11 +32,7 @@ {%- block head_include %}{{ head_include or "" }}{% endblock -%} - {%- block style %} - - {%- endblock -%} + {%- block style %}{%- endblock -%} {%- endblock -%} @@ -55,17 +51,12 @@ {% include "templates/includes/navbar/navbar.html" %} {%- endblock -%}
    - {%- block hero -%} -
    - {{ hero or "" }} -
    - {%- endblock -%} - {% block content %} -
    - {{ content }} - -
    - {% endblock %} +
    + {%- block hero -%}{%- endblock -%} +
    +
    + {% block content %}{% endblock %} +