You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2018/12/12 16:32:25 UTC
[4/5] allura git commit: [#8263] Move methods from app_globals to
helpers
[#8263] Move methods from app_globals to helpers
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/3e525285
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3e525285
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3e525285
Branch: refs/heads/master
Commit: 3e525285cf1e58efab2504dd5b503d5b10034436
Parents: 40c302d
Author: Shalitha Suranga <sh...@gmail.com>
Authored: Tue Dec 11 13:24:40 2018 +0530
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Dec 12 16:32:04 2018 +0000
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 9 ---------
Allura/allura/lib/helpers.py | 11 +++++++++++
Allura/allura/lib/utils.py | 4 ++--
Allura/allura/templates/widgets/post_widget.html | 4 ++--
4 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/3e525285/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 6856245..58d5b0e 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -34,7 +34,6 @@ import traceback
import activitystream
import pkg_resources
import markdown
-import emoji
import pygments
import pygments.lexers
import pygments.formatters
@@ -615,14 +614,6 @@ class Globals(object):
"image_height": logo['image_height']
}
- def emojize(self, text):
- """Coverts emoji codes to unicode emojis"""
- return emoji.emojize(text, use_aliases=True)
-
- def get_current_reaction(self, d):
- """Return current selected reaction for given react_users dict"""
- return utils.get_key_from_value(d, c.user.username)
-
class Icon(object):
http://git-wip-us.apache.org/repos/asf/allura/blob/3e525285/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index bbf36e4..70c768f 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -39,6 +39,7 @@ from functools import partial
from cStringIO import StringIO
import cgi
+import emoji
import tg
import genshi.template
try:
@@ -1338,3 +1339,13 @@ def hide_private_info(message):
return email_re.sub(r'\1@...', message)
else:
return message
+
+
+def emojize(text):
+ """Coverts emoji codes to unicode emojis"""
+ return emoji.emojize(text, use_aliases=True)
+
+
+def get_current_reaction(react_users_dict):
+ """Return current selected reaction for given react_users dict"""
+ return utils.get_key_from_value(react_users_dict, c.user.username)
http://git-wip-us.apache.org/repos/asf/allura/blob/3e525285/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index dbc83c9..e07323c 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -30,9 +30,9 @@ import magic
from itertools import groupby
import operator as op
import collections
-import emoji
import tg
+import emoji
import pylons
import json
from formencode import Invalid
@@ -783,7 +783,7 @@ def get_reactions_json():
""" Returns global reactions json """
j = OrderedDict()
for em in get_reaction_emoji_list():
- j[em] = pylons.app_globals.emojize(em)
+ j[em] = emoji.emojize(em, use_aliases=True)
return json.dumps(j)
http://git-wip-us.apache.org/repos/asf/allura/blob/3e525285/Allura/allura/templates/widgets/post_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html
index c65768e..f4504b4 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -56,7 +56,7 @@
<div class="tools">
{% if not c.user.is_anonymous() %}
- <a href="#" id="react_{{value.slug.replace('/','_')}}" data-commentlink="{{value.url()}}" data-currentreact="{{ g.get_current_reaction(value.react_users) }}" class="reaction-button icon btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"{%if value.status == 'pending'%} style="display:none"{%endif%}>
+ <a href="#" id="react_{{value.slug.replace('/','_')}}" data-commentlink="{{value.url()}}" data-currentreact="{{ h.get_current_reaction(value.react_users) }}" class="reaction-button icon btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"{%if value.status == 'pending'%} style="display:none"{%endif%}>
<span><i class="fa fa-smile-o" aria-hidden="true"></i></span></a>
{% endif %}
{% if (h.has_access(value.thread, 'post')() and value.status == 'ok') or moderator %}
@@ -85,7 +85,7 @@
<div{% if h.has_access(value, 'moderate') %} class="active-md" data-markdownlink="{{value.url()}}" {% endif %}>{{g.markdown.cached_convert(value, 'text')|safe}}</div>
<div class='reactions' style='user-select: none; cursor: default'>
{% for reaction in value.react_counts %}
- <span>{{ g.emojize(reaction) }}</span> {{ value.react_counts[reaction] }}
+ <span>{{ h.emojize(reaction) }}</span> {{ value.react_counts[reaction] }}
{% endfor %}
</div>
{{lib.related_artifacts(value)}}