common hero and page_titles system

This commit is contained in:
Anand Doshi 2015-03-12 19:44:09 +05:30
parent 9f7791bca5
commit 03ed55fc53
13 changed files with 56 additions and 38 deletions

View file

@ -43,6 +43,12 @@ website_route_rules = [
{"from_route": "/blog/<category>", "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"

View file

@ -69,7 +69,7 @@ a.text-muted:focus,
a.text-extra-muted:hover,
a.text-extra-muted:focus {
color: inherit !important;
border-bottom: 1px solid #8d99a6;
text-decoration: underline;
}
/* the element that this class is applied to, should have a max width for this to work*/
.text-ellipsis,

View file

@ -69,7 +69,7 @@ a.text-muted:focus,
a.text-extra-muted:hover,
a.text-extra-muted:focus {
color: inherit !important;
border-bottom: 1px solid #8d99a6;
text-decoration: underline;
}
/* the element that this class is applied to, should have a max width for this to work*/
.text-ellipsis,

View file

@ -69,7 +69,7 @@ a.text-muted:focus,
a.text-extra-muted:hover,
a.text-extra-muted:focus {
color: inherit !important;
border-bottom: 1px solid #8d99a6;
text-decoration: underline;
}
/* the element that this class is applied to, should have a max width for this to work*/
.text-ellipsis,
@ -517,17 +517,17 @@ fieldset {
border-top: 1px solid #d1d8dd;
}
.web-list-item:last-child {
margin-bottom: -1px;
border-bottom: none;
}
.blog-footer {
padding: 5px 15px;
border-top: 1px solid #d1d8dd;
margin: 0px -15px -20px -15px;
}
.blog-text {
.longform {
padding: 15px 0px;
}
.blog-text p {
.longform p {
margin-bottom: 30px;
}
.blog-category {
@ -538,7 +538,8 @@ fieldset {
border-top: 1px solid #d1d8dd;
margin: 0px -15px;
}
.blog-comments {
.blog-comments,
.help-article-comments {
margin: 0px -15px;
border-top: 1px solid #d1d8dd;
padding: 5px 15px 15px;

View file

@ -65,7 +65,7 @@ a.text-muted:focus,
a.text-extra-muted:hover,
a.text-extra-muted:focus {
color: inherit !important;
border-bottom: 1px solid @text-muted;
text-decoration: underline;
}
/* the element that this class is applied to, should have a max width for this to work*/

View file

@ -219,7 +219,7 @@ fieldset {
}
.web-list-item:last-child {
margin-bottom: -1px;
border-bottom: none;
}
.blog-footer {
@ -228,7 +228,7 @@ fieldset {
margin: 0px -15px -20px -15px;
}
.blog-text {
.longform {
padding: 15px 0px;
p {
@ -246,7 +246,8 @@ fieldset {
margin: 0px -15px;
}
.blog-comments {
.blog-comments,
.help-article-comments {
margin: 0px -15px;
border-top: 1px solid @border-color;
padding: 5px 15px 15px;

View file

@ -11,7 +11,7 @@
<span itemprop="author">{{ blogger_info and blogger_info.full_name or full_name }}</span>,
<span itemprop="dateCreated">{{ updated }}</span>
</p>
<div itemprop="articleBody" class="blog-text">
<div itemprop="articleBody" class="longform blog-text">
{{ content }}
</div>
<p class="text-muted blog-category">

View file

@ -3,27 +3,12 @@
{% block content %}
<!-- no-header -->
<!-- no-breadcrumbs -->
{% if blog_title and pathname == 'blog' and not frappe.local.form_dict.by %}
<!-- start-hero -->
<div class="page-hero border-bottom">
<div class="container">
<h1 class="page-title">
{{ blog_title }}
</h1>
{% if blog_introduction -%}
<p class="blog-introduction">{{ blog_introduction }}</p>
{%- endif %}
</div>
</div>
<!-- end-hero -->
{% elif blog_subtitle %}
<!-- start-hero -->
<div class="container list-hero">
{% if blog_subtitle %}
<div class="list-hero">
<h1>
{{ blog_subtitle }}
</h1>
</div>
<!-- end-hero -->
{% endif %}
<div class="blog-list-content">
<div id="blog-list">

View file

@ -0,0 +1,12 @@
{% if blog_title and not (frappe.local.form_dict.txt or frappe.local.form_dict.by) %}
<div class="page-hero border-bottom">
<div class="container">
<h1 class="page-title">
{{ blog_title }}
</h1>
{% if blog_introduction -%}
<p class="blog-introduction">{{ blog_introduction }}</p>
{%- endif %}
</div>
</div>
{% endif %}

View file

@ -37,28 +37,35 @@ def get(doctype, txt=None, limit_start=0, **kwargs):
# resolve additional filters from path
resolve_path(filters.pathname)
for key, val in frappe.local.form_dict.items():
if not (key in ("doctype", "txt", "limit_start") and key in filters):
if key in ("cmd", "pathname", "doctype", "txt", "limit_start"):
if key in filters:
del filters[key]
elif key not in filters:
filters[key] = val
controller = get_controller(doctype)
meta = frappe.get_meta(doctype)
list_context = frappe._dict(hasattr(controller, "get_list_context") and controller.get_list_context() or {})
if list_context.filters:
filters.update(list_context.filters)
_get_list = list_context.get_list or get_list
raw_result = _get_list(doctype=doctype, txt=txt, filters=filters,
limit_start=limit_start, limit_page_length=limit_page_length)
show_more = (_get_list(doctype=doctype, txt=txt, filters=filters,
limit_start=next_start, limit_page_length=1)
and True or False)
limit_start=next_start, limit_page_length=1) and True or False)
result = []
row_template = list_context.row_template or "templates/includes/list/row_template.html"
for item in raw_result:
item.doctype = doctype
item.update(list_context)
result.append(frappe.render_template(row_template,
{ "doc": item, "meta": meta, "pathname": frappe.local.request.path.strip("/ ") },
is_path=True))
new_context = { "doc": item, "meta": meta, "pathname": frappe.local.request.path.strip("/ ") }
new_context.update(list_context)
result.append(frappe.render_template(row_template, new_context, is_path=True))
return {
"result": result,

View file

@ -3,7 +3,7 @@
{% block content %}
<!-- no-header -->
<!-- no-sidebar -->
<div class="login-content container" style="max-width: 800px; padding-top: 30px; padding-bottom:15px">
<div class="login-content" style="max-width: 800px; padding-top: 30px; padding-bottom:15px">
<form class="form-signin form-login" role="form">
{%- if social_login -%}
<h4 class="form-signin-heading text-center">{{ _("Sign in using") }}</h4>

View file

@ -125,7 +125,7 @@ def get_website_settings():
via_hooks = frappe.get_hooks("website_context")
for key in via_hooks:
context[key] = via_hooks[key]
if key not in ("top_bar_items", "footer_items", "post_login"):
if isinstance(context[key], list) and key not in ("top_bar_items", "footer_items", "post_login"):
context[key] = context[key][0]
return context

View file

@ -49,6 +49,9 @@ def render_blocks(context):
if "title" not in out:
out["title"] = context.get("title")
if context.get("page_titles") and context.page_titles.get(context.pathname):
out["title"] = context.page_titles.get(context.pathname)[0]
# header
if out["no_header"]:
out["header"] = ""
@ -110,4 +113,7 @@ def render_blocks(context):
out["content"] = parts1[0] + parts2[1]
out["hero"] = parts2[0]
elif context.hero and context.hero.get(context.pathname):
out["hero"] = frappe.render_template(context.hero[context.pathname][0], context)
return out