main
Bob Mottram 2021-02-23 18:08:03 +00:00
commit bdbb512663
3 changed files with 155 additions and 124 deletions

View File

@ -2819,7 +2819,7 @@ class PubServer(BaseHTTPRequestHandler):
domain, domainFull,
GETstartTime, GETtimings,
onionDomain, i2pDomain,
cookie, debug)
cookie, debug, authorized)
return
else:
showPublishedDateOnly = self.server.showPublishedDateOnly
@ -5486,7 +5486,8 @@ class PubServer(BaseHTTPRequestHandler):
domain: str, domainFull: str,
GETstartTime, GETtimings: {},
onionDomain: str, i2pDomain: str,
cookie: str, debug: bool) -> None:
cookie: str, debug: bool,
authorized: bool) -> None:
"""Show person options screen
"""
backToPath = ''
@ -5576,7 +5577,8 @@ class PubServer(BaseHTTPRequestHandler):
lockedAccount,
movedTo, alsoKnownAs,
self.server.textModeBanner,
self.server.newsInstance).encode('utf-8')
self.server.newsInstance,
authorized).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain)
@ -10495,7 +10497,8 @@ class PubServer(BaseHTTPRequestHandler):
GETstartTime, GETtimings,
self.server.onionDomain,
self.server.i2pDomain,
cookie, self.server.debug)
cookie, self.server.debug,
authorized)
return
self._benchmarkGETtimings(GETstartTime, GETtimings,

View File

@ -619,6 +619,15 @@ def setNewsAvatar(baseDir: str, name: str,
nickname + '@' + domain + '/avatar.png')
def _setClearCacheFlag(baseDir: str) -> None:
"""Sets a flag which can be used by an external system
(eg. a script in a cron job) to clear the browser cache
"""
flagFilename = baseDir + '/accounts/.clear_cache'
with open(flagFilename, 'w+') as flagFile:
flagFile.write('\n')
def setTheme(baseDir: str, name: str, domain: str,
allowLocalNetworkAccess: bool) -> bool:
"""Sets the theme with the given name as the current theme
@ -674,4 +683,5 @@ def setTheme(baseDir: str, name: str, domain: str,
disableGrayscale(baseDir)
_setThemeInConfig(baseDir, name)
_setClearCacheFlag(baseDir)
return result

View File

@ -53,7 +53,8 @@ def htmlPersonOptions(defaultTimeline: str,
movedTo: str,
alsoKnownAs: [],
textModeBanner: str,
newsInstance: bool) -> str:
newsInstance: bool,
authorized: bool) -> str:
"""Show options for a person: view/follow/block/report
"""
optionsDomain, optionsPort = getDomainFromActor(optionsActor)
@ -225,6 +226,8 @@ def htmlPersonOptions(defaultTimeline: str,
optionsActor + '">\n'
optionsStr += ' <input type="hidden" name="avatarUrl" value="' + \
optionsProfileUrl + '">\n'
if authorized:
if originPathStr == '/users/' + nickname:
if optionsNickname:
handle = optionsNickname + '@' + optionsDomainFull
petname = getPetName(baseDir, nickname, domain, handle)
@ -246,7 +249,8 @@ def htmlPersonOptions(defaultTimeline: str,
'name="submitOnCalendar">' + \
translate['Submit'] + '</button><br>\n'
if not receivingCalendarEvents(baseDir, nickname, domain,
optionsNickname, optionsDomainFull):
optionsNickname,
optionsDomainFull):
checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr
@ -262,7 +266,8 @@ def htmlPersonOptions(defaultTimeline: str,
optionsNickname + '@' + optionsDomain + '/.nonewswire'
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="postsToNews" checked> ' + \
'class="profilecheckbox" ' + \
'name="postsToNews" checked> ' + \
translate['Allow news posts'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToNews">' + \
@ -273,11 +278,13 @@ def htmlPersonOptions(defaultTimeline: str,
newswirePostsPermitted = True
optionsStr += checkboxStr
# whether blogs created by this account are moderated on the newswire
# whether blogs created by this account are moderated on
# the newswire
if newswirePostsPermitted:
moderatedFilename = \
baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.newswiremoderated'
optionsNickname + '@' + \
optionsDomain + '/.newswiremoderated'
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="modNewsPosts" checked> ' + \
@ -297,7 +304,8 @@ def htmlPersonOptions(defaultTimeline: str,
not isModerator(baseDir, optionsNickname))):
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="postsToFeatures" checked> ' + \
'class="profilecheckbox" ' + \
'name="postsToFeatures" checked> ' + \
translate['Featured writer'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToFeatures">' + \
@ -313,14 +321,22 @@ def htmlPersonOptions(defaultTimeline: str,
backPath = '/users/' + nickname + '/' + defaultTimeline
if 'moderation' in backToPath:
backPath = '/users/' + nickname + '/moderation'
if authorized and originPathStr == '/users/' + nickname:
optionsStr += \
' <a href="' + backPath + '"><button type="button" ' + \
'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \
'</button></a>\n'
else:
optionsStr += \
' <a href="' + originPathStr + '"><button type="button" ' + \
'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \
'</button></a>\n'
if authorized:
optionsStr += \
' <button type="submit" class="button" name="submitView">' + \
translate['View'] + '</button>\n'
optionsStr += donateStr
if authorized:
optionsStr += \
' <button type="submit" class="button" name="submit' + \
followStr + '">' + translate[followStr] + '</button>\n'
@ -332,10 +348,11 @@ def htmlPersonOptions(defaultTimeline: str,
translate['DM'] + '</button>\n'
optionsStr += \
' <button type="submit" class="button" name="submit' + \
snoozeButtonStr + '">' + translate[snoozeButtonStr] + '</button>\n'
snoozeButtonStr + '">' + translate[snoozeButtonStr] + \
'</button>\n'
optionsStr += \
' <button type="submit" class="button" name="submitReport">' + \
translate['Report'] + '</button>\n'
' <button type="submit" class="button" ' + \
'name="submitReport">' + translate['Report'] + '</button>\n'
if isModerator(baseDir, nickname):
optionsStr += \
@ -344,6 +361,7 @@ def htmlPersonOptions(defaultTimeline: str,
translate['Info'] + '</button>\n'
personNotes = ''
if originPathStr == '/users/' + nickname:
personNotesFilename = \
baseDir + '/accounts/' + nickname + '@' + domain + \
'/notes/' + handle + '.txt'