From 8bf6151dd9814c1ed0acdfdfcaacab8ba56e1335 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 21 Apr 2016 18:18:39 +0530 Subject: [PATCH] [fix] css for blog and set context.path = request.path if available --- frappe/public/css/website.css | 14 ++++----- frappe/public/less/website.less | 30 +++++++++----------- frappe/templates/generators/blog_post.html | 4 +-- frappe/templates/includes/blog/blog_row.html | 2 +- frappe/templates/includes/blog/blogger.html | 2 +- frappe/utils/__init__.py | 13 +++++---- frappe/website/context.py | 16 +++++++---- 7 files changed, 43 insertions(+), 38 deletions(-) diff --git a/frappe/public/css/website.css b/frappe/public/css/website.css index 11e64a9a5b..f844cd2d1c 100644 --- a/frappe/public/css/website.css +++ b/frappe/public/css/website.css @@ -589,6 +589,7 @@ fieldset { } .blog-category { text-transform: uppercase; + letter-spacing: 0.5px; font-size: 12px; text-align: center; margin-bottom: 20px; @@ -600,7 +601,7 @@ fieldset { } .blog-comments, .help-article-comments { - padding: 5px 15px 15px 70px; + padding: 0px 15px 15px 85px; } .comment-view { background-color: #fafbfc; @@ -846,6 +847,7 @@ body { display: inline-block; padding-bottom: 4px; text-transform: uppercase; + letter-spacing: 0.5px; font-size: 12px; } .sidebar-block, @@ -855,6 +857,7 @@ body { } .content-block { padding-left: 50px; + padding-right: 50px; } .content-header { padding-bottom: 20px; @@ -867,7 +870,7 @@ a:active { } .blog-header { font-size: 36px; - margin-bottom: 20px; + margin-left: -1px; } .blog-dot:before { padding-right: 8px; @@ -879,14 +882,12 @@ a:active { margin-bottom: 25px; border: none; } -.post-description { - margin-top: 0px; -} .post-by { - margin-top: 4px; + margin-top: -5px; margin-bottom: 4px; text-transform: uppercase; font-size: 12px; + letter-spacing: 0.5px; } li .footer-child-item { margin-bottom: 4px !important; @@ -899,7 +900,6 @@ li .social-child-item { margin-top: 30px; } .blog-text { - text-align: justify; padding-top: 50px; padding-bottom: 50px; font-size: 18px; diff --git a/frappe/public/less/website.less b/frappe/public/less/website.less index 04557bef31..82cd756338 100644 --- a/frappe/public/less/website.less +++ b/frappe/public/less/website.less @@ -251,7 +251,6 @@ fieldset { h1, h2, h3 { margin-top: 10px; - } h1, h2, h3, h4, h5, h6 { @@ -286,6 +285,7 @@ fieldset { .blog-category { text-transform: uppercase; + letter-spacing: 0.5px; font-size: 12px; text-align: center; margin-bottom: 20px; @@ -299,7 +299,7 @@ fieldset { .blog-comments, .help-article-comments { - padding: 5px 15px 15px 70px; + padding: 0px 15px 15px 85px; } .comment-view { background-color: #fafbfc; @@ -439,20 +439,22 @@ a.active { margin-top: 60px; } -.footer-group-label{ +.footer-group-label { display:inline-block; padding-bottom: 4px; text-transform: uppercase; + letter-spacing: 0.5px; font-size: 12px; } .sidebar-block, .content-block { - padding-top:50px; - padding-bottom:50px; + padding-top: 50px; + padding-bottom: 50px; } .content-block { padding-left: 50px; + padding-right: 50px; } .content-header { @@ -464,9 +466,9 @@ a:hover, a:visited, a:link, a:active text-decoration: none; } -.blog-header{ - font-size:36px; - margin-bottom: 20px; +.blog-header { + font-size: 36px; + margin-left: -1px; } .blog-dot:before{ @@ -481,15 +483,12 @@ a:hover, a:visited, a:link, a:active border:none; } -.post-description{ - margin-top:0px; -} - .post-by { - margin-top:4px; - margin-bottom:4px; + margin-top: -5px; + margin-bottom: 4px; text-transform: uppercase; font-size: 12px; + letter-spacing: 0.5px; } li .footer-child-item { @@ -506,7 +505,6 @@ li .social-child-item { } .blog-text { - text-align:justify; padding-top: 50px; padding-bottom: 50px; font-size: 18px; @@ -534,4 +532,4 @@ li .social-child-item { .vert-line {overflow:hidden;} .vert-line>div+div{border-left:1px solid @light-border-color;} .vert-line>div{ - padding-bottom:2000px; margin-bottom:-2000px;} \ No newline at end of file + padding-bottom:2000px; margin-bottom:-2000px;} diff --git a/frappe/templates/generators/blog_post.html b/frappe/templates/generators/blog_post.html index bc344c289a..58fe2f84e1 100644 --- a/frappe/templates/generators/blog_post.html +++ b/frappe/templates/generators/blog_post.html @@ -7,9 +7,7 @@
{{blog_category}}
-
- {{ title }} -
+

{{ title }}

BY {{ blogger_info and blogger_info.full_name or full_name }} {{ frappe.format_date(published_on) }} {{ comment_text }}

diff --git a/frappe/templates/includes/blog/blog_row.html b/frappe/templates/includes/blog/blog_row.html index 868e79ec06..4c4477495e 100644 --- a/frappe/templates/includes/blog/blog_row.html +++ b/frappe/templates/includes/blog/blog_row.html @@ -2,7 +2,7 @@
- +

{{ post.title }}

BY {{ post.full_name }} {{ frappe.format_date(post.published_on) }} {{ post.blog_category }} {{ post.comment_text }}

{{ post.content }}

diff --git a/frappe/templates/includes/blog/blogger.html b/frappe/templates/includes/blog/blogger.html index 816fe11b34..ca45578464 100644 --- a/frappe/templates/includes/blog/blogger.html +++ b/frappe/templates/includes/blog/blogger.html @@ -1,6 +1,6 @@
-
+
diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index ed813ad277..860a45a3d3 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -125,22 +125,25 @@ def has_gravatar(email): or frappe.flags.in_test): # no gravatar if via upload # since querying gravatar for every item will be slow - return + return '' gravatar_url = "https://secure.gravatar.com/avatar/{hash}?d=404&s=200".format(hash=md5.md5(email).hexdigest()) try: res = requests.get(gravatar_url) - if res.status_code==404: - return '' - else: + if res.status_code==200: return gravatar_url + else: + return '' except requests.exceptions.ConnectionError: return '' def get_gravatar(email): gravatar_url = has_gravatar(email) + if not gravatar_url: - return Identicon(email).base64() + gravatar_url = Identicon(email).base64() + + return gravatar_url def get_traceback(): """ diff --git a/frappe/website/context.py b/frappe/website/context.py index de75863617..8a5d3919a0 100644 --- a/frappe/website/context.py +++ b/frappe/website/context.py @@ -14,7 +14,13 @@ def get_context(path, args=None): context.update(args) context = build_context(context) - context["path"] = path + + if frappe.local.request: + # for (remove leading slash) + # path could be overriden in render.resolve_from_map + context["path"] = frappe.local.request.path[1:] + else: + context["path"] = path # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): @@ -76,19 +82,19 @@ def build_context(context): def add_sidebar_data(context): from frappe.utils.user import get_fullname_and_avatar - + context.my_account_list = frappe.get_all('Portal Menu Item', fields=['title', 'route', 'reference_doctype'], filters={'enabled': 1}, order_by='idx asc') for item in context.my_account_list: if item.reference_doctype: item.count = len(frappe.templates.pages.list.get(item.reference_doctype).get('result')) - - + + info = get_fullname_and_avatar(frappe.session.user) context["fullname"] = info.fullname context["user_image"] = info.avatar - + def add_metatags(context): tags = context.get("metatags")