From 03ed55fc53e1ef9bc16378045f4e3dec215b9098 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Mar 2015 19:44:09 +0530 Subject: [PATCH] common hero and page_titles system --- frappe/hooks.py | 6 ++++++ frappe/public/css/common.css | 2 +- frappe/public/css/desk.css | 2 +- frappe/public/css/website.css | 11 +++++----- frappe/public/less/common.less | 2 +- frappe/public/less/website.less | 7 ++++--- frappe/templates/generators/blog_post.html | 2 +- frappe/templates/includes/blog/blog.html | 19 ++--------------- frappe/templates/includes/blog/hero.html | 12 +++++++++++ frappe/templates/pages/list.py | 21 ++++++++++++------- frappe/templates/pages/login.html | 2 +- .../website_settings/website_settings.py | 2 +- frappe/website/template.py | 6 ++++++ 13 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 frappe/templates/includes/blog/hero.html diff --git a/frappe/hooks.py b/frappe/hooks.py index 6ac17885ea..1e5b58ffaa 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -43,6 +43,12 @@ 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/css/common.css b/frappe/public/css/common.css index 3a71ec83c1..6946d8fc97 100644 --- a/frappe/public/css/common.css +++ b/frappe/public/css/common.css @@ -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, diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css index bde4e82f8f..72fa92ec46 100644 --- a/frappe/public/css/desk.css +++ b/frappe/public/css/desk.css @@ -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, diff --git a/frappe/public/css/website.css b/frappe/public/css/website.css index fc4835f7eb..57f23502e5 100644 --- a/frappe/public/css/website.css +++ b/frappe/public/css/website.css @@ -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; diff --git a/frappe/public/less/common.less b/frappe/public/less/common.less index 7e5be68561..6043a7bf28 100644 --- a/frappe/public/less/common.less +++ b/frappe/public/less/common.less @@ -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*/ diff --git a/frappe/public/less/website.less b/frappe/public/less/website.less index 7a1db18f2d..2c621cc1d8 100644 --- a/frappe/public/less/website.less +++ b/frappe/public/less/website.less @@ -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; diff --git a/frappe/templates/generators/blog_post.html b/frappe/templates/generators/blog_post.html index 4a7eef8b1c..322d0be7ce 100644 --- a/frappe/templates/generators/blog_post.html +++ b/frappe/templates/generators/blog_post.html @@ -11,7 +11,7 @@ , {{ updated }}

-
+
{{ content }}

diff --git a/frappe/templates/includes/blog/blog.html b/frappe/templates/includes/blog/blog.html index 10c2fd26f1..60c17ccdf9 100644 --- a/frappe/templates/includes/blog/blog.html +++ b/frappe/templates/includes/blog/blog.html @@ -3,27 +3,12 @@ {% block content %} -{% if blog_title and pathname == 'blog' and not frappe.local.form_dict.by %} - -

-
-

- {{ blog_title }} -

- {% if blog_introduction -%} -

{{ blog_introduction }}

- {%- endif %} -
-
- -{% elif blog_subtitle %} - -
+{% if blog_subtitle %} +

{{ blog_subtitle }}

- {% endif %}
diff --git a/frappe/templates/includes/blog/hero.html b/frappe/templates/includes/blog/hero.html new file mode 100644 index 0000000000..8ec47f3ac0 --- /dev/null +++ b/frappe/templates/includes/blog/hero.html @@ -0,0 +1,12 @@ +{% if blog_title and not (frappe.local.form_dict.txt or frappe.local.form_dict.by) %} +
+
+

+ {{ blog_title }} +

+ {% if blog_introduction -%} +

{{ blog_introduction }}

+ {%- endif %} +
+
+{% endif %} diff --git a/frappe/templates/pages/list.py b/frappe/templates/pages/list.py index e07a62bad4..7c6dc41c9a 100644 --- a/frappe/templates/pages/list.py +++ b/frappe/templates/pages/list.py @@ -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, diff --git a/frappe/templates/pages/login.html b/frappe/templates/pages/login.html index f8c33e3f5a..cdb5ef7ceb 100644 --- a/frappe/templates/pages/login.html +++ b/frappe/templates/pages/login.html @@ -3,7 +3,7 @@ {% block content %} -