Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-09-02 12:11:23 +01:00
commit 1f70c519d8
29 changed files with 231 additions and 30 deletions

View File

@ -156,6 +156,7 @@ from roles import get_actor_roles_list
from roles import set_role from roles import set_role
from roles import clear_moderator_status from roles import clear_moderator_status
from roles import clear_editor_status from roles import clear_editor_status
from roles import clear_devops_status
from roles import clear_counselor_status from roles import clear_counselor_status
from roles import clear_artist_status from roles import clear_artist_status
from blog import path_contains_blog_link from blog import path_contains_blog_link
@ -6678,6 +6679,71 @@ class PubServer(BaseHTTPRequestHandler):
ed_nick, domain, ed_nick, domain,
'editor') 'editor')
# change site devops list
if fields.get('devopslist'):
if path.startswith('/users/' +
admin_nickname + '/'):
devops_file = \
base_dir + \
'/accounts/devops.txt'
clear_devops_status(base_dir)
if ',' in fields['devopslist']:
# if the list was given as comma separated
dos = fields['devopslist'].split(',')
try:
with open(devops_file, 'w+',
encoding='utf-8') as dofil:
for do_nick in dos:
do_nick = do_nick.strip()
do_dir = base_dir + \
'/accounts/' + do_nick + \
'@' + domain
if os.path.isdir(do_dir):
dofil.write(do_nick + '\n')
except OSError as ex:
print('EX: unable to write devops ' +
devops_file + ' ' + str(ex))
for do_nick in dos:
do_nick = do_nick.strip()
do_dir = base_dir + \
'/accounts/' + do_nick + \
'@' + domain
if os.path.isdir(do_dir):
set_role(base_dir,
do_nick, domain,
'devops')
else:
# nicknames on separate lines
dos = fields['devopslist'].split('\n')
try:
with open(devops_file, 'w+',
encoding='utf-8') as dofile:
for do_nick in dos:
do_nick = do_nick.strip()
do_dir = \
base_dir + \
'/accounts/' + do_nick + \
'@' + domain
if os.path.isdir(do_dir):
dofile.write(do_nick +
'\n')
except OSError as ex:
print('EX: unable to write devops ' +
devops_file + ' ' + str(ex))
for do_nick in dos:
do_nick = do_nick.strip()
do_dir = \
base_dir + \
'/accounts/' + \
do_nick + '@' + \
domain
if os.path.isdir(do_dir):
set_role(base_dir,
do_nick, domain,
'devops')
# change site counselors list # change site counselors list
if fields.get('counselors'): if fields.get('counselors'):
if path.startswith('/users/' + if path.startswith('/users/' +

View File

@ -14,6 +14,7 @@ from utils import get_status_number
from utils import remove_domain_port from utils import remove_domain_port
from utils import acct_dir from utils import acct_dir
from utils import text_in_file from utils import text_in_file
from utils import get_config_param
def _clear_role_status(base_dir: str, role: str) -> None: def _clear_role_status(base_dir: str, role: str) -> None:
@ -49,6 +50,14 @@ def clear_editor_status(base_dir: str) -> None:
_clear_role_status(base_dir, 'editor') _clear_role_status(base_dir, 'editor')
def clear_devops_status(base_dir: str) -> None:
"""Removes devops status from all accounts
This could be slow if there are many users, but only happens
rarely when devops are appointed or removed
"""
_clear_role_status(base_dir, 'devops')
def clear_counselor_status(base_dir: str) -> None: def clear_counselor_status(base_dir: str) -> None:
"""Removes counselor status from all accounts """Removes counselor status from all accounts
This could be slow if there are many users, but only happens This could be slow if there are many users, but only happens
@ -296,3 +305,32 @@ def actor_has_role(actor_json: {}, role_name: str) -> bool:
""" """
roles_list = get_actor_roles_list(actor_json) roles_list = get_actor_roles_list(actor_json)
return role_name in roles_list return role_name in roles_list
def is_devops(base_dir: str, nickname: str) -> bool:
"""Returns true if the given nickname has the devops role
"""
devops_file = base_dir + '/accounts/devops.txt'
if not os.path.isfile(devops_file):
admin_name = get_config_param(base_dir, 'admin')
if not admin_name:
return False
if admin_name == nickname:
return True
return False
with open(devops_file, 'r', encoding='utf-8') as fp_mod:
lines = fp_mod.readlines()
if len(lines) == 0:
# if there is nothing in the file
admin_name = get_config_param(base_dir, 'admin')
if not admin_name:
return False
if admin_name == nickname:
return True
for devops in lines:
devops = devops.strip('\n').strip('\r')
if devops == nickname:
return True
return False

View File

@ -590,5 +590,8 @@
"Last year": "العام الماضي", "Last year": "العام الماضي",
"Unauthorized": "غير مصرح", "Unauthorized": "غير مصرح",
"No login credentials were posted": "لم يتم نشر بيانات اعتماد تسجيل الدخول", "No login credentials were posted": "لم يتم نشر بيانات اعتماد تسجيل الدخول",
"Credentials are too long": "أوراق الاعتماد طويلة جدًا" "Credentials are too long": "أوراق الاعتماد طويلة جدًا",
"Site DevOps": "DevOps الموقع",
"A list of devops nicknames. One per line.": "قائمة بأسماء المطورين. واحد في كل سطر.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "গত বছর", "Last year": "গত বছর",
"Unauthorized": "অননুমোদিত", "Unauthorized": "অননুমোদিত",
"No login credentials were posted": "কোনো লগইন শংসাপত্র পোস্ট করা হয়নি", "No login credentials were posted": "কোনো লগইন শংসাপত্র পোস্ট করা হয়নি",
"Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷" "Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷",
"Site DevOps": "সাইট DevOps",
"A list of devops nicknames. One per line.": "ডেভপস ডাকনামের একটি তালিকা। প্রতি লাইনে একটি।",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "L'any passat", "Last year": "L'any passat",
"Unauthorized": "No autoritzat", "Unauthorized": "No autoritzat",
"No login credentials were posted": "No s'ha publicat cap credencial d'inici de sessió", "No login credentials were posted": "No s'ha publicat cap credencial d'inici de sessió",
"Credentials are too long": "Les credencials són massa llargues" "Credentials are too long": "Les credencials són massa llargues",
"Site DevOps": "Lloc DevOps",
"A list of devops nicknames. One per line.": "Una llista de sobrenoms de devops. Un per línia.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Blwyddyn diwethaf", "Last year": "Blwyddyn diwethaf",
"Unauthorized": "Anawdurdodedig", "Unauthorized": "Anawdurdodedig",
"No login credentials were posted": "Ni bostiwyd unrhyw fanylion mewngofnodi", "No login credentials were posted": "Ni bostiwyd unrhyw fanylion mewngofnodi",
"Credentials are too long": "Mae manylion yn rhy hir" "Credentials are too long": "Mae manylion yn rhy hir",
"Site DevOps": "Gwefan DevOps",
"A list of devops nicknames. One per line.": "Mae rhestr o devops llysenwau. Un i bob llinell.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Vergangenes Jahr", "Last year": "Vergangenes Jahr",
"Unauthorized": "Unbefugt", "Unauthorized": "Unbefugt",
"No login credentials were posted": "Es wurden keine Zugangsdaten gepostet", "No login credentials were posted": "Es wurden keine Zugangsdaten gepostet",
"Credentials are too long": "Anmeldeinformationen sind zu lang" "Credentials are too long": "Anmeldeinformationen sind zu lang",
"Site DevOps": "Site-DevOps",
"A list of devops nicknames. One per line.": "Eine Liste von Entwickler-Spitznamen. Eine pro Zeile.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Πέρυσι", "Last year": "Πέρυσι",
"Unauthorized": "Ανεξουσιοδότητος", "Unauthorized": "Ανεξουσιοδότητος",
"No login credentials were posted": "Δεν δημοσιεύτηκαν διαπιστευτήρια σύνδεσης", "No login credentials were posted": "Δεν δημοσιεύτηκαν διαπιστευτήρια σύνδεσης",
"Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα" "Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα",
"Site DevOps": "DevOps ιστότοπου",
"A list of devops nicknames. One per line.": "Μια λίστα με ψευδώνυμα devops. Ένα ανά γραμμή.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Last year", "Last year": "Last year",
"Unauthorized": "Unauthorized", "Unauthorized": "Unauthorized",
"No login credentials were posted": "No login credentials were posted", "No login credentials were posted": "No login credentials were posted",
"Credentials are too long": "Credentials are too long" "Credentials are too long": "Credentials are too long",
"Site DevOps": "Site DevOps",
"A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "El año pasado", "Last year": "El año pasado",
"Unauthorized": "No autorizado", "Unauthorized": "No autorizado",
"No login credentials were posted": "No se publicaron credenciales de inicio de sesión", "No login credentials were posted": "No se publicaron credenciales de inicio de sesión",
"Credentials are too long": "Las credenciales son demasiado largas" "Credentials are too long": "Las credenciales son demasiado largas",
"Site DevOps": "DevOps del sitio",
"A list of devops nicknames. One per line.": "Una lista de apodos de devops. Uno por línea.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "L'année dernière", "Last year": "L'année dernière",
"Unauthorized": "Non autorisé", "Unauthorized": "Non autorisé",
"No login credentials were posted": "Aucun identifiant de connexion n'a été posté", "No login credentials were posted": "Aucun identifiant de connexion n'a été posté",
"Credentials are too long": "Les identifiants sont trop longs" "Credentials are too long": "Les identifiants sont trop longs",
"Site DevOps": "DevOps du site",
"A list of devops nicknames. One per line.": "Une liste de surnoms de devops. Un par ligne.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Anuraidh", "Last year": "Anuraidh",
"Unauthorized": "Neamhúdaraithe", "Unauthorized": "Neamhúdaraithe",
"No login credentials were posted": "Níor postáladh aon dintiúir logáil isteach", "No login credentials were posted": "Níor postáladh aon dintiúir logáil isteach",
"Credentials are too long": "Tá dintiúir ró-fhada" "Credentials are too long": "Tá dintiúir ró-fhada",
"Site DevOps": "Suíomh DevOps",
"A list of devops nicknames. One per line.": "Tá liosta devops leasainmneacha. Ceann in aghaidh an líne.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "पिछले साल", "Last year": "पिछले साल",
"Unauthorized": "अनधिकृत", "Unauthorized": "अनधिकृत",
"No login credentials were posted": "कोई लॉगिन क्रेडेंशियल पोस्ट नहीं किया गया था", "No login credentials were posted": "कोई लॉगिन क्रेडेंशियल पोस्ट नहीं किया गया था",
"Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं" "Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं",
"Site DevOps": "साइट देवऑप्स",
"A list of devops nicknames. One per line.": "देवोप्स उपनामों की एक सूची। प्रति पंक्ति एक।",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "L'anno scorso", "Last year": "L'anno scorso",
"Unauthorized": "Non autorizzato", "Unauthorized": "Non autorizzato",
"No login credentials were posted": "Non sono state pubblicate credenziali di accesso", "No login credentials were posted": "Non sono state pubblicate credenziali di accesso",
"Credentials are too long": "Le credenziali sono troppo lunghe" "Credentials are too long": "Le credenziali sono troppo lunghe",
"Site DevOps": "Sito DevOps",
"A list of devops nicknames. One per line.": "Un elenco di soprannomi devops. Uno per riga.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "去年", "Last year": "去年",
"Unauthorized": "無許可", "Unauthorized": "無許可",
"No login credentials were posted": "ログイン認証情報が投稿されていません", "No login credentials were posted": "ログイン認証情報が投稿されていません",
"Credentials are too long": "資格情報が長すぎます" "Credentials are too long": "資格情報が長すぎます",
"Site DevOps": "サイト DevOps",
"A list of devops nicknames. One per line.": "DevOps ニックネームのリスト。 1 行に 1 つ。",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "작년", "Last year": "작년",
"Unauthorized": "무단", "Unauthorized": "무단",
"No login credentials were posted": "게시된 로그인 자격 증명이 없습니다.", "No login credentials were posted": "게시된 로그인 자격 증명이 없습니다.",
"Credentials are too long": "자격 증명이 너무 깁니다." "Credentials are too long": "자격 증명이 너무 깁니다.",
"Site DevOps": "사이트 DevOps",
"A list of devops nicknames. One per line.": "데브옵스 닉네임 목록입니다. 한 줄에 하나씩.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Sala borî", "Last year": "Sala borî",
"Unauthorized": "Bêmaf", "Unauthorized": "Bêmaf",
"No login credentials were posted": "Tu pêbaweriyên têketinê nehatin şandin", "No login credentials were posted": "Tu pêbaweriyên têketinê nehatin şandin",
"Credentials are too long": "Bawernameyên pir dirêj in" "Credentials are too long": "Bawernameyên pir dirêj in",
"Site DevOps": "Malpera DevOps",
"A list of devops nicknames. One per line.": "Lîsteya navên devops. Her rêzek yek.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Afgelopen jaar", "Last year": "Afgelopen jaar",
"Unauthorized": "Ongeautoriseerd", "Unauthorized": "Ongeautoriseerd",
"No login credentials were posted": "Er zijn geen inloggegevens gepost", "No login credentials were posted": "Er zijn geen inloggegevens gepost",
"Credentials are too long": "Inloggegevens zijn te lang" "Credentials are too long": "Inloggegevens zijn te lang",
"Site DevOps": "Site DevOps",
"A list of devops nicknames. One per line.": "Een lijst met devops-bijnamen. Een per regel.",
"devops": "devops"
} }

View File

@ -586,5 +586,8 @@
"Last year": "Last year", "Last year": "Last year",
"Unauthorized": "Unauthorized", "Unauthorized": "Unauthorized",
"No login credentials were posted": "No login credentials were posted", "No login credentials were posted": "No login credentials were posted",
"Credentials are too long": "Credentials are too long" "Credentials are too long": "Credentials are too long",
"Site DevOps": "Site DevOps",
"A list of devops nicknames. One per line.": "A list of devops nicknames. One per line.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Ostatni rok", "Last year": "Ostatni rok",
"Unauthorized": "Nieautoryzowany", "Unauthorized": "Nieautoryzowany",
"No login credentials were posted": "Nie opublikowano danych logowania", "No login credentials were posted": "Nie opublikowano danych logowania",
"Credentials are too long": "Poświadczenia są za długie" "Credentials are too long": "Poświadczenia są za długie",
"Site DevOps": "Deweloperzy witryny",
"A list of devops nicknames. One per line.": "Lista pseudonimów Devopa. Jeden na linię.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Ano passado", "Last year": "Ano passado",
"Unauthorized": "Não autorizado", "Unauthorized": "Não autorizado",
"No login credentials were posted": "Nenhuma credencial de login foi postada", "No login credentials were posted": "Nenhuma credencial de login foi postada",
"Credentials are too long": "As credenciais são muito longas" "Credentials are too long": "As credenciais são muito longas",
"Site DevOps": "Site DevOps",
"A list of devops nicknames. One per line.": "Uma lista de apelidos de devops. Um por linha.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Прошедший год", "Last year": "Прошедший год",
"Unauthorized": "Неавторизованный", "Unauthorized": "Неавторизованный",
"No login credentials were posted": "Учетные данные для входа не были отправлены", "No login credentials were posted": "Учетные данные для входа не были отправлены",
"Credentials are too long": "Учетные данные слишком длинные" "Credentials are too long": "Учетные данные слишком длинные",
"Site DevOps": "DevOps сайта",
"A list of devops nicknames. One per line.": "Список псевдонимов devops. По одному на строку.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Mwaka jana", "Last year": "Mwaka jana",
"Unauthorized": "Haijaidhinishwa", "Unauthorized": "Haijaidhinishwa",
"No login credentials were posted": "Hakuna kitambulisho cha kuingia kilichochapishwa", "No login credentials were posted": "Hakuna kitambulisho cha kuingia kilichochapishwa",
"Credentials are too long": "Kitambulisho ni kirefu sana" "Credentials are too long": "Kitambulisho ni kirefu sana",
"Site DevOps": "Tovuti ya DevOps",
"A list of devops nicknames. One per line.": "Orodha ya majina ya utani ya devops. Moja kwa kila mstari.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Geçen yıl", "Last year": "Geçen yıl",
"Unauthorized": "Yetkisiz", "Unauthorized": "Yetkisiz",
"No login credentials were posted": "Giriş bilgileri gönderilmedi", "No login credentials were posted": "Giriş bilgileri gönderilmedi",
"Credentials are too long": "Kimlik bilgileri çok uzun" "Credentials are too long": "Kimlik bilgileri çok uzun",
"Site DevOps": "Site DevOps",
"A list of devops nicknames. One per line.": "Devops takma adlarının listesi. Her satıra bir tane.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "Минулого року", "Last year": "Минулого року",
"Unauthorized": "Несанкціонований", "Unauthorized": "Несанкціонований",
"No login credentials were posted": "Облікові дані для входу не опубліковано", "No login credentials were posted": "Облікові дані для входу не опубліковано",
"Credentials are too long": "Облікові дані задовгі" "Credentials are too long": "Облікові дані задовгі",
"Site DevOps": "Сайт DevOps",
"A list of devops nicknames. One per line.": "Список ніків devops. По одному на рядок.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "לעצטע יאר", "Last year": "לעצטע יאר",
"Unauthorized": "אַנאָטערייזד", "Unauthorized": "אַנאָטערייזד",
"No login credentials were posted": "קיין לאָגין קראַדענטשאַלז זענען אַרייַנגעשיקט", "No login credentials were posted": "קיין לאָגין קראַדענטשאַלז זענען אַרייַנגעשיקט",
"Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג" "Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג",
"Site DevOps": "וועבזייטל DevOps",
"A list of devops nicknames. One per line.": "א רשימה פון דיוואָפּס ניקניימז. איינער פּער שורה.",
"devops": "devops"
} }

View File

@ -590,5 +590,8 @@
"Last year": "去年", "Last year": "去年",
"Unauthorized": "未经授权", "Unauthorized": "未经授权",
"No login credentials were posted": "未发布登录凭据", "No login credentials were posted": "未发布登录凭据",
"Credentials are too long": "凭据太长" "Credentials are too long": "凭据太长",
"Site DevOps": "站点 DevOps",
"A list of devops nicknames. One per line.": "devops 昵称列表。 每行一个。",
"devops": "devops"
} }

View File

@ -133,6 +133,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url += '?autoplay=0' url += '?autoplay=0'
else: else:
url = url.replace('?autoplay=1', '?autoplay=0') url = url.replace('?autoplay=1', '?autoplay=0')
if not url:
continue
content += \ content += \
"<center>\n<span itemprop=\"video\">\n" + \ "<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" " + \ "<iframe loading=\"lazy\" " + \
@ -211,6 +213,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
if '"' not in url: if '"' not in url:
continue continue
url = url.split('"')[0] url = url.split('"')[0]
if not url:
continue
if url.endswith('/trending') or \ if url.endswith('/trending') or \
url.endswith('/home') or \ url.endswith('/home') or \
url.endswith('/overview') or \ url.endswith('/overview') or \

View File

@ -82,6 +82,7 @@ from webapp_timeline import page_number_buttons
from blocking import get_cw_list_variable from blocking import get_cw_list_variable
from blocking import is_blocked from blocking import is_blocked
from content import bold_reading_string from content import bold_reading_string
from roles import is_devops
THEME_FORMATS = '.zip, .gz' THEME_FORMATS = '.zip, .gz'
@ -1531,8 +1532,8 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
with open(counselors_file, 'r', encoding='utf-8') as co_file: with open(counselors_file, 'r', encoding='utf-8') as co_file:
counselors = co_file.read() counselors = co_file.read()
role_assign_str += \ role_assign_str += \
edit_text_area(translate['Counselors'], 'counselors', counselors, edit_text_area('<b>' + translate['Counselors'] + '</b>',
200, '', False) 'counselors', counselors, 200, '', False)
# artists # artists
artists = '' artists = ''
@ -1541,8 +1542,24 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
with open(artists_file, 'r', encoding='utf-8') as art_file: with open(artists_file, 'r', encoding='utf-8') as art_file:
artists = art_file.read() artists = art_file.read()
role_assign_str += \ role_assign_str += \
edit_text_area(translate['Artists'], 'artists', artists, edit_text_area('<b>' + translate['Artists'] + '</b>',
200, '', False) 'artists', artists, 200, '', False)
# site devops
devops = ''
devops_file = base_dir + '/accounts/devops.txt'
if os.path.isfile(devops_file):
with open(devops_file, 'r', encoding='utf-8') as edit_file:
devops = edit_file.read()
role_assign_str += \
' <b><label class="labels">' + \
translate['Site DevOps'] + '</label></b><br>\n' + \
' ' + \
translate['A list of devops nicknames. One per line.'] + \
' <textarea id="message" name="devopslist" placeholder="" ' + \
'style="height:200px" spellcheck="false">' + \
devops + '</textarea>'
role_assign_str += end_edit_section() role_assign_str += end_edit_section()
# Video section # Video section
@ -2420,7 +2437,8 @@ def html_edit_profile(server, translate: {},
media_instance_str, media_instance_str,
blogs_instance_str, blogs_instance_str,
news_instance_str) news_instance_str)
system_monitor_str = _html_system_monitor(nickname, translate) if is_admin or is_devops(base_dir, nickname):
system_monitor_str = _html_system_monitor(nickname, translate)
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
edit_profile_form = \ edit_profile_form = \