mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
a2b11135f3
commit
8b9a53c304
62
daemon.py
62
daemon.py
|
@ -587,7 +587,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if agentStr:
|
if agentStr:
|
||||||
# is this a web crawler? If so the block it
|
# is this a web crawler? If so the block it
|
||||||
if 'bot/' in agentStrLower or 'bot-' in agentStrLower:
|
if 'bot/' in agentStrLower or 'bot-' in agentStrLower:
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
return False
|
return False
|
||||||
print('Blocked Crawler: ' + agentStr)
|
print('Blocked Crawler: ' + agentStr)
|
||||||
return True
|
return True
|
||||||
|
@ -4561,7 +4561,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('WARN: nickname not found in ' + actorStr)
|
print('WARN: nickname not found in ' + actorStr)
|
||||||
else:
|
else:
|
||||||
print('WARN: nickname is not an editor' + actorStr)
|
print('WARN: nickname is not an editor' + actorStr)
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
self._redirect_headers(actorStr + '/tlfeatures',
|
self._redirect_headers(actorStr + '/tlfeatures',
|
||||||
cookie, callingDomain)
|
cookie, callingDomain)
|
||||||
else:
|
else:
|
||||||
|
@ -4575,7 +4575,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# check that the POST isn't too large
|
# check that the POST isn't too large
|
||||||
if length > self.server.maxPostLength:
|
if length > self.server.maxPostLength:
|
||||||
print('Maximum news data length exceeded ' + str(length))
|
print('Maximum news data length exceeded ' + str(length))
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
self._redirect_headers(actorStr + '/tlfeatures',
|
self._redirect_headers(actorStr + '/tlfeatures',
|
||||||
cookie, callingDomain)
|
cookie, callingDomain)
|
||||||
else:
|
else:
|
||||||
|
@ -4661,7 +4661,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
self._redirect_headers(actorStr + '/tlfeatures',
|
self._redirect_headers(actorStr + '/tlfeatures',
|
||||||
cookie, callingDomain)
|
cookie, callingDomain)
|
||||||
else:
|
else:
|
||||||
|
@ -5045,7 +5045,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['mediaInstance'] == 'on':
|
if fields['mediaInstance'] == 'on':
|
||||||
self.server.mediaInstance = True
|
self.server.mediaInstance = True
|
||||||
self.server.blogsInstance = False
|
self.server.blogsInstance = False
|
||||||
self.server.newsInstance = False
|
self.server.news_instance = False
|
||||||
self.server.defaultTimeline = 'tlmedia'
|
self.server.defaultTimeline = 'tlmedia'
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"mediaInstance",
|
"mediaInstance",
|
||||||
|
@ -5054,8 +5054,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"blogsInstance",
|
"blogsInstance",
|
||||||
self.server.blogsInstance)
|
self.server.blogsInstance)
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"newsInstance",
|
"news_instance",
|
||||||
self.server.newsInstance)
|
self.server.news_instance)
|
||||||
else:
|
else:
|
||||||
if self.server.mediaInstance:
|
if self.server.mediaInstance:
|
||||||
self.server.mediaInstance = False
|
self.server.mediaInstance = False
|
||||||
|
@ -5067,14 +5067,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# is this a news theme?
|
# is this a news theme?
|
||||||
if isNewsThemeName(self.server.base_dir,
|
if isNewsThemeName(self.server.base_dir,
|
||||||
self.server.themeName):
|
self.server.themeName):
|
||||||
fields['newsInstance'] = 'on'
|
fields['news_instance'] = 'on'
|
||||||
|
|
||||||
# change news instance status
|
# change news instance status
|
||||||
if fields.get('newsInstance'):
|
if fields.get('news_instance'):
|
||||||
self.server.newsInstance = False
|
self.server.news_instance = False
|
||||||
self.server.defaultTimeline = 'inbox'
|
self.server.defaultTimeline = 'inbox'
|
||||||
if fields['newsInstance'] == 'on':
|
if fields['news_instance'] == 'on':
|
||||||
self.server.newsInstance = True
|
self.server.news_instance = True
|
||||||
self.server.blogsInstance = False
|
self.server.blogsInstance = False
|
||||||
self.server.mediaInstance = False
|
self.server.mediaInstance = False
|
||||||
self.server.defaultTimeline = 'tlfeatures'
|
self.server.defaultTimeline = 'tlfeatures'
|
||||||
|
@ -5085,14 +5085,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"blogsInstance",
|
"blogsInstance",
|
||||||
self.server.blogsInstance)
|
self.server.blogsInstance)
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"newsInstance",
|
"news_instance",
|
||||||
self.server.newsInstance)
|
self.server.news_instance)
|
||||||
else:
|
else:
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
self.server.newsInstance = False
|
self.server.news_instance = False
|
||||||
self.server.defaultTimeline = 'inbox'
|
self.server.defaultTimeline = 'inbox'
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"newsInstance",
|
"news_instance",
|
||||||
self.server.mediaInstance)
|
self.server.mediaInstance)
|
||||||
|
|
||||||
# change blog instance status
|
# change blog instance status
|
||||||
|
@ -5102,7 +5102,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['blogsInstance'] == 'on':
|
if fields['blogsInstance'] == 'on':
|
||||||
self.server.blogsInstance = True
|
self.server.blogsInstance = True
|
||||||
self.server.mediaInstance = False
|
self.server.mediaInstance = False
|
||||||
self.server.newsInstance = False
|
self.server.news_instance = False
|
||||||
self.server.defaultTimeline = 'tlblogs'
|
self.server.defaultTimeline = 'tlblogs'
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"blogsInstance",
|
"blogsInstance",
|
||||||
|
@ -5111,8 +5111,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"mediaInstance",
|
"mediaInstance",
|
||||||
self.server.mediaInstance)
|
self.server.mediaInstance)
|
||||||
setConfigParam(base_dir,
|
setConfigParam(base_dir,
|
||||||
"newsInstance",
|
"news_instance",
|
||||||
self.server.newsInstance)
|
self.server.news_instance)
|
||||||
else:
|
else:
|
||||||
if self.server.blogsInstance:
|
if self.server.blogsInstance:
|
||||||
self.server.blogsInstance = False
|
self.server.blogsInstance = False
|
||||||
|
@ -7166,7 +7166,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
lockedAccount,
|
lockedAccount,
|
||||||
movedTo, alsoKnownAs,
|
movedTo, alsoKnownAs,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
self.server.newsInstance,
|
self.server.news_instance,
|
||||||
authorized,
|
authorized,
|
||||||
accessKeys, isGroup).encode('utf-8')
|
accessKeys, isGroup).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -12432,7 +12432,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if divertToLoginScreen and not authorized:
|
if divertToLoginScreen and not authorized:
|
||||||
divertPath = '/login'
|
divertPath = '/login'
|
||||||
if self.server.newsInstance:
|
if self.server.news_instance:
|
||||||
# for news instances if not logged in then show the
|
# for news instances if not logged in then show the
|
||||||
# front page
|
# front page
|
||||||
divertPath = '/users/news'
|
divertPath = '/users/news'
|
||||||
|
@ -13344,7 +13344,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
if self.path == '/logout':
|
if self.path == '/logout':
|
||||||
if not self.server.newsInstance:
|
if not self.server.news_instance:
|
||||||
msg = \
|
msg = \
|
||||||
htmlLogin(self.server.cssCache,
|
htmlLogin(self.server.cssCache,
|
||||||
self.server.translate,
|
self.server.translate,
|
||||||
|
@ -14899,7 +14899,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if (self.path.startswith('/login') or
|
if (self.path.startswith('/login') or
|
||||||
(self.path == '/' and
|
(self.path == '/' and
|
||||||
not authorized and
|
not authorized and
|
||||||
not self.server.newsInstance)):
|
not self.server.news_instance)):
|
||||||
# request basic auth
|
# request basic auth
|
||||||
msg = htmlLogin(self.server.cssCache,
|
msg = htmlLogin(self.server.cssCache,
|
||||||
self.server.translate,
|
self.server.translate,
|
||||||
|
@ -14920,7 +14920,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# show the news front page
|
# show the news front page
|
||||||
if self.path == '/' and \
|
if self.path == '/' and \
|
||||||
not authorized and \
|
not authorized and \
|
||||||
self.server.newsInstance:
|
self.server.news_instance:
|
||||||
if callingDomain.endswith('.onion') and \
|
if callingDomain.endswith('.onion') and \
|
||||||
self.server.onionDomain:
|
self.server.onionDomain:
|
||||||
self._logout_redirect('http://' +
|
self._logout_redirect('http://' +
|
||||||
|
@ -14955,7 +14955,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if (authorized or
|
if (authorized or
|
||||||
(not authorized and
|
(not authorized and
|
||||||
self.path.startswith('/users/news/') and
|
self.path.startswith('/users/news/') and
|
||||||
self.server.newsInstance)):
|
self.server.news_instance)):
|
||||||
nickname = getNicknameFromActor(self.path)
|
nickname = getNicknameFromActor(self.path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
self._404()
|
self._404()
|
||||||
|
@ -14999,7 +14999,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if (authorized or
|
if (authorized or
|
||||||
(not authorized and
|
(not authorized and
|
||||||
self.path.startswith('/users/news/') and
|
self.path.startswith('/users/news/') and
|
||||||
self.server.newsInstance)):
|
self.server.news_instance)):
|
||||||
nickname = getNicknameFromActor(self.path)
|
nickname = getNicknameFromActor(self.path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
self._404()
|
self._404()
|
||||||
|
@ -18449,7 +18449,7 @@ def runDaemon(content_license_url: str,
|
||||||
voting_time_mins: int,
|
voting_time_mins: int,
|
||||||
positive_voting: bool,
|
positive_voting: bool,
|
||||||
newswire_votes_threshold: int,
|
newswire_votes_threshold: int,
|
||||||
newsInstance: bool,
|
news_instance: bool,
|
||||||
blogsInstance: bool,
|
blogsInstance: bool,
|
||||||
mediaInstance: bool,
|
mediaInstance: bool,
|
||||||
maxRecentPosts: int,
|
maxRecentPosts: int,
|
||||||
|
@ -18803,15 +18803,15 @@ def runDaemon(content_license_url: str,
|
||||||
if not httpd.themeName:
|
if not httpd.themeName:
|
||||||
httpd.themeName = 'default'
|
httpd.themeName = 'default'
|
||||||
if isNewsThemeName(base_dir, httpd.themeName):
|
if isNewsThemeName(base_dir, httpd.themeName):
|
||||||
newsInstance = True
|
news_instance = True
|
||||||
|
|
||||||
httpd.newsInstance = newsInstance
|
httpd.news_instance = news_instance
|
||||||
httpd.defaultTimeline = 'inbox'
|
httpd.defaultTimeline = 'inbox'
|
||||||
if mediaInstance:
|
if mediaInstance:
|
||||||
httpd.defaultTimeline = 'tlmedia'
|
httpd.defaultTimeline = 'tlmedia'
|
||||||
if blogsInstance:
|
if blogsInstance:
|
||||||
httpd.defaultTimeline = 'tlblogs'
|
httpd.defaultTimeline = 'tlblogs'
|
||||||
if newsInstance:
|
if news_instance:
|
||||||
httpd.defaultTimeline = 'tlfeatures'
|
httpd.defaultTimeline = 'tlfeatures'
|
||||||
|
|
||||||
setNewsAvatar(base_dir,
|
setNewsAvatar(base_dir,
|
||||||
|
|
|
@ -1006,9 +1006,9 @@ if not args.mediainstance:
|
||||||
args.newsinstance = False
|
args.newsinstance = False
|
||||||
|
|
||||||
if not args.newsinstance:
|
if not args.newsinstance:
|
||||||
newsInstance = getConfigParam(base_dir, 'newsInstance')
|
news_instance = getConfigParam(base_dir, 'news_instance')
|
||||||
if newsInstance is not None:
|
if news_instance is not None:
|
||||||
args.newsinstance = newsInstance
|
args.newsinstance = news_instance
|
||||||
if args.newsinstance:
|
if args.newsinstance:
|
||||||
args.blogsinstance = False
|
args.blogsinstance = False
|
||||||
args.mediainstance = False
|
args.mediainstance = False
|
||||||
|
|
|
@ -59,7 +59,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
movedTo: str,
|
movedTo: str,
|
||||||
alsoKnownAs: [],
|
alsoKnownAs: [],
|
||||||
textModeBanner: str,
|
textModeBanner: str,
|
||||||
newsInstance: bool,
|
news_instance: bool,
|
||||||
authorized: bool,
|
authorized: bool,
|
||||||
accessKeys: {},
|
accessKeys: {},
|
||||||
isGroup: bool) -> str:
|
isGroup: bool) -> str:
|
||||||
|
@ -329,7 +329,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
optionsStr += checkboxStr
|
optionsStr += checkboxStr
|
||||||
|
|
||||||
# checkbox for permission to post to featured articles
|
# checkbox for permission to post to featured articles
|
||||||
if newsInstance and optionsDomainFull == domainFull:
|
if news_instance and optionsDomainFull == domainFull:
|
||||||
adminNickname = getConfigParam(base_dir, 'admin')
|
adminNickname = getConfigParam(base_dir, 'admin')
|
||||||
if (nickname == adminNickname or
|
if (nickname == adminNickname or
|
||||||
(isModerator(base_dir, nickname) and
|
(isModerator(base_dir, nickname) and
|
||||||
|
|
|
@ -1298,7 +1298,7 @@ def _htmlEditProfileInstance(base_dir: str, translate: {},
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
mediaInstanceStr: str,
|
mediaInstanceStr: str,
|
||||||
blogsInstanceStr: str,
|
blogsInstanceStr: str,
|
||||||
newsInstanceStr: str) -> (str, str, str, str):
|
news_instanceStr: str) -> (str, str, str, str):
|
||||||
"""Edit profile instance settings
|
"""Edit profile instance settings
|
||||||
"""
|
"""
|
||||||
imageFormats = getImageFormats()
|
imageFormats = getImageFormats()
|
||||||
|
@ -1393,7 +1393,7 @@ def _htmlEditProfileInstance(base_dir: str, translate: {},
|
||||||
'blogsInstance', blogsInstanceStr)
|
'blogsInstance', blogsInstanceStr)
|
||||||
instanceStr += \
|
instanceStr += \
|
||||||
editCheckBox(translate['This is a news instance'],
|
editCheckBox(translate['This is a news instance'],
|
||||||
'newsInstance', newsInstanceStr)
|
'news_instance', news_instanceStr)
|
||||||
|
|
||||||
instanceStr += endEditSection()
|
instanceStr += endEditSection()
|
||||||
|
|
||||||
|
@ -1822,7 +1822,7 @@ def _htmlEditProfileLibreTranslate(translate: {},
|
||||||
return editProfileForm
|
return editProfileForm
|
||||||
|
|
||||||
|
|
||||||
def _htmlEditProfileBackground(newsInstance: bool, translate: {}) -> str:
|
def _htmlEditProfileBackground(news_instance: bool, translate: {}) -> str:
|
||||||
"""Background images section of edit profile screen
|
"""Background images section of edit profile screen
|
||||||
"""
|
"""
|
||||||
idx = 'The files attached below should be no larger than ' + \
|
idx = 'The files attached below should be no larger than ' + \
|
||||||
|
@ -1831,7 +1831,7 @@ def _htmlEditProfileBackground(newsInstance: bool, translate: {}) -> str:
|
||||||
beginEditSection(translate['Background Images']) + \
|
beginEditSection(translate['Background Images']) + \
|
||||||
' <label class="labels">' + translate[idx] + '</label><br><br>\n'
|
' <label class="labels">' + translate[idx] + '</label><br><br>\n'
|
||||||
|
|
||||||
if not newsInstance:
|
if not news_instance:
|
||||||
imageFormats = getImageFormats()
|
imageFormats = getImageFormats()
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
' <label class="labels">' + \
|
' <label class="labels">' + \
|
||||||
|
@ -2113,7 +2113,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
isBot = isGroup = followDMs = removeTwitter = ''
|
isBot = isGroup = followDMs = removeTwitter = ''
|
||||||
notifyLikes = notifyReactions = ''
|
notifyLikes = notifyReactions = ''
|
||||||
hideLikeButton = hideReactionButton = mediaInstanceStr = ''
|
hideLikeButton = hideReactionButton = mediaInstanceStr = ''
|
||||||
blogsInstanceStr = newsInstanceStr = movedTo = twitterStr = ''
|
blogsInstanceStr = news_instanceStr = movedTo = twitterStr = ''
|
||||||
bioStr = donateUrl = websiteUrl = emailAddress = ''
|
bioStr = donateUrl = websiteUrl = emailAddress = ''
|
||||||
PGPpubKey = EnigmaPubKey = ''
|
PGPpubKey = EnigmaPubKey = ''
|
||||||
PGPfingerprint = xmppAddress = matrixAddress = ''
|
PGPfingerprint = xmppAddress = matrixAddress = ''
|
||||||
|
@ -2176,19 +2176,19 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
if mediaInstance:
|
if mediaInstance:
|
||||||
if mediaInstance is True:
|
if mediaInstance is True:
|
||||||
mediaInstanceStr = 'checked'
|
mediaInstanceStr = 'checked'
|
||||||
blogsInstanceStr = newsInstanceStr = ''
|
blogsInstanceStr = news_instanceStr = ''
|
||||||
|
|
||||||
newsInstance = getConfigParam(base_dir, "newsInstance")
|
news_instance = getConfigParam(base_dir, "news_instance")
|
||||||
if newsInstance:
|
if news_instance:
|
||||||
if newsInstance is True:
|
if news_instance is True:
|
||||||
newsInstanceStr = 'checked'
|
news_instanceStr = 'checked'
|
||||||
blogsInstanceStr = mediaInstanceStr = ''
|
blogsInstanceStr = mediaInstanceStr = ''
|
||||||
|
|
||||||
blogsInstance = getConfigParam(base_dir, "blogsInstance")
|
blogsInstance = getConfigParam(base_dir, "blogsInstance")
|
||||||
if blogsInstance:
|
if blogsInstance:
|
||||||
if blogsInstance is True:
|
if blogsInstance is True:
|
||||||
blogsInstanceStr = 'checked'
|
blogsInstanceStr = 'checked'
|
||||||
mediaInstanceStr = newsInstanceStr = ''
|
mediaInstanceStr = news_instanceStr = ''
|
||||||
|
|
||||||
cssFilename = base_dir + '/epicyon-profile.css'
|
cssFilename = base_dir + '/epicyon-profile.css'
|
||||||
if os.path.isfile(base_dir + '/epicyon.css'):
|
if os.path.isfile(base_dir + '/epicyon.css'):
|
||||||
|
@ -2223,7 +2223,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
peertubeInstances,
|
peertubeInstances,
|
||||||
mediaInstanceStr,
|
mediaInstanceStr,
|
||||||
blogsInstanceStr,
|
blogsInstanceStr,
|
||||||
newsInstanceStr)
|
news_instanceStr)
|
||||||
systemMonitorStr = _htmlSystemMonitor(nickname, translate)
|
systemMonitorStr = _htmlSystemMonitor(nickname, translate)
|
||||||
|
|
||||||
instanceTitle = getConfigParam(base_dir, 'instanceTitle')
|
instanceTitle = getConfigParam(base_dir, 'instanceTitle')
|
||||||
|
@ -2284,7 +2284,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
PGPpubKey, EnigmaPubKey, translate)
|
PGPpubKey, EnigmaPubKey, translate)
|
||||||
|
|
||||||
# Customize images and banners
|
# Customize images and banners
|
||||||
editProfileForm += _htmlEditProfileBackground(newsInstance, translate)
|
editProfileForm += _htmlEditProfileBackground(news_instance, translate)
|
||||||
|
|
||||||
# Change password
|
# Change password
|
||||||
editProfileForm += _htmlEditProfileChangePassword(translate)
|
editProfileForm += _htmlEditProfileChangePassword(translate)
|
||||||
|
|
Loading…
Reference in New Issue