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

View File

@ -619,6 +619,15 @@ def setNewsAvatar(baseDir: str, name: str,
nickname + '@' + domain + '/avatar.png') 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, def setTheme(baseDir: str, name: str, domain: str,
allowLocalNetworkAccess: bool) -> bool: allowLocalNetworkAccess: bool) -> bool:
"""Sets the theme with the given name as the current theme """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) disableGrayscale(baseDir)
_setThemeInConfig(baseDir, name) _setThemeInConfig(baseDir, name)
_setClearCacheFlag(baseDir)
return result return result

View File

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