Browse Source

[minor] get_gravatar in templates to not query and show

version-14
Rushabh Mehta 9 years ago
parent
commit
620b2f82b3
7 changed files with 15 additions and 13 deletions
  1. +1
    -1
      frappe/app.py
  2. +8
    -0
      frappe/public/js/frappe/misc/common.js
  3. +0
    -9
      frappe/public/js/frappe/misc/user.js
  4. +1
    -1
      frappe/templates/includes/web_sidebar.html
  5. +3
    -0
      frappe/utils/__init__.py
  6. +1
    -1
      frappe/utils/jinja.py
  7. +1
    -1
      frappe/website/context.py

+ 1
- 1
frappe/app.py View File

@@ -180,7 +180,7 @@ def serve(port=8000, profile=False, site=None, sites_path='.'):
from werkzeug.serving import run_simple

if profile:
application = ProfilerMiddleware(application, sort_by=('tottime', 'calls'))
application = ProfilerMiddleware(application, sort_by=('cumtime', 'calls'))

if not os.environ.get('NO_STATICS'):
application = SharedDataMiddleware(application, {


+ 8
- 0
frappe/public/js/frappe/misc/common.js View File

@@ -77,6 +77,14 @@ frappe.get_abbr = function(txt, max_length) {
return abbr || "?";
}

frappe.gravatars = {};
frappe.get_gravatar = function(email_id) {
if(!frappe.gravatars[email_id]) {
frappe.gravatars[email_id] = "https://secure.gravatar.com/avatar/" + md5(email_id) + "?d=retro";
}
return frappe.gravatars[email_id];
}

// string commons

function repl(s, dict) {


+ 0
- 9
frappe/public/js/frappe/misc/user.js View File

@@ -29,15 +29,6 @@ frappe.user_info = function(uid) {
return user_info;
}


frappe.gravatars = {};
frappe.get_gravatar = function(email_id) {
if(!frappe.gravatars[email_id]) {
frappe.gravatars[email_id] = "https://secure.gravatar.com/avatar/" + md5(email_id) + "?d=retro";
}
return frappe.gravatars[email_id];
}

frappe.ui.set_user_background = function(src, selector, style) {
if(!selector) selector = "#page-desktop";
if(!style) style = "Fill Screen";


+ 1
- 1
frappe/templates/includes/web_sidebar.html View File

@@ -19,7 +19,7 @@
<a href="/me">My Account</a>
</li>
{% for item in my_account_list -%}
{% if item.count or (not item.reference_doctype) %}
{% if item.count or (not item.reference_doctype) or item.show_always %}
<li class="sidebar-item">
<a href="{{ item.route }}" class="text-muted {{ 'active' if pathname==item.route else '' }}"
{% if item.target %}target="{{ item.target }}"{% endif %}>


+ 3
- 0
frappe/utils/__init__.py View File

@@ -137,6 +137,9 @@ def has_gravatar(email):
except requests.exceptions.ConnectionError:
return ''

def get_gravatar_url(email):
return "https://secure.gravatar.com/avatar/{hash}?d=mm&s=200".format(hash=md5.md5(email).hexdigest())

def get_gravatar(email):
gravatar_url = has_gravatar(email)



+ 1
- 1
frappe/utils/jinja.py View File

@@ -95,7 +95,7 @@ def get_allowed_functions_for_jenv():
"user": getattr(frappe.local, "session", None) and frappe.local.session.user or "Guest",
"date_format": frappe.db.get_default("date_format") or "yyyy-mm-dd",
"get_fullname": frappe.utils.get_fullname,
"get_gravatar": frappe.utils.get_gravatar,
"get_gravatar": frappe.utils.get_gravatar_url,
"full_name": getattr(frappe.local, "session", None) and frappe.local.session.data.full_name or "Guest",
"render_template": frappe.render_template
},


+ 1
- 1
frappe/website/context.py View File

@@ -85,7 +85,7 @@ def add_sidebar_data(context):
import frappe.templates.pages.list

context.my_account_list = frappe.get_all('Portal Menu Item',
fields=['title', 'route', 'reference_doctype'], filters={'enabled': 1}, order_by='idx asc')
fields=['title', 'route', 'reference_doctype', 'show_always'], filters={'enabled': 1}, order_by='idx asc')

for item in context.my_account_list:
if item.reference_doctype:


Loading…
Cancel
Save