瀏覽代碼

[minor] get_gravatar in templates to not query and show

version-14
Rushabh Mehta 9 年之前
父節點
當前提交
620b2f82b3
共有 7 個檔案被更改,包括 15 行新增13 行删除
  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 查看文件

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


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


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


+ 8
- 0
frappe/public/js/frappe/misc/common.js 查看文件

@@ -77,6 +77,14 @@ frappe.get_abbr = function(txt, max_length) {
return abbr || "?"; 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 // string commons


function repl(s, dict) { function repl(s, dict) {


+ 0
- 9
frappe/public/js/frappe/misc/user.js 查看文件

@@ -29,15 +29,6 @@ frappe.user_info = function(uid) {
return user_info; 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) { frappe.ui.set_user_background = function(src, selector, style) {
if(!selector) selector = "#page-desktop"; if(!selector) selector = "#page-desktop";
if(!style) style = "Fill Screen"; if(!style) style = "Fill Screen";


+ 1
- 1
frappe/templates/includes/web_sidebar.html 查看文件

@@ -19,7 +19,7 @@
<a href="/me">My Account</a> <a href="/me">My Account</a>
</li> </li>
{% for item in my_account_list -%} {% 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"> <li class="sidebar-item">
<a href="{{ item.route }}" class="text-muted {{ 'active' if pathname==item.route else '' }}" <a href="{{ item.route }}" class="text-muted {{ 'active' if pathname==item.route else '' }}"
{% if item.target %}target="{{ item.target }}"{% endif %}> {% if item.target %}target="{{ item.target }}"{% endif %}>


+ 3
- 0
frappe/utils/__init__.py 查看文件

@@ -137,6 +137,9 @@ def has_gravatar(email):
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
return '' 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): def get_gravatar(email):
gravatar_url = has_gravatar(email) gravatar_url = has_gravatar(email)




+ 1
- 1
frappe/utils/jinja.py 查看文件

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


+ 1
- 1
frappe/website/context.py 查看文件

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


context.my_account_list = frappe.get_all('Portal Menu Item', 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: for item in context.my_account_list:
if item.reference_doctype: if item.reference_doctype:


Loading…
取消
儲存