Adding post tags for custom emoji

merge-requests/30/head
Bob Mottram 2022-03-29 22:10:09 +01:00
parent 1e82777fdb
commit 88380b2c3c
2 changed files with 13 additions and 16 deletions

View File

@ -551,7 +551,10 @@ def _add_emoji(base_dir: str, word_str: str,
return False return False
emoji_filename = base_dir + '/emoji/' + emoji_dict[emoji] + '.png' emoji_filename = base_dir + '/emoji/' + emoji_dict[emoji] + '.png'
if not os.path.isfile(emoji_filename): if not os.path.isfile(emoji_filename):
return False emoji_filename = \
base_dir + '/emojicustom/' + emoji_dict[emoji] + '.png'
if not os.path.isfile(emoji_filename):
return False
emoji_url = http_prefix + "://" + domain + \ emoji_url = http_prefix + "://" + domain + \
"/emoji/" + emoji_dict[emoji] + '.png' "/emoji/" + emoji_dict[emoji] + '.png'
post_tags[emoji] = { post_tags[emoji] = {
@ -940,21 +943,15 @@ def add_html_tags(base_dir: str, http_prefix: str,
emoji_dict = load_json(base_dir + '/emoji/emoji.json') emoji_dict = load_json(base_dir + '/emoji/emoji.json')
# append custom emoji to the dict # append custom emoji to the dict
if os.path.isfile(base_dir + '/emojicustom/emoji.json'): custom_emoji_filename = base_dir + '/emojicustom/emoji.json'
custom_emoji_dict = \ if os.path.isfile(custom_emoji_filename):
load_json(base_dir + '/emojicustom/emoji.json') custom_emoji_dict = load_json(custom_emoji_filename)
if custom_emoji_dict: if custom_emoji_dict:
emojis_combined = True # combine emoji dicts one by one
try: for ename, eitem in custom_emoji_dict.items():
emoji_dict = dict(emoji_dict, **custom_emoji_dict) if ename and eitem:
except BaseException: if not emoji_dict.get(ename):
emojis_combined = False emoji_dict[ename] = eitem
if not emojis_combined:
# combine emoji dicts one by one
for ename, eitem in custom_emoji_dict.items():
if ename and eitem:
if not emoji_dict.get(ename):
emoji_dict[ename] = eitem
# print('TAG: looking up emoji for :' + word_str2 + ':') # print('TAG: looking up emoji for :' + word_str2 + ':')
_add_emoji(base_dir, ':' + word_str2 + ':', http_prefix, _add_emoji(base_dir, ':' + word_str2 + ':', http_prefix,

View File

@ -6756,7 +6756,7 @@ def _test_bold_reading() -> None:
def run_all_tests(): def run_all_tests():
base_dir = os.getcwd() base_dir = os.getcwd()
print('Running tests...') print('Running tests...')
update_default_themes_list(os.getcwd()) update_default_themes_list(os.getcwd())
_test_source_contains_no_tabs() _test_source_contains_no_tabs()