title, header, sidebar and breadcrumbs are default blocks, show nprogress bar when loading via pushstate and ajax
This commit is contained in:
parent
61e648c49b
commit
17652dd1f7
17 changed files with 66 additions and 58 deletions
|
|
@ -1,5 +1,5 @@
|
|||
wn.make_editable = function(editor, doctype, name, fieldname) {
|
||||
wn.require("assets/js/editor.min.js");
|
||||
wn.require("/assets/js/editor.min.js");
|
||||
|
||||
WebPageEditor = bsEditor.extend({
|
||||
onhide: function(action) {
|
||||
|
|
@ -15,7 +15,12 @@ wn.make_editable = function(editor, doctype, name, fieldname) {
|
|||
this._super(bool);
|
||||
|
||||
if(!bool) {
|
||||
var $edit_btn = $(repl('<li><a href="#"><i class="icon-fixed-width icon-pencil"></i> Edit %(doctype)s</a></li>\
|
||||
// remove existing web page editor toggles
|
||||
$('li.editable-toggle + li').remove();
|
||||
$('li.editable-toggle').remove();
|
||||
|
||||
var $edit_btn = $(repl('<li class="editable-toggle">\
|
||||
<a href="#"><i class="icon-fixed-width icon-pencil"></i>Edit %(doctype)s</a></li>\
|
||||
<li class="divider"></li>', {doctype: doctype}))
|
||||
.prependTo($("#website-post-login ul.dropdown-menu"));
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<header class="page-header">
|
||||
<div class="container" data-html-block="header">
|
||||
{%- if header is defined -%}{{ header }}{% elif title is defined %}<h2>{{ title }}</h2>{%- endif -%}
|
||||
{%- if header is defined -%}{{ header }}{%- endif -%}
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
{% block title %} {{ title }} {% endblock %}
|
||||
|
||||
{% block header %}
|
||||
<h2 itemprop="name headline" itemscope itemtype="http://schema.org/BlogPost">
|
||||
{{ title }}
|
||||
|
|
@ -38,5 +36,3 @@ $(function() {
|
|||
{% endblock %}
|
||||
|
||||
{% block footer %}{% include 'templates/includes/blog_footer.html' %}{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
||||
|
|
@ -1,9 +1,3 @@
|
|||
{% block title %} {{ title }} {% endblock %}
|
||||
|
||||
{% block header %}<h2>{{ title }}</h2>{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="webpage-content">
|
||||
{# title, breadcrumbs, table of contents #}
|
||||
|
|
@ -48,17 +42,15 @@
|
|||
<script>
|
||||
$(function() {
|
||||
if(window.logged_in && getCookie("system_user")==="yes") {
|
||||
wn.has_permission("Web Page", "{{ name }}", "write", function(r) {
|
||||
wn.has_permission("Web Page", "{{ docname }}", "write", function(r) {
|
||||
wn.require("assets/webnotes/js/wn/website/editable.js");
|
||||
wn.make_editable($(".web-page-content"), "Web Page", "{{ name }}", "main_section");
|
||||
wn.make_editable($(".web-page-content"), "Web Page", "{{ docname }}", "main_section");
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
||||
|
||||
{% block style %}{{ style }}{% endblock %}
|
||||
|
||||
{% block script %}{{ script }}{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
{% block title %}{{ title }}{% endblock %}
|
||||
{% block header %}<h2>{{ group.group_title }}</h2>{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
<h2>{{ group.group_title }}</h2>
|
||||
{% block content %}
|
||||
{%- if group.group_description -%}
|
||||
<p class="lead">{{ group.group_description }}</p>
|
||||
{%- endif -%}
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<ul class="nav nav-tabs view-selector">
|
||||
{%- for t in views -%}
|
||||
{% set url = (pathname if t.default else "{}?view={}".format(pathname, t.name)) %}
|
||||
|
|
@ -39,5 +34,3 @@
|
|||
<script>$(function() { website.toggle_upvote(); });</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<ul class="breadcrumb">
|
||||
{% for parent in parents or [] %}
|
||||
<li><a href="/{{ parent.name|lower }}">{{ parent.page_title or parent.title }}</a></li>
|
||||
<li><a href="{{ parent.name }}">{{ parent.page_title or parent.title or "" }}</a></li>
|
||||
{% endfor %}
|
||||
<li class="active">{{ title }}</li>
|
||||
<li class="active">{{ title or "" }}</li>
|
||||
</ul>
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
{% block title %}{{ blog_title or "Blog" }}{% endblock %}
|
||||
|
||||
{% block header %}<h2>{{ blog_title or "Blog" }}</h2>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="blog-list-content">
|
||||
{% if blog_introduction %}
|
||||
|
|
@ -26,5 +24,3 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block footer %}{% include 'templates/includes/blog_footer.html' %}{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
{% block title %} Login {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="login-content container" style="max-width: 800px;">
|
||||
<div class="row" style="margin-top: 70px; margin-bottom: 20px">
|
||||
|
|
@ -48,4 +46,6 @@
|
|||
<script>
|
||||
{% include "templates/includes/login.js" %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}{% endblock %}
|
||||
|
|
@ -7,4 +7,4 @@ import webnotes
|
|||
def get_context(context):
|
||||
# get settings from site config
|
||||
if webnotes.conf.get("fb_app_id"):
|
||||
return { "fb_app_id": webnotes.conf.fb_app_id }
|
||||
return { "fb_app_id": webnotes.conf.fb_app_id, "title": "Login" }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
{% if javascript -%}{{ javascript }}{%- endif %}
|
||||
|
||||
{% if google_analytics_id -%}
|
||||
// Google Analytics template
|
||||
window._gaq = window._gaq || [];
|
||||
window._gaq.push(['_setAccount', '{{ google_analytics_id }}']);
|
||||
window._gaq.push(['_trackPageview']);
|
||||
<!-- Google Analytics -->
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
ga('create', '{{ google_analytics_id }}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
<!-- End Google Analytics -->
|
||||
{%- endif %}
|
||||
|
|
@ -8,7 +8,10 @@ no_sitemap = 1
|
|||
base_template_path = "templates/pages/website_script.js"
|
||||
|
||||
def get_context(context):
|
||||
return {
|
||||
"javascript": webnotes.conn.get_value('Website Script', None, 'javascript'),
|
||||
"google_analytics_id": webnotes.conn.get_value("Website Settings", "Website Settings", "google_analytics_id")
|
||||
}
|
||||
script_context = { "javascript": webnotes.conn.get_value('Website Script', None, 'javascript') }
|
||||
|
||||
if not webnotes.conf.developer_mode:
|
||||
script_context["google_analytics_id"] = webnotes.conn.get_value("Website Settings", "Website Settings",
|
||||
"google_analytics_id")
|
||||
|
||||
return script_context
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
{% block title %} Blog Writers {% endblock %}
|
||||
|
||||
{% block header %}<h2>Blog Writers</h2>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="writers-content">
|
||||
{% if writers_introduction %}
|
||||
|
|
@ -15,5 +13,3 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block footer %}{% include "templates/includes/blog_footer.html" %}{% endblock %}
|
||||
|
||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<div class="small text-muted post-list-help"></div>
|
||||
<div class="post-list">
|
||||
{{ post_list_html }}
|
||||
{{ post_list_html }}
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-default btn-more hide">More</button>
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ a.no-decoration {
|
|||
a.active {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
color: initial;
|
||||
border-bottom: inherit;
|
||||
}
|
||||
|
||||
.page-breadcrumbs .breadcrumb {
|
||||
|
|
|
|||
|
|
@ -248,11 +248,14 @@ $.extend(wn, {
|
|||
window.previous_href = href;
|
||||
history.pushState(null, null, href);
|
||||
|
||||
NProgress.start();
|
||||
$.ajax({ url: href, cache: false }).done(function(data) {
|
||||
history.replaceState(data, data.title, href);
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
wn.render_json(data);
|
||||
})
|
||||
}).always(function() {
|
||||
NProgress.done();
|
||||
});
|
||||
},
|
||||
render_json: function(data) {
|
||||
if(data.reload) {
|
||||
|
|
@ -263,6 +266,7 @@ $.extend(wn, {
|
|||
$section.html(data[$section.attr("data-html-block")] || "");
|
||||
});
|
||||
if(data.title) $("title").html(data.title);
|
||||
window.ga && ga('send', 'pageview', location.pathname);
|
||||
$(document).trigger("page_change");
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,9 +9,18 @@ $.extend(website, {
|
|||
$('li[data-view="add"]').toggleClass("hide", !website.access.write);
|
||||
$('li[data-view="settings"]').toggleClass("hide", !website.access.admin);
|
||||
$('li[data-view="edit"]').toggleClass("hide", website.view!=="edit");
|
||||
|
||||
|
||||
// show message
|
||||
$(".post-list-help").html(!website.access.write ? "You do not have permission to post" : "");
|
||||
if(!website.access.write) {
|
||||
var sid = wn.get_cookie("sid");
|
||||
if(!sid || sid==="Guest") {
|
||||
$(".post-list-help").html("Please login to post");
|
||||
} else {
|
||||
$(".post-list-help").html("You do not have permission to post");
|
||||
}
|
||||
} else {
|
||||
$(".post-list-help").html("");
|
||||
}
|
||||
}
|
||||
},
|
||||
setup_pagination: function() {
|
||||
|
|
|
|||
|
|
@ -460,6 +460,21 @@ def render_blocks(context):
|
|||
# render each block individually
|
||||
for block, render in template.blocks.items():
|
||||
out[block] = scrub_relative_urls(concat(render(context)))
|
||||
|
||||
# default blocks if not found
|
||||
if "title" not in out:
|
||||
out["title"] = context.get("title")
|
||||
|
||||
if "header" not in out:
|
||||
out["header"] = """<h2>{}</h2>""".format(out.get("title") or context.title)
|
||||
|
||||
if "breadcrumbs" not in out:
|
||||
out["breadcrumbs"] = scrub_relative_urls(
|
||||
webnotes.get_template("templates/includes/breadcrumbs.html").render(context))
|
||||
|
||||
if "sidebar" not in out:
|
||||
out["sidebar"] = scrub_relative_urls(
|
||||
webnotes.get_template("templates/includes/sidebar.html").render(context))
|
||||
|
||||
return out
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue