mirror of https://gitlab.com/bashrc2/epicyon
Only show libretranslate options to admin account
parent
79b356a374
commit
3136f428d3
|
@ -4438,9 +4438,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['libretranslateUrl'] != \
|
if fields['libretranslateUrl'] != \
|
||||||
currLibretranslateUrl:
|
currLibretranslateUrl:
|
||||||
ltUrl = fields['libretranslateUrl']
|
ltUrl = fields['libretranslateUrl']
|
||||||
setConfigParam(baseDir,
|
if '://' in ltUrl and \
|
||||||
'libretranslateUrl',
|
'.' in ltUrl:
|
||||||
ltUrl)
|
setConfigParam(baseDir,
|
||||||
|
'libretranslateUrl',
|
||||||
|
ltUrl)
|
||||||
else:
|
else:
|
||||||
if currLibretranslateUrl:
|
if currLibretranslateUrl:
|
||||||
setConfigParam(baseDir,
|
setConfigParam(baseDir,
|
||||||
|
|
15
epicyon.py
15
epicyon.py
|
@ -110,6 +110,13 @@ parser = argparse.ArgumentParser(description='ActivityPub Server')
|
||||||
parser.add_argument('--userAgentBlocks', type=str,
|
parser.add_argument('--userAgentBlocks', type=str,
|
||||||
default=None,
|
default=None,
|
||||||
help='List of blocked user agents, separated by commas')
|
help='List of blocked user agents, separated by commas')
|
||||||
|
parser.add_argument('--libretranslate', dest='libretranslateUrl', type=str,
|
||||||
|
default=None,
|
||||||
|
help='URL for LibreTranslate service')
|
||||||
|
parser.add_argument('--libretranslateApiKey',
|
||||||
|
dest='libretranslateApiKey', type=str,
|
||||||
|
default=None,
|
||||||
|
help='API key for LibreTranslate service')
|
||||||
parser.add_argument('-n', '--nickname', dest='nickname', type=str,
|
parser.add_argument('-n', '--nickname', dest='nickname', type=str,
|
||||||
default=None,
|
default=None,
|
||||||
help='Nickname of the account to use')
|
help='Nickname of the account to use')
|
||||||
|
@ -606,6 +613,14 @@ if baseDir.endswith('/'):
|
||||||
print("--path option should not end with '/'")
|
print("--path option should not end with '/'")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
# automatic translations
|
||||||
|
if args.libretranslateUrl:
|
||||||
|
if '://' in args.libretranslateUrl and \
|
||||||
|
'.' in args.libretranslateUrl:
|
||||||
|
setConfigParam(baseDir, 'libretranslateUrl', args.libretranslateUrl)
|
||||||
|
if args.libretranslateApiKey:
|
||||||
|
setConfigParam(baseDir, 'libretranslateApiKey', args.libretranslateApiKey)
|
||||||
|
|
||||||
if args.posts:
|
if args.posts:
|
||||||
if '@' not in args.posts:
|
if '@' not in args.posts:
|
||||||
if '/users/' in args.posts:
|
if '/users/' in args.posts:
|
||||||
|
|
|
@ -1088,7 +1088,7 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
mediaInstanceStr: str,
|
mediaInstanceStr: str,
|
||||||
blogsInstanceStr: str,
|
blogsInstanceStr: str,
|
||||||
newsInstanceStr: str) -> (str, str, str):
|
newsInstanceStr: str) -> (str, str, str, str):
|
||||||
"""Edit profile instance settings
|
"""Edit profile instance settings
|
||||||
"""
|
"""
|
||||||
imageFormats = getImageFormats()
|
imageFormats = getImageFormats()
|
||||||
|
@ -1324,7 +1324,14 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
||||||
YTReplacementDomain + '">\n'
|
YTReplacementDomain + '">\n'
|
||||||
peertubeStr += ' </div></details>\n'
|
peertubeStr += ' </div></details>\n'
|
||||||
|
|
||||||
return instanceStr, roleAssignStr, peertubeStr
|
libretranslateUrl = getConfigParam(baseDir, 'libretranslateUrl')
|
||||||
|
libretranslateApiKey = getConfigParam(baseDir, 'libretranslateApiKey')
|
||||||
|
libretranslateStr = \
|
||||||
|
_htmlEditProfileLibreTranslate(translate,
|
||||||
|
libretranslateUrl,
|
||||||
|
libretranslateApiKey)
|
||||||
|
|
||||||
|
return instanceStr, roleAssignStr, peertubeStr, libretranslateStr
|
||||||
|
|
||||||
|
|
||||||
def _htmlEditProfileDangerZone(translate: {}) -> str:
|
def _htmlEditProfileDangerZone(translate: {}) -> str:
|
||||||
|
@ -2049,6 +2056,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
instanceStr = ''
|
instanceStr = ''
|
||||||
roleAssignStr = ''
|
roleAssignStr = ''
|
||||||
peertubeStr = ''
|
peertubeStr = ''
|
||||||
|
libretranslateStr = ''
|
||||||
|
|
||||||
adminNickname = getConfigParam(baseDir, 'admin')
|
adminNickname = getConfigParam(baseDir, 'admin')
|
||||||
|
|
||||||
|
@ -2058,7 +2066,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
|
|
||||||
if adminNickname:
|
if adminNickname:
|
||||||
if path.startswith('/users/' + adminNickname + '/'):
|
if path.startswith('/users/' + adminNickname + '/'):
|
||||||
instanceStr, roleAssignStr, peertubeStr = \
|
instanceStr, roleAssignStr, peertubeStr, libretranslateStr = \
|
||||||
_htmlEditProfileInstance(baseDir, translate,
|
_htmlEditProfileInstance(baseDir, translate,
|
||||||
peertubeInstances,
|
peertubeInstances,
|
||||||
mediaInstanceStr,
|
mediaInstanceStr,
|
||||||
|
@ -2122,12 +2130,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
editProfileForm += _htmlEditProfileChangePassword(translate)
|
editProfileForm += _htmlEditProfileChangePassword(translate)
|
||||||
|
|
||||||
# automatic translations
|
# automatic translations
|
||||||
libretranslateUrl = getConfigParam(baseDir, 'libretranslateUrl')
|
editProfileForm += libretranslateStr
|
||||||
libretranslateApiKey = getConfigParam(baseDir, 'libretranslateApiKey')
|
|
||||||
editProfileForm += \
|
|
||||||
_htmlEditProfileLibreTranslate(translate,
|
|
||||||
libretranslateUrl,
|
|
||||||
libretranslateApiKey)
|
|
||||||
|
|
||||||
# Filtering and blocking section
|
# Filtering and blocking section
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
|
|
Loading…
Reference in New Issue