Fix issue #3321: Emoji extension uses wrong path

remotes/origin/logger
David Barragán Merino 2015-10-13 15:13:36 +02:00 committed by Alejandro Alonso
parent 7ec8253749
commit 67636f1b32
2 changed files with 7 additions and 9 deletions

View File

@ -193,9 +193,6 @@ MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage"
# urls depends on it. On production should be set # urls depends on it. On production should be set
# something like https://media.taiga.io/ # something like https://media.taiga.io/
MEDIA_URL = "http://localhost:8000/media/" MEDIA_URL = "http://localhost:8000/media/"
# Static url is not widelly used by taiga (only
# if admin is activated).
STATIC_URL = "http://localhost:8000/static/" STATIC_URL = "http://localhost:8000/static/"
# Static configuration. # Static configuration.

View File

@ -27,7 +27,8 @@
import re import re
from django.conf import settings from django.templatetags.static import static
from markdown.extensions import Extension from markdown.extensions import Extension
from markdown.preprocessors import Preprocessor from markdown.preprocessors import Preprocessor
@ -35,8 +36,8 @@ from markdown.preprocessors import Preprocessor
# Grab the emojis (+800) here: https://github.com/arvida/emoji-cheat-sheet.com # Grab the emojis (+800) here: https://github.com/arvida/emoji-cheat-sheet.com
# This **crazy long** list was generated by walking through the emojis.png # This **crazy long** list was generated by walking through the emojis.png
emojis_path = "{}://{}/static/img/emojis/".format(settings.SITES["api"]["scheme"], settings.SITES["api"]["domain"]) EMOJIS_PATH = "img/emojis/"
emojis_set = { EMOJIS_SET = {
"+1", "-1", "100", "1234", "8ball", "a", "ab", "abc", "abcd", "accept", "aerial_tramway", "airplane", "+1", "-1", "100", "1234", "8ball", "a", "ab", "abc", "abcd", "accept", "aerial_tramway", "airplane",
"alarm_clock", "alien", "ambulance", "anchor", "angel", "anger", "angry", "anguished", "ant", "apple", "alarm_clock", "alien", "ambulance", "anchor", "angel", "anger", "angry", "anguished", "ant", "apple",
"aquarius", "aries", "arrows_clockwise", "arrows_counterclockwise", "arrow_backward", "arrow_double_down", "aquarius", "aries", "arrows_clockwise", "arrows_counterclockwise", "arrow_backward", "arrow_double_down",
@ -168,11 +169,11 @@ class EmojifyPreprocessor(Preprocessor):
def emojify(match): def emojify(match):
emoji = match.group(1) emoji = match.group(1)
if emoji not in emojis_set: if emoji not in EMOJIS_SET:
return match.group(0) return match.group(0)
url = emojis_path + emoji + u'.png' path = "{}{}.png".format(EMOJIS_PATH, emoji)
url = static(path)
return '![{emoji}]({url})'.format(emoji=emoji, url=url) return '![{emoji}]({url})'.format(emoji=emoji, url=url)
for line in lines: for line in lines: