mirror of https://gitlab.com/bashrc2/epicyon
Translate login screen
parent
5c44b93fb0
commit
c25b373ee2
17
daemon.py
17
daemon.py
|
@ -898,7 +898,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if self.path.startswith('/login') or self.path=='/':
|
if self.path.startswith('/login') or self.path=='/':
|
||||||
# request basic auth
|
# request basic auth
|
||||||
msg=htmlLogin(self.server.baseDir).encode('utf-8')
|
msg=htmlLogin(self.server.translate,self.server.baseDir).encode('utf-8')
|
||||||
self._login_headers('text/html',len(msg))
|
self._login_headers('text/html',len(msg))
|
||||||
self.wfile.write(msg)
|
self.wfile.write(msg)
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
|
@ -1601,7 +1601,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
maxPostsInFeed, 'inbox', \
|
maxPostsInFeed, 'inbox', \
|
||||||
True,self.server.ocapAlways)
|
True,self.server.ocapAlways)
|
||||||
msg=htmlInbox(pageNumber,maxPostsInFeed, \
|
msg=htmlInbox(self.server.translate, \
|
||||||
|
pageNumber,maxPostsInFeed, \
|
||||||
self.server.session, \
|
self.server.session, \
|
||||||
self.server.baseDir, \
|
self.server.baseDir, \
|
||||||
self.server.cachedWebfingers, \
|
self.server.cachedWebfingers, \
|
||||||
|
@ -1666,7 +1667,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
maxPostsInFeed, 'dm', \
|
maxPostsInFeed, 'dm', \
|
||||||
True,self.server.ocapAlways)
|
True,self.server.ocapAlways)
|
||||||
msg=htmlInboxDMs(pageNumber,maxPostsInFeed, \
|
msg=htmlInboxDMs(self.server.translate, \
|
||||||
|
pageNumber,maxPostsInFeed, \
|
||||||
self.server.session, \
|
self.server.session, \
|
||||||
self.server.baseDir, \
|
self.server.baseDir, \
|
||||||
self.server.cachedWebfingers, \
|
self.server.cachedWebfingers, \
|
||||||
|
@ -1726,7 +1728,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
maxPostsInFeed, 'outbox', \
|
maxPostsInFeed, 'outbox', \
|
||||||
authorized, \
|
authorized, \
|
||||||
self.server.ocapAlways)
|
self.server.ocapAlways)
|
||||||
msg=htmlOutbox(pageNumber,maxPostsInFeed, \
|
msg=htmlOutbox(self.server.translate, \
|
||||||
|
pageNumber,maxPostsInFeed, \
|
||||||
self.server.session, \
|
self.server.session, \
|
||||||
self.server.baseDir, \
|
self.server.baseDir, \
|
||||||
self.server.cachedWebfingers, \
|
self.server.cachedWebfingers, \
|
||||||
|
@ -1780,7 +1783,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
maxPostsInFeed, 'moderation', \
|
maxPostsInFeed, 'moderation', \
|
||||||
True,self.server.ocapAlways)
|
True,self.server.ocapAlways)
|
||||||
msg=htmlModeration(pageNumber,maxPostsInFeed, \
|
msg=htmlModeration(self.server.translate, \
|
||||||
|
pageNumber,maxPostsInFeed, \
|
||||||
self.server.session, \
|
self.server.session, \
|
||||||
self.server.baseDir, \
|
self.server.baseDir, \
|
||||||
self.server.cachedWebfingers, \
|
self.server.cachedWebfingers, \
|
||||||
|
@ -2656,7 +2660,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
moderationText=moderationStr.split('=')[1].strip()
|
moderationText=moderationStr.split('=')[1].strip()
|
||||||
moderationText=moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
|
moderationText=moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
|
||||||
elif moderationStr.startswith('submitInfo'):
|
elif moderationStr.startswith('submitInfo'):
|
||||||
msg=htmlModerationInfo(self.server.baseDir).encode('utf-8')
|
msg=htmlModerationInfo(self.server.translate, \
|
||||||
|
self.server.baseDir).encode('utf-8')
|
||||||
self._login_headers('text/html',len(msg))
|
self._login_headers('text/html',len(msg))
|
||||||
self.wfile.write(msg)
|
self.wfile.write(msg)
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
|
|
|
@ -90,5 +90,21 @@
|
||||||
"Stop blocking": "Stop blocking",
|
"Stop blocking": "Stop blocking",
|
||||||
"Enter an emoji name to search for": "Enter an emoji name to search for",
|
"Enter an emoji name to search for": "Enter an emoji name to search for",
|
||||||
"Enter an address, shared item, #hashtag, *skill or :emoji: to search for": "Enter an address, shared item, #hashtag, *skill or :emoji: to search for",
|
"Enter an address, shared item, #hashtag, *skill or :emoji: to search for": "Enter an address, shared item, #hashtag, *skill or :emoji: to search for",
|
||||||
"Go Back": "Go Back"
|
"Go Back": "Go Back",
|
||||||
|
"Moderation Information": "Moderation Information",
|
||||||
|
"Suspended accounts": "Suspended accounts",
|
||||||
|
"These are currently suspended": "These are currently suspended",
|
||||||
|
"Blocked accounts and hashtags": "Blocked accounts and hashtags",
|
||||||
|
"These are globally blocked for all accounts on this instance": "These are globally blocked for all accounts on this instance",
|
||||||
|
"Any blocks or suspensions made by moderators will be shown here.": "Any blocks or suspensions made by moderators will be shown here.",
|
||||||
|
"Welcome. Please enter your login details below.": "Welcome. Please enter your login details below.",
|
||||||
|
"Welcome. Please login or register a new account.": "Welcome. Please login or register a new account.",
|
||||||
|
"Please enter some credentials": "Please enter some credentials",
|
||||||
|
"You will become the admin of this site.": "You will become the admin of this site.",
|
||||||
|
"Terms of Service": "Terms of Service",
|
||||||
|
"About this Instance": "About this Instance",
|
||||||
|
"Nickname": "Nickname",
|
||||||
|
"Enter Nickname": "Enter Nickname",
|
||||||
|
"Password": "Password",
|
||||||
|
"Enter Password": "Enter Password"
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,5 +90,21 @@
|
||||||
"Stop blocking": "Arrêtez le blocage",
|
"Stop blocking": "Arrêtez le blocage",
|
||||||
"Enter an emoji name to search for": "Entrez un nom emoji à rechercher",
|
"Enter an emoji name to search for": "Entrez un nom emoji à rechercher",
|
||||||
"Enter an address, shared item, #hashtag, *skill or :emoji: to search for": "Entrez une adresse, un objet partagé, #hashtag, * skill ou: emoji: à rechercher",
|
"Enter an address, shared item, #hashtag, *skill or :emoji: to search for": "Entrez une adresse, un objet partagé, #hashtag, * skill ou: emoji: à rechercher",
|
||||||
"Go Back": "Retourner"
|
"Go Back": "Retourner",
|
||||||
|
"Moderation Information": "Informations de modération",
|
||||||
|
"Suspended accounts": "Comptes suspendus",
|
||||||
|
"These are currently suspended": "Ceux-ci sont actuellement suspendus",
|
||||||
|
"Blocked accounts and hashtags": "Comptes bloqués et hashtags",
|
||||||
|
"These are globally blocked for all accounts on this instance": "Ceux-ci sont globalement bloqués pour tous les comptes sur cette instance.",
|
||||||
|
"Any blocks or suspensions made by moderators will be shown here.": "Tous les blocages ou suspensions réalisés par les modérateurs seront affichés ici.",
|
||||||
|
"Welcome. Please enter your login details below.": "Bienvenue. S'il vous plaît entrer vos informations de connexion ci-dessous.",
|
||||||
|
"Welcome. Please login or register a new account.": "Bienvenue. Veuillez vous connecter ou créer un nouveau compte.",
|
||||||
|
"Please enter some credentials": "S'il vous plaît entrer des informations d'identification",
|
||||||
|
"You will become the admin of this site.": "Vous allez devenir l'administrateur de ce site.",
|
||||||
|
"Terms of Service": "Conditions d'utilisation",
|
||||||
|
"About this Instance": "A propos de cette instance",
|
||||||
|
"Nickname": "Pseudo",
|
||||||
|
"Enter Nickname": "Entrez le pseudo",
|
||||||
|
"Password": "Mot de passe",
|
||||||
|
"Enter Password": "Entrer le mot de passe"
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,13 +184,13 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str, \
|
||||||
sharedItemsForm+=htmlFooter()
|
sharedItemsForm+=htmlFooter()
|
||||||
return sharedItemsForm
|
return sharedItemsForm
|
||||||
|
|
||||||
def htmlModerationInfo(baseDir: str) -> str:
|
def htmlModerationInfo(translate: {},baseDir: str) -> str:
|
||||||
infoForm=''
|
infoForm=''
|
||||||
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
||||||
infoCSS=cssFile.read()
|
infoCSS=cssFile.read()
|
||||||
infoForm=htmlHeader(infoCSS)
|
infoForm=htmlHeader(infoCSS)
|
||||||
|
|
||||||
infoForm+='<center><h1>Moderation Information</h1></center>'
|
infoForm+='<center><h1>'+translate['Moderation Information']+'</h1></center>'
|
||||||
|
|
||||||
infoShown=False
|
infoShown=False
|
||||||
suspendedFilename=baseDir+'/accounts/suspended.txt'
|
suspendedFilename=baseDir+'/accounts/suspended.txt'
|
||||||
|
@ -199,8 +199,8 @@ def htmlModerationInfo(baseDir: str) -> str:
|
||||||
suspendedStr = f.read()
|
suspendedStr = f.read()
|
||||||
infoForm+= \
|
infoForm+= \
|
||||||
'<div class="container">' \
|
'<div class="container">' \
|
||||||
' <br><b>Suspended accounts</b>' \
|
' <br><b>'+translate['Suspended accounts']+'</b>' \
|
||||||
' <br>These are currently suspended' \
|
' <br>'+translate['These are currently suspended']+ \
|
||||||
' <textarea id="message" name="suspended" style="height:200px">'+suspendedStr+'</textarea>' \
|
' <textarea id="message" name="suspended" style="height:200px">'+suspendedStr+'</textarea>' \
|
||||||
'</div>'
|
'</div>'
|
||||||
infoShown=True
|
infoShown=True
|
||||||
|
@ -211,13 +211,13 @@ def htmlModerationInfo(baseDir: str) -> str:
|
||||||
blockedStr = f.read()
|
blockedStr = f.read()
|
||||||
infoForm+= \
|
infoForm+= \
|
||||||
'<div class="container">' \
|
'<div class="container">' \
|
||||||
' <br><b>Blocked accounts and hashtags</b>' \
|
' <br><b>'+translate['Blocked accounts and hashtags']+'</b>' \
|
||||||
' <br>These are globally blocked for all accounts on this instance' \
|
' <br>'+translate['These are globally blocked for all accounts on this instance']+ \
|
||||||
' <textarea id="message" name="blocked" style="height:200px">'+blockedStr+'</textarea>' \
|
' <textarea id="message" name="blocked" style="height:200px">'+blockedStr+'</textarea>' \
|
||||||
'</div>'
|
'</div>'
|
||||||
infoShown=True
|
infoShown=True
|
||||||
if not infoShown:
|
if not infoShown:
|
||||||
infoForm+='<center><p>Any blocks or suspensions made by moderators will be shown here.</p></center>'
|
infoForm+='<center><p>'+translate['Any blocks or suspensions made by moderators will be shown here.']+'</p></center>'
|
||||||
infoForm+=htmlFooter()
|
infoForm+=htmlFooter()
|
||||||
return infoForm
|
return infoForm
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ def htmlGetLoginCredentials(loginParams: str,lastLoginTime: int) -> (str,str,boo
|
||||||
register=True
|
register=True
|
||||||
return nickname,password,register
|
return nickname,password,register
|
||||||
|
|
||||||
def htmlLogin(baseDir: str) -> str:
|
def htmlLogin(translate: {},baseDir: str) -> str:
|
||||||
"""Shows the login screen
|
"""Shows the login screen
|
||||||
"""
|
"""
|
||||||
accounts=noOfAccounts(baseDir)
|
accounts=noOfAccounts(baseDir)
|
||||||
|
@ -554,9 +554,10 @@ def htmlLogin(baseDir: str) -> str:
|
||||||
copyfile(baseDir+'/img/login-background.png',baseDir+'/accounts/login-background.png')
|
copyfile(baseDir+'/img/login-background.png',baseDir+'/accounts/login-background.png')
|
||||||
|
|
||||||
if accounts>0:
|
if accounts>0:
|
||||||
loginText='<p class="login-text">Welcome. Please enter your login details below.</p>'
|
loginText='<p class="login-text">'+translate['Welcome. Please enter your login details below.']+'</p>'
|
||||||
else:
|
else:
|
||||||
loginText='<p class="login-text">Please enter some credentials</p><p>You will become the admin of this site.</p>'
|
loginText='<p class="login-text">'+translate['Please enter some credentials']+'</p>'
|
||||||
|
loginText+='<p class="login-text">'+translate['You will become the admin of this site.']+'</p>'
|
||||||
if os.path.isfile(baseDir+'/accounts/login.txt'):
|
if os.path.isfile(baseDir+'/accounts/login.txt'):
|
||||||
# custom login message
|
# custom login message
|
||||||
with open(baseDir+'/accounts/login.txt', 'r') as file:
|
with open(baseDir+'/accounts/login.txt', 'r') as file:
|
||||||
|
@ -570,15 +571,15 @@ def htmlLogin(baseDir: str) -> str:
|
||||||
if getConfigParam(baseDir,'registration')=='open':
|
if getConfigParam(baseDir,'registration')=='open':
|
||||||
if int(getConfigParam(baseDir,'registrationsRemaining'))>0:
|
if int(getConfigParam(baseDir,'registrationsRemaining'))>0:
|
||||||
if accounts>0:
|
if accounts>0:
|
||||||
loginText='<p class="login-text">Welcome. Please login or register a new account.</p>'
|
loginText='<p class="login-text">'+translate['Welcome. Please login or register a new account.']+'</p>'
|
||||||
registerButtonStr='<button type="submit" name="register">Register</button>'
|
registerButtonStr='<button type="submit" name="register">Register</button>'
|
||||||
|
|
||||||
TOSstr='<p class="login-text"><a href="/terms">Terms of Service</a></p>'
|
TOSstr='<p class="login-text"><a href="/terms">'+translate['Terms of Service']+'</a></p>'
|
||||||
TOSstr+='<p class="login-text"><a href="/about">About this Instance</a></p>'
|
TOSstr+='<p class="login-text"><a href="/about">'+translate['About this Instance']+'</a></p>'
|
||||||
|
|
||||||
loginButtonStr=''
|
loginButtonStr=''
|
||||||
if accounts>0:
|
if accounts>0:
|
||||||
loginButtonStr='<button type="submit" name="submit">Login</button>'
|
loginButtonStr='<button type="submit" name="submit">'+translate['Login']+'</button>'
|
||||||
|
|
||||||
loginForm=htmlHeader(loginCSS)
|
loginForm=htmlHeader(loginCSS)
|
||||||
loginForm+= \
|
loginForm+= \
|
||||||
|
@ -589,11 +590,11 @@ def htmlLogin(baseDir: str) -> str:
|
||||||
' </div>' \
|
' </div>' \
|
||||||
'' \
|
'' \
|
||||||
' <div class="container">' \
|
' <div class="container">' \
|
||||||
' <label for="nickname"><b>Nickname</b></label>' \
|
' <label for="nickname"><b>'+translate['Nickname']+'</b></label>' \
|
||||||
' <input type="text" placeholder="Enter Nickname" name="username" required autofocus>' \
|
' <input type="text" placeholder="'+translate['Enter Nickname']+'" name="username" required autofocus>' \
|
||||||
'' \
|
'' \
|
||||||
' <label for="password"><b>Password</b></label>' \
|
' <label for="password"><b>'+translate['Password']+'</b></label>' \
|
||||||
' <input type="password" placeholder="Enter Password" name="password" required>'+ \
|
' <input type="password" placeholder="'+translate['Enter Password']+'" name="password" required>'+ \
|
||||||
registerButtonStr+loginButtonStr+ \
|
registerButtonStr+loginButtonStr+ \
|
||||||
' </div>' \
|
' </div>' \
|
||||||
'</form>'
|
'</form>'
|
||||||
|
@ -1895,7 +1896,7 @@ def htmlTimeline(translate: {},pageNumber: int, \
|
||||||
tlStr+=htmlFooter()
|
tlStr+=htmlFooter()
|
||||||
return tlStr
|
return tlStr
|
||||||
|
|
||||||
def htmlInbox(pageNumber: int,itemsPerPage: int, \
|
def htmlInbox(translate: {},pageNumber: int,itemsPerPage: int, \
|
||||||
session,baseDir: str,wfRequest: {},personCache: {}, \
|
session,baseDir: str,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int,inboxJson: {}, \
|
nickname: str,domain: str,port: int,inboxJson: {}, \
|
||||||
allowDeletion: bool, \
|
allowDeletion: bool, \
|
||||||
|
@ -1905,33 +1906,36 @@ def htmlInbox(pageNumber: int,itemsPerPage: int, \
|
||||||
manuallyApproveFollowers= \
|
manuallyApproveFollowers= \
|
||||||
followerApprovalActive(baseDir,nickname,domain)
|
followerApprovalActive(baseDir,nickname,domain)
|
||||||
|
|
||||||
return htmlTimeline(pageNumber,itemsPerPage,session,baseDir,wfRequest,personCache, \
|
return htmlTimeline(translate,pageNumber, \
|
||||||
|
itemsPerPage,session,baseDir,wfRequest,personCache, \
|
||||||
nickname,domain,port,inboxJson,'inbox',allowDeletion, \
|
nickname,domain,port,inboxJson,'inbox',allowDeletion, \
|
||||||
httpPrefix,projectVersion,manuallyApproveFollowers)
|
httpPrefix,projectVersion,manuallyApproveFollowers)
|
||||||
|
|
||||||
def htmlInboxDMs(pageNumber: int,itemsPerPage: int, \
|
def htmlInboxDMs(translate: {},pageNumber: int,itemsPerPage: int, \
|
||||||
session,baseDir: str,wfRequest: {},personCache: {}, \
|
session,baseDir: str,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int,inboxJson: {}, \
|
nickname: str,domain: str,port: int,inboxJson: {}, \
|
||||||
allowDeletion: bool, \
|
allowDeletion: bool, \
|
||||||
httpPrefix: str,projectVersion: str) -> str:
|
httpPrefix: str,projectVersion: str) -> str:
|
||||||
"""Show the DM timeline as html
|
"""Show the DM timeline as html
|
||||||
"""
|
"""
|
||||||
return htmlTimeline(pageNumber,itemsPerPage,session,baseDir,wfRequest,personCache, \
|
return htmlTimeline(translate,pageNumber, \
|
||||||
|
itemsPerPage,session,baseDir,wfRequest,personCache, \
|
||||||
nickname,domain,port,inboxJson,'dm',allowDeletion, \
|
nickname,domain,port,inboxJson,'dm',allowDeletion, \
|
||||||
httpPrefix,projectVersion,False)
|
httpPrefix,projectVersion,False)
|
||||||
|
|
||||||
def htmlModeration(pageNumber: int,itemsPerPage: int, \
|
def htmlModeration(translate: {},pageNumber: int,itemsPerPage: int, \
|
||||||
session,baseDir: str,wfRequest: {},personCache: {}, \
|
session,baseDir: str,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int,inboxJson: {}, \
|
nickname: str,domain: str,port: int,inboxJson: {}, \
|
||||||
allowDeletion: bool, \
|
allowDeletion: bool, \
|
||||||
httpPrefix: str,projectVersion: str) -> str:
|
httpPrefix: str,projectVersion: str) -> str:
|
||||||
"""Show the moderation feed as html
|
"""Show the moderation feed as html
|
||||||
"""
|
"""
|
||||||
return htmlTimeline(pageNumber,itemsPerPage,session,baseDir,wfRequest,personCache, \
|
return htmlTimeline(translate,pageNumber, \
|
||||||
|
itemsPerPage,session,baseDir,wfRequest,personCache, \
|
||||||
nickname,domain,port,inboxJson,'moderation',allowDeletion, \
|
nickname,domain,port,inboxJson,'moderation',allowDeletion, \
|
||||||
httpPrefix,projectVersion,True)
|
httpPrefix,projectVersion,True)
|
||||||
|
|
||||||
def htmlOutbox(pageNumber: int,itemsPerPage: int, \
|
def htmlOutbox(translate: {},pageNumber: int,itemsPerPage: int, \
|
||||||
session,baseDir: str,wfRequest: {},personCache: {}, \
|
session,baseDir: str,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int,outboxJson: {}, \
|
nickname: str,domain: str,port: int,outboxJson: {}, \
|
||||||
allowDeletion: bool,
|
allowDeletion: bool,
|
||||||
|
@ -1940,7 +1944,8 @@ def htmlOutbox(pageNumber: int,itemsPerPage: int, \
|
||||||
"""
|
"""
|
||||||
manuallyApproveFollowers= \
|
manuallyApproveFollowers= \
|
||||||
followerApprovalActive(baseDir,nickname,domain)
|
followerApprovalActive(baseDir,nickname,domain)
|
||||||
return htmlTimeline(pageNumber,itemsPerPage,session,baseDir,wfRequest,personCache, \
|
return htmlTimeline(translate,pageNumber, \
|
||||||
|
itemsPerPage,session,baseDir,wfRequest,personCache, \
|
||||||
nickname,domain,port,outboxJson,'outbox',allowDeletion, \
|
nickname,domain,port,outboxJson,'outbox',allowDeletion, \
|
||||||
httpPrefix,projectVersion,manuallyApproveFollowers)
|
httpPrefix,projectVersion,manuallyApproveFollowers)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue