mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
37cb69867a
84
content.py
84
content.py
|
@ -322,6 +322,80 @@ def _save_custom_emoji(session, base_dir: str, emojiName: str, url: str,
|
|||
print('EX: cusom emoji already saved')
|
||||
|
||||
|
||||
def _get_emoji_name_from_code(base_dir: str, emoji_code: str) -> str:
|
||||
"""Returns the emoji name from its code
|
||||
"""
|
||||
emojis_filename = base_dir + '/emoji/emoji.json'
|
||||
if not os.path.isfile(emojis_filename):
|
||||
emojis_filename = base_dir + '/emoji/default_emoji.json'
|
||||
if not os.path.isfile(emojis_filename):
|
||||
return None
|
||||
emojis_json = load_json(emojis_filename)
|
||||
if not emojis_json:
|
||||
return None
|
||||
for emoji_name, code in emojis_json.items():
|
||||
if code == emoji_code:
|
||||
return emoji_name
|
||||
return None
|
||||
|
||||
|
||||
def _update_common_emoji(base_dir: str, emoji_content: str) -> None:
|
||||
"""Updates the list of commonly used emoji
|
||||
"""
|
||||
if '.' in emoji_content:
|
||||
emoji_content = emoji_content.split('.')[0]
|
||||
emoji_content = emoji_content.replace(':', '')
|
||||
if emoji_content.startswith('0x'):
|
||||
# lookup the name for an emoji code
|
||||
emoji_code = emoji_content[2:]
|
||||
emoji_content = _get_emoji_name_from_code(base_dir, emoji_code)
|
||||
if not emoji_content:
|
||||
return
|
||||
common_emoji_filename = base_dir + '/accounts/common_emoji.txt'
|
||||
common_emoji = None
|
||||
if os.path.isfile(common_emoji_filename):
|
||||
try:
|
||||
with open(common_emoji_filename, 'r') as fp_emoji:
|
||||
common_emoji = fp_emoji.readlines()
|
||||
except OSError:
|
||||
print('EX: unable to load common emoji file')
|
||||
pass
|
||||
if common_emoji:
|
||||
new_common_emoji = []
|
||||
emoji_found = False
|
||||
for line in common_emoji:
|
||||
if ' ' + emoji_content in line:
|
||||
if not emoji_found:
|
||||
emoji_found = True
|
||||
counter = 1
|
||||
count_str = line.split(' ')[0]
|
||||
if count_str.isdigit():
|
||||
counter = int(count_str) + 1
|
||||
count_str = str(counter).zfill(16)
|
||||
line = count_str + ' ' + emoji_content
|
||||
new_common_emoji.append(line)
|
||||
else:
|
||||
new_common_emoji.append(line.replace('\n', ''))
|
||||
if not emoji_found:
|
||||
new_common_emoji.append(str(1).zfill(16) + ' ' + emoji_content)
|
||||
new_common_emoji.sort(reverse=True)
|
||||
try:
|
||||
with open(common_emoji_filename, 'w+') as fp_emoji:
|
||||
for line in new_common_emoji:
|
||||
fp_emoji.write(line + '\n')
|
||||
except OSError:
|
||||
print('EX: error writing common emoji 1')
|
||||
return
|
||||
else:
|
||||
line = str(1).zfill(16) + ' ' + emoji_content + '\n'
|
||||
try:
|
||||
with open(common_emoji_filename, 'w+') as fp_emoji:
|
||||
fp_emoji.write(line)
|
||||
except OSError:
|
||||
print('EX: error writing common emoji 2')
|
||||
return
|
||||
|
||||
|
||||
def replace_emoji_from_tags(session, base_dir: str,
|
||||
content: str, tag: [], message_type: str,
|
||||
debug: bool) -> str:
|
||||
|
@ -370,6 +444,11 @@ def replace_emoji_from_tags(session, base_dir: str,
|
|||
tag_item['name'],
|
||||
tag_item['icon']['url'],
|
||||
debug)
|
||||
_update_common_emoji(base_dir,
|
||||
icon_name)
|
||||
else:
|
||||
_update_common_emoji(base_dir,
|
||||
"0x" + icon_name)
|
||||
else:
|
||||
# sequence of codes
|
||||
icon_codes = icon_name.split('-')
|
||||
|
@ -394,6 +473,11 @@ def replace_emoji_from_tags(session, base_dir: str,
|
|||
tag_item['name'],
|
||||
tag_item['icon']['url'],
|
||||
debug)
|
||||
_update_common_emoji(base_dir,
|
||||
icon_name)
|
||||
else:
|
||||
_update_common_emoji(base_dir,
|
||||
"0x" + icon_name)
|
||||
if icon_code_sequence:
|
||||
content = content.replace(tag_item['name'],
|
||||
icon_code_sequence)
|
||||
|
|
|
@ -1717,7 +1717,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not isinstance(message_json['object'][check_field], str):
|
||||
print('INBOX: ' +
|
||||
check_field + ' should be a string ' +
|
||||
str(message_json[check_field]))
|
||||
str(message_json['object'][check_field]))
|
||||
self._400()
|
||||
self.server.postreq_busy = False
|
||||
return 3
|
||||
|
@ -1731,7 +1731,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not isinstance(message_json['object'][check_field], list):
|
||||
print('INBOX: ' +
|
||||
check_field + ' should be a list ' +
|
||||
str(message_json[check_field]))
|
||||
str(message_json['object'][check_field]))
|
||||
self._400()
|
||||
self.server.postreq_busy = False
|
||||
return 3
|
||||
|
|
|
@ -114,6 +114,10 @@ a:focus {
|
|||
background-color: var(--main-bg-color);
|
||||
}
|
||||
|
||||
.follow container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.followAvatar {
|
||||
margin: 0% 0;
|
||||
}
|
||||
|
@ -201,12 +205,24 @@ input[type=text] {
|
|||
width: 15%;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 400px) {
|
||||
.hashtagswarm {
|
||||
font-size: var(--hashtag-size1);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing1);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.hashtagswarm img {
|
||||
width: 5%;
|
||||
min-width: 5%;
|
||||
}
|
||||
.followText {
|
||||
font-size: var(--follow-text-size1);
|
||||
|
@ -238,13 +254,13 @@ input[type=text] {
|
|||
}
|
||||
input[type=checkbox]
|
||||
{
|
||||
-ms-transform: scale(2);
|
||||
-moz-transform: scale(2);
|
||||
-webkit-transform: scale(2);
|
||||
-o-transform: scale(2);
|
||||
transform: scale(2);
|
||||
padding: 10px;
|
||||
margin: 20px 30px;
|
||||
-ms-transform: scale(2);
|
||||
-moz-transform: scale(2);
|
||||
-webkit-transform: scale(2);
|
||||
-o-transform: scale(2);
|
||||
transform: scale(2);
|
||||
padding: 10px;
|
||||
margin: 20px 30px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,6 +270,14 @@ input[type=text] {
|
|||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing3);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.hashtagswarm img {
|
||||
width: 10%;
|
||||
min-width: 10%;
|
||||
}
|
||||
.followText {
|
||||
font-size: var(--follow-text-size2);
|
||||
|
@ -297,13 +321,21 @@ input[type=text] {
|
|||
|
||||
@media screen and (max-width: 480px) {
|
||||
body, html {
|
||||
min-width: 400px;
|
||||
min-width: 400px;
|
||||
}
|
||||
.hashtagswarm {
|
||||
font-size: var(--font-size2);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing3);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.hashtagswarm img {
|
||||
width: 10%;
|
||||
min-width: 10%;
|
||||
}
|
||||
.followText {
|
||||
font-size: var(--font-size2);
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
@charset "UTF-8";
|
||||
|
||||
:root {
|
||||
--hashtag-margin: 2%;
|
||||
--hashtag-size1: 30px;
|
||||
--hashtag-size2: 40px;
|
||||
--hashtag-vertical-spacing1: 50px;
|
||||
--hashtag-vertical-spacing3: 100px;
|
||||
--likes-names-margin: 2%;
|
||||
--likes-names-size1: 30px;
|
||||
--likes-names-size2: 40px;
|
||||
|
@ -1082,6 +1087,12 @@ div.container {
|
|||
margin: 0 20%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 400px) {
|
||||
body, html {
|
||||
background-color: var(--main-bg-color);
|
||||
|
@ -1098,6 +1109,21 @@ div.container {
|
|||
font-size: var(--font-size);
|
||||
color: var(--title-color);
|
||||
}
|
||||
.hashtagswarm {
|
||||
font-size: var(--hashtag-size1);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing1);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#commonemojilabel {
|
||||
float: none;
|
||||
width: 5%;
|
||||
min-width: 5%;
|
||||
}
|
||||
.likerNames {
|
||||
font-size: var(--liker-names-size1);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
|
@ -1871,6 +1897,21 @@ div.container {
|
|||
blockquote {
|
||||
font-size: var(--quote-font-size-mobile);
|
||||
}
|
||||
.hashtagswarm {
|
||||
font-size: var(--hashtag-size2);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing3);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#commonemojilabel {
|
||||
float: none;
|
||||
width: 10%;
|
||||
min-width: 10%;
|
||||
}
|
||||
.likerNames {
|
||||
font-size: var(--liker-names-size2);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
|
@ -2616,6 +2657,21 @@ div.container {
|
|||
blockquote {
|
||||
font-size: var(--quote-font-size-tiny);
|
||||
}
|
||||
.hashtagswarm {
|
||||
font-size: var(--font-size2);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin: var(--hashtag-margin);
|
||||
line-height: var(--hashtag-vertical-spacing3);
|
||||
-webkit-user-select: all;
|
||||
-ms-user-select: all;
|
||||
user-select: all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#commonemojilabel {
|
||||
float: none;
|
||||
width: 10%;
|
||||
min-width: 10%;
|
||||
}
|
||||
.likerNames {
|
||||
font-size: var(--font-size2);
|
||||
font-family: 'Arial, Helvetica, sans-serif';
|
||||
|
|
50
reaction.py
50
reaction.py
|
@ -446,6 +446,54 @@ def outbox_undo_reaction(recent_posts_cache: {},
|
|||
print('DEBUG: post undo reaction via c2s - ' + post_filename)
|
||||
|
||||
|
||||
def _update_common_reactions(base_dir: str, emoji_content: str) -> None:
|
||||
"""Updates the list of commonly used reactions
|
||||
"""
|
||||
common_reactions_filename = base_dir + '/accounts/common_reactions.txt'
|
||||
common_reactions = None
|
||||
if os.path.isfile(common_reactions_filename):
|
||||
try:
|
||||
with open(common_reactions_filename, 'r') as fp_react:
|
||||
common_reactions = fp_react.readlines()
|
||||
except OSError:
|
||||
print('EX: unable to load common reactions file')
|
||||
pass
|
||||
if common_reactions:
|
||||
new_common_reactions = []
|
||||
reaction_found = False
|
||||
for line in common_reactions:
|
||||
if ' ' + emoji_content in line:
|
||||
if not reaction_found:
|
||||
reaction_found = True
|
||||
counter = 1
|
||||
count_str = line.split(' ')[0]
|
||||
if count_str.isdigit():
|
||||
counter = int(count_str) + 1
|
||||
count_str = str(counter).zfill(16)
|
||||
line = count_str + ' ' + emoji_content
|
||||
new_common_reactions.append(line)
|
||||
else:
|
||||
new_common_reactions.append(line.replace('\n', ''))
|
||||
if not reaction_found:
|
||||
new_common_reactions.append(str(1).zfill(16) + ' ' + emoji_content)
|
||||
new_common_reactions.sort(reverse=True)
|
||||
try:
|
||||
with open(common_reactions_filename, 'w+') as fp_react:
|
||||
for line in new_common_reactions:
|
||||
fp_react.write(line + '\n')
|
||||
except OSError:
|
||||
print('EX: error writing common reactions 1')
|
||||
return
|
||||
else:
|
||||
line = str(1).zfill(16) + ' ' + emoji_content + '\n'
|
||||
try:
|
||||
with open(common_reactions_filename, 'w+') as fp_react:
|
||||
fp_react.write(line)
|
||||
except OSError:
|
||||
print('EX: error writing common reactions 2')
|
||||
return
|
||||
|
||||
|
||||
def update_reaction_collection(recent_posts_cache: {},
|
||||
base_dir: str, post_filename: str,
|
||||
object_url: str, actor: str,
|
||||
|
@ -515,6 +563,8 @@ def update_reaction_collection(recent_posts_cache: {},
|
|||
itlen = len(obj['reactions']['items'])
|
||||
obj['reactions']['totalItems'] = itlen
|
||||
|
||||
_update_common_reactions(base_dir, emoji_content)
|
||||
|
||||
if debug:
|
||||
print('DEBUG: saving post with emoji reaction added')
|
||||
pprint(post_json_object)
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "الأوكسيتانية",
|
||||
"lang_pt": "البرتغالية",
|
||||
"lang_sw": "السواحيلية",
|
||||
"lang_zh": "صينى"
|
||||
"lang_zh": "صينى",
|
||||
"Common emoji": "الرموز التعبيرية الشائعة",
|
||||
"Copy and paste into your text": "نسخ ولصق في النص الخاص بك"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occità",
|
||||
"lang_pt": "Portuguès",
|
||||
"lang_sw": "Suahili",
|
||||
"lang_zh": "Xinès"
|
||||
"lang_zh": "Xinès",
|
||||
"Common emoji": "Emoji comú",
|
||||
"Copy and paste into your text": "Copia i enganxa al teu text"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Ocsitaneg",
|
||||
"lang_pt": "Portiwgaleg",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Tseiniaidd"
|
||||
"lang_zh": "Tseiniaidd",
|
||||
"Common emoji": "Emoji cyffredin",
|
||||
"Copy and paste into your text": "Copïwch a gludwch i'ch testun"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Okzitanisch",
|
||||
"lang_pt": "Portugiesisch",
|
||||
"lang_sw": "Suaheli",
|
||||
"lang_zh": "Chinesisch"
|
||||
"lang_zh": "Chinesisch",
|
||||
"Common emoji": "Gewöhnliches Emoji",
|
||||
"Copy and paste into your text": "Kopieren und in Ihren Text einfügen"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitan",
|
||||
"lang_pt": "Portuguese",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinese"
|
||||
"lang_zh": "Chinese",
|
||||
"Common emoji": "Common emoji",
|
||||
"Copy and paste into your text": "Copy and paste into your text"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitano",
|
||||
"lang_pt": "Portuguesa",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "China"
|
||||
"lang_zh": "China",
|
||||
"Common emoji": "Emoticonos comunes",
|
||||
"Copy and paste into your text": "Copia y pega en tu texto"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitan",
|
||||
"lang_pt": "Portugais",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinoise"
|
||||
"lang_zh": "Chinoise",
|
||||
"Common emoji": "Émoji commun",
|
||||
"Copy and paste into your text": "Copiez et collez dans votre texte"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Béarla",
|
||||
"lang_pt": "Portaingéilis",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Síneach"
|
||||
"lang_zh": "Síneach",
|
||||
"Common emoji": "Emoji coitianta",
|
||||
"Copy and paste into your text": "Cóipeáil agus greamaigh isteach i do théacs"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "ओसीटान",
|
||||
"lang_pt": "पुर्तगाली",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "चीनी"
|
||||
"lang_zh": "चीनी",
|
||||
"Common emoji": "आम इमोजी",
|
||||
"Copy and paste into your text": "अपने टेक्स्ट में कॉपी और पेस्ट करें"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitano",
|
||||
"lang_pt": "Portoghese",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Cinese"
|
||||
"lang_zh": "Cinese",
|
||||
"Common emoji": "Emoji comuni",
|
||||
"Copy and paste into your text": "Copia e incolla nel tuo testo"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "オック語",
|
||||
"lang_pt": "ポルトガル語",
|
||||
"lang_sw": "スワヒリ語",
|
||||
"lang_zh": "中国語"
|
||||
"lang_zh": "中国語",
|
||||
"Common emoji": "一般的な絵文字",
|
||||
"Copy and paste into your text": "コピーしてテキストに貼り付けます"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "옥시탄",
|
||||
"lang_pt": "포르투갈 인",
|
||||
"lang_sw": "스와힐리어",
|
||||
"lang_zh": "중국인"
|
||||
"lang_zh": "중국인",
|
||||
"Common emoji": "일반적인 이모티콘",
|
||||
"Copy and paste into your text": "텍스트에 복사하여 붙여넣기"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitan",
|
||||
"lang_pt": "Portekizî",
|
||||
"lang_sw": "Swahîlîyî",
|
||||
"lang_zh": "Çînî"
|
||||
"lang_zh": "Çînî",
|
||||
"Common emoji": "Emojiyên hevpar",
|
||||
"Copy and paste into your text": "Di nivîsa xwe de kopî bikin û bixin"
|
||||
}
|
||||
|
|
|
@ -540,5 +540,7 @@
|
|||
"lang_oc": "Occitan",
|
||||
"lang_pt": "Portuguese",
|
||||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinese"
|
||||
"lang_zh": "Chinese",
|
||||
"Common emoji": "Common emoji",
|
||||
"Copy and paste into your text": "Copy and paste into your text"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Prowansalski",
|
||||
"lang_pt": "Portugalski",
|
||||
"lang_sw": "Suahili",
|
||||
"lang_zh": "Chiński"
|
||||
"lang_zh": "Chiński",
|
||||
"Common emoji": "Popularne emotikony",
|
||||
"Copy and paste into your text": "Skopiuj i wklej do swojego tekstu"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Occitano",
|
||||
"lang_pt": "Português",
|
||||
"lang_sw": "Suaíli",
|
||||
"lang_zh": "Chinês"
|
||||
"lang_zh": "Chinês",
|
||||
"Common emoji": "Emoji comum",
|
||||
"Copy and paste into your text": "Copie e cole no seu texto"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "окситанский",
|
||||
"lang_pt": "португальский",
|
||||
"lang_sw": "суахили",
|
||||
"lang_zh": "Китайский"
|
||||
"lang_zh": "Китайский",
|
||||
"Common emoji": "Общие смайлики",
|
||||
"Copy and paste into your text": "Скопируйте и вставьте в свой текст"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "Oksitani",
|
||||
"lang_pt": "Kireno",
|
||||
"lang_sw": "Kiswahili",
|
||||
"lang_zh": "Kichina"
|
||||
"lang_zh": "Kichina",
|
||||
"Common emoji": "Emoji ya kawaida",
|
||||
"Copy and paste into your text": "Nakili na ubandike kwenye maandishi yako"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "окситанський",
|
||||
"lang_pt": "португальська",
|
||||
"lang_sw": "суахілі",
|
||||
"lang_zh": "китайський"
|
||||
"lang_zh": "китайський",
|
||||
"Common emoji": "Звичайні емодзі",
|
||||
"Copy and paste into your text": "Скопіюйте та вставте у свій текст"
|
||||
}
|
||||
|
|
|
@ -544,5 +544,7 @@
|
|||
"lang_oc": "奥克西坦",
|
||||
"lang_pt": "葡萄牙语",
|
||||
"lang_sw": "斯瓦希里语",
|
||||
"lang_zh": "中国人"
|
||||
"lang_zh": "中国人",
|
||||
"Common emoji": "常见表情符号",
|
||||
"Copy and paste into your text": "复制并粘贴到您的文本中"
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ from utils import get_currencies
|
|||
from utils import get_category_types
|
||||
from utils import get_account_timezone
|
||||
from utils import get_supported_languages
|
||||
from webapp_utils import html_common_emoji
|
||||
from webapp_utils import begin_edit_section
|
||||
from webapp_utils import end_edit_section
|
||||
from webapp_utils import get_banner_file
|
||||
|
@ -381,6 +382,17 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
|
|||
'imageDescription', '')
|
||||
new_post_image_section += end_edit_section()
|
||||
|
||||
new_post_emoji_section = ''
|
||||
common_emoji_str = html_common_emoji(base_dir, 16)
|
||||
if common_emoji_str:
|
||||
new_post_emoji_section = \
|
||||
begin_edit_section('😀 ' + translate['Common emoji'])
|
||||
new_post_emoji_section += \
|
||||
'<label class="labels">' + \
|
||||
translate['Copy and paste into your text'] + '</label><br>\n'
|
||||
new_post_emoji_section += common_emoji_str
|
||||
new_post_emoji_section += end_edit_section()
|
||||
|
||||
scope_icon = 'scope_public.png'
|
||||
scope_description = translate['Public']
|
||||
if share_description:
|
||||
|
@ -880,6 +892,7 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
|
|||
extra_fields + citations_str + replies_section + date_and_location
|
||||
if not media_instance or reply_str:
|
||||
new_post_form += new_post_image_section
|
||||
new_post_form += new_post_emoji_section
|
||||
|
||||
new_post_form += \
|
||||
' <div class="container">\n' + \
|
||||
|
|
|
@ -30,6 +30,7 @@ from skills import get_skills_from_list
|
|||
from categories import get_hashtag_category
|
||||
from feeds import rss2tag_header
|
||||
from feeds import rss2tag_footer
|
||||
from webapp_utils import html_common_emoji
|
||||
from webapp_utils import set_custom_background
|
||||
from webapp_utils import html_keyboard_navigation
|
||||
from webapp_utils import html_header_with_external_style
|
||||
|
@ -369,6 +370,11 @@ def html_search_emoji_text_entry(css_cache: {}, translate: {},
|
|||
emoji_str += ' </form>\n'
|
||||
emoji_str += ' </center>\n'
|
||||
emoji_str += ' </div>\n'
|
||||
emoji_str += ' <center>\n'
|
||||
emoji_str += ' <div class="container"><p>\n'
|
||||
emoji_str += html_common_emoji(base_dir, 16) + '\n'
|
||||
emoji_str += ' </p></div>\n'
|
||||
emoji_str += ' </center>\n'
|
||||
emoji_str += '</div>\n'
|
||||
emoji_str += html_footer()
|
||||
return emoji_str
|
||||
|
|
|
@ -1672,3 +1672,60 @@ def set_custom_background(base_dir: str, background: str,
|
|||
base_dir + '/accounts/' + new_background + '.' + ext)
|
||||
return ext
|
||||
return None
|
||||
|
||||
|
||||
def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
|
||||
"""Shows common emoji
|
||||
"""
|
||||
emojis_filename = base_dir + '/emoji/emoji.json'
|
||||
if not os.path.isfile(emojis_filename):
|
||||
emojis_filename = base_dir + '/emoji/default_emoji.json'
|
||||
emojis_json = load_json(emojis_filename)
|
||||
|
||||
common_emoji_filename = base_dir + '/accounts/common_emoji.txt'
|
||||
if not os.path.isfile(common_emoji_filename):
|
||||
return ''
|
||||
common_emoji = None
|
||||
try:
|
||||
with open(common_emoji_filename, 'r') as fp_emoji:
|
||||
common_emoji = fp_emoji.readlines()
|
||||
except OSError:
|
||||
print('EX: html_common_emoji unable to load file')
|
||||
return ''
|
||||
if not common_emoji:
|
||||
return ''
|
||||
line_ctr = 0
|
||||
ctr = 0
|
||||
html_str = ''
|
||||
while ctr < no_of_emoji and line_ctr < len(common_emoji):
|
||||
emoji_name = common_emoji[line_ctr].split(' ')[1].replace('\n', '')
|
||||
emoji_icon_name = emoji_name
|
||||
emoji_filename = base_dir + '/emoji/' + emoji_name + '.png'
|
||||
if not os.path.isfile(emoji_filename):
|
||||
emoji_filename = base_dir + '/customemoji/' + emoji_name + '.png'
|
||||
if not os.path.isfile(emoji_filename):
|
||||
# load the emojis index
|
||||
if not emojis_json:
|
||||
emojis_json = load_json(emojis_filename)
|
||||
# lookup the name within the index to get the hex code
|
||||
if emojis_json:
|
||||
for emoji_tag, emoji_code in emojis_json.items():
|
||||
if emoji_tag == emoji_name:
|
||||
# get the filename based on the hex code
|
||||
emoji_filename = \
|
||||
base_dir + '/emoji/' + emoji_code + '.png'
|
||||
emoji_icon_name = emoji_code
|
||||
break
|
||||
if os.path.isfile(emoji_filename):
|
||||
# NOTE: deliberately no alt text, so that without graphics only
|
||||
# the emoji name shows
|
||||
html_str += \
|
||||
'<label class="hashtagswarm">' + \
|
||||
'<img id="commonemojilabel" ' + \
|
||||
'loading="lazy" decoding="async" ' + \
|
||||
'src="/emoji/' + emoji_icon_name + '.png" ' + \
|
||||
'alt="" title="">' + \
|
||||
':' + emoji_name + ':</label>\n'
|
||||
ctr += 1
|
||||
line_ctr += 1
|
||||
return html_str
|
||||
|
|
Loading…
Reference in New Issue