Featured writers

merge-requests/17/merge
Bob Mottram 2021-02-13 11:37:02 +00:00
parent d3abc360e3
commit 03c234eac9
19 changed files with 110 additions and 25 deletions

View File

@ -1964,6 +1964,42 @@ class PubServer(BaseHTTPRequestHandler):
self.server.POSTbusy = False self.server.POSTbusy = False
return return
# person options screen, permission to post to featured articles
# See htmlPersonOptions
if '&submitPostToFeatures=' in optionsConfirmParams:
adminNickname = getConfigParam(self.server.baseDir, 'admin')
if (chooserNickname != optionsNickname and
(chooserNickname == adminNickname or
(isModerator(self.server.baseDir, chooserNickname) and
not isModerator(self.server.baseDir, optionsNickname)))):
postsToFeatures = None
if 'postsToFeatures=' in optionsConfirmParams:
postsToFeatures = \
optionsConfirmParams.split('postsToFeatures=')[1]
if '&' in postsToFeatures:
postsToFeatures = postsToFeatures.split('&')[0]
accountDir = self.server.baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain
featuresBlockedFilename = accountDir + '/.nofeatures'
if postsToFeatures == 'on':
if os.path.isfile(featuresBlockedFilename):
os.remove(featuresBlockedFilename)
refreshNewswire(self.server.baseDir)
else:
if os.path.isdir(accountDir):
noFeaturesFile = open(featuresBlockedFilename, "w+")
if noFeaturesFile:
noFeaturesFile.write('\n')
noFeaturesFile.close()
refreshNewswire(self.server.baseDir)
usersPathStr = \
usersPath + '/' + self.server.defaultTimeline + \
'?page=' + str(pageNumber)
self._redirect_headers(usersPathStr, cookie,
callingDomain)
self.server.POSTbusy = False
return
# person options screen, permission to post to newswire # person options screen, permission to post to newswire
# See htmlPersonOptions # See htmlPersonOptions
if '&submitModNewsPosts=' in optionsConfirmParams: if '&submitModNewsPosts=' in optionsConfirmParams:
@ -5472,7 +5508,8 @@ class PubServer(BaseHTTPRequestHandler):
backToPath, backToPath,
lockedAccount, lockedAccount,
movedTo, alsoKnownAs, movedTo, alsoKnownAs,
self.server.textModeBanner).encode('utf-8') self.server.textModeBanner,
self.server.newsInstance).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)

View File

@ -18,6 +18,7 @@ from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import isFeaturedWriter
from blocking import isBlockedDomain from blocking import isBlockedDomain
from blocking import outboxBlock from blocking import outboxBlock
from blocking import outboxUndoBlock from blocking import outboxUndoBlock
@ -211,14 +212,16 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
# save all instance blogs to the news actor # save all instance blogs to the news actor
if postToNickname != 'news' and outboxName == 'tlblogs': if postToNickname != 'news' and outboxName == 'tlblogs':
if '/' in savedFilename: if '/' in savedFilename:
savedPostId = savedFilename.split('/')[-1] if isFeaturedWriter(baseDir, postToNickname, domain):
blogsDir = baseDir + '/accounts/news@' + domain + '/tlblogs' savedPostId = savedFilename.split('/')[-1]
if not os.path.isdir(blogsDir): blogsDir = \
os.mkdir(blogsDir) baseDir + '/accounts/news@' + domain + '/tlblogs'
copyfile(savedFilename, blogsDir + '/' + savedPostId) if not os.path.isdir(blogsDir):
inboxUpdateIndex('tlblogs', baseDir, os.mkdir(blogsDir)
'news@' + domain, copyfile(savedFilename, blogsDir + '/' + savedPostId)
savedFilename, debug) inboxUpdateIndex('tlblogs', baseDir,
'news@' + domain,
savedFilename, debug)
# clear the citations file if it exists # clear the citations file if it exists
citationsFilename = \ citationsFilename = \

View File

@ -367,5 +367,6 @@
"Skip to timeline": "تخطي إلى الجدول الزمني", "Skip to timeline": "تخطي إلى الجدول الزمني",
"Skip to Newswire": "انتقل إلى Newswire", "Skip to Newswire": "انتقل إلى Newswire",
"Skip to Links": "تخطي إلى روابط الويب", "Skip to Links": "تخطي إلى روابط الويب",
"Publish a blog article": "نشر مقال بلوق" "Publish a blog article": "نشر مقال بلوق",
"Featured writer": "كاتب متميز"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Ves a la cronologia", "Skip to timeline": "Ves a la cronologia",
"Skip to Newswire": "Vés a Newswire", "Skip to Newswire": "Vés a Newswire",
"Skip to Links": "Vés als enllaços web", "Skip to Links": "Vés als enllaços web",
"Publish a blog article": "Publicar un article del bloc" "Publish a blog article": "Publicar un article del bloc",
"Featured writer": "Escriptor destacat"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Neidio i'r llinell amser", "Skip to timeline": "Neidio i'r llinell amser",
"Skip to Newswire": "Neidio i Newswire", "Skip to Newswire": "Neidio i Newswire",
"Skip to Links": "Neidio i Dolenni Gwe", "Skip to Links": "Neidio i Dolenni Gwe",
"Publish a blog article": "Cyhoeddi erthygl blog" "Publish a blog article": "Cyhoeddi erthygl blog",
"Featured writer": "Awdur dan sylw"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Zur Zeitleiste springen", "Skip to timeline": "Zur Zeitleiste springen",
"Skip to Newswire": "Springe zu Newswire", "Skip to Newswire": "Springe zu Newswire",
"Skip to Links": "Springe zu Weblinks", "Skip to Links": "Springe zu Weblinks",
"Publish a blog article": "Veröffentlichen Sie einen Blog-Artikel" "Publish a blog article": "Veröffentlichen Sie einen Blog-Artikel",
"Featured writer": "Ausgewählter Schriftsteller"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Skip to timeline", "Skip to timeline": "Skip to timeline",
"Skip to Newswire": "Skip to Newswire", "Skip to Newswire": "Skip to Newswire",
"Skip to Links": "Skip to Links", "Skip to Links": "Skip to Links",
"Publish a blog article": "Publish a blog article" "Publish a blog article": "Publish a blog article",
"Featured writer": "Featured writer"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Saltar a la línea de tiempo", "Skip to timeline": "Saltar a la línea de tiempo",
"Skip to Newswire": "Saltar a Newswire", "Skip to Newswire": "Saltar a Newswire",
"Skip to Links": "Saltar a enlaces web", "Skip to Links": "Saltar a enlaces web",
"Publish a blog article": "Publica un artículo de blog" "Publish a blog article": "Publica un artículo de blog",
"Featured writer": "Escritora destacada"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Passer à la chronologie", "Skip to timeline": "Passer à la chronologie",
"Skip to Newswire": "Passer à Newswire", "Skip to Newswire": "Passer à Newswire",
"Skip to Links": "Passer aux liens Web", "Skip to Links": "Passer aux liens Web",
"Publish a blog article": "Publier un article de blog" "Publish a blog article": "Publier un article de blog",
"Featured writer": "Écrivain en vedette"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Scipeáil chuig an amlíne", "Skip to timeline": "Scipeáil chuig an amlíne",
"Skip to Newswire": "Scipeáil chuig Newswire", "Skip to Newswire": "Scipeáil chuig Newswire",
"Skip to Links": "Scipeáil chuig Naisc Ghréasáin", "Skip to Links": "Scipeáil chuig Naisc Ghréasáin",
"Publish a blog article": "Foilsigh alt blagála" "Publish a blog article": "Foilsigh alt blagála",
"Featured writer": "Scríbhneoir mór le rá"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "टाइमलाइन पर जाएं", "Skip to timeline": "टाइमलाइन पर जाएं",
"Skip to Newswire": "Newswire पर जाएं", "Skip to Newswire": "Newswire पर जाएं",
"Skip to Links": "वेब लिंक पर जाएं", "Skip to Links": "वेब लिंक पर जाएं",
"Publish a blog article": "एक ब्लॉग लेख प्रकाशित करें" "Publish a blog article": "एक ब्लॉग लेख प्रकाशित करें",
"Featured writer": "फीचर्ड लेखक"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Passa alla sequenza temporale", "Skip to timeline": "Passa alla sequenza temporale",
"Skip to Newswire": "Passa a Newswire", "Skip to Newswire": "Passa a Newswire",
"Skip to Links": "Passa a collegamenti Web", "Skip to Links": "Passa a collegamenti Web",
"Publish a blog article": "Pubblica un articolo sul blog" "Publish a blog article": "Pubblica un articolo sul blog",
"Featured writer": "Scrittore in primo piano"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "タイムラインにスキップ", "Skip to timeline": "タイムラインにスキップ",
"Skip to Newswire": "Newswireにスキップ", "Skip to Newswire": "Newswireにスキップ",
"Skip to Links": "Webリンクにスキップ", "Skip to Links": "Webリンクにスキップ",
"Publish a blog article": "ブログ記事を公開する" "Publish a blog article": "ブログ記事を公開する",
"Featured writer": "注目の作家"
} }

View File

@ -363,5 +363,6 @@
"Skip to timeline": "Skip to timeline", "Skip to timeline": "Skip to timeline",
"Skip to Newswire": "Skip to Newswire", "Skip to Newswire": "Skip to Newswire",
"Skip to Links": "Skip to Links", "Skip to Links": "Skip to Links",
"Publish a blog article": "Publish a blog article" "Publish a blog article": "Publish a blog article",
"Featured writer": "Featured writer"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Pular para a linha do tempo", "Skip to timeline": "Pular para a linha do tempo",
"Skip to Newswire": "Pular para Newswire", "Skip to Newswire": "Pular para Newswire",
"Skip to Links": "Pular para links da web", "Skip to Links": "Pular para links da web",
"Publish a blog article": "Publique um artigo de blog" "Publish a blog article": "Publique um artigo de blog",
"Featured writer": "Escritor em destaque"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "Перейти к временной шкале", "Skip to timeline": "Перейти к временной шкале",
"Skip to Newswire": "Перейти к ленте новостей", "Skip to Newswire": "Перейти к ленте новостей",
"Skip to Links": "Перейти к веб-ссылкам", "Skip to Links": "Перейти к веб-ссылкам",
"Publish a blog article": "Опубликовать статью в блоге" "Publish a blog article": "Опубликовать статью в блоге",
"Featured writer": "Избранный писатель"
} }

View File

@ -367,5 +367,6 @@
"Skip to timeline": "跳到时间线", "Skip to timeline": "跳到时间线",
"Skip to Newswire": "跳到新闻专线", "Skip to Newswire": "跳到新闻专线",
"Skip to Links": "跳到网页链接", "Skip to Links": "跳到网页链接",
"Publish a blog article": "发布博客文章" "Publish a blog article": "发布博客文章",
"Featured writer": "特色作家"
} }

View File

@ -26,6 +26,16 @@ invalidCharacters = (
) )
def isFeaturedWriter(baseDir: str, nickname: str, domain: str) -> bool:
"""Is the given account a featured writer, appearing in the features
timeline on news instances?
"""
featuresBlockedFilename = \
baseDir + '/accounts/' + \
nickname + '@' + domain + '/.nofeatures'
return not os.path.isfile(featuresBlockedFilename)
def refreshNewswire(baseDir: str): def refreshNewswire(baseDir: str):
"""Causes the newswire to be updates after a change to user accounts """Causes the newswire to be updates after a change to user accounts
""" """

View File

@ -17,6 +17,7 @@ from utils import isDormant
from utils import removeHtml from utils import removeHtml
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import isFeaturedWriter
from blocking import isBlocked from blocking import isBlocked
from follow import isFollowerOfPerson from follow import isFollowerOfPerson
from follow import isFollowingActor from follow import isFollowingActor
@ -51,7 +52,8 @@ def htmlPersonOptions(defaultTimeline: str,
lockedAccount: bool, lockedAccount: bool,
movedTo: str, movedTo: str,
alsoKnownAs: [], alsoKnownAs: [],
textModeBanner: str) -> str: textModeBanner: str,
newsInstance: 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)
@ -287,6 +289,24 @@ def htmlPersonOptions(defaultTimeline: str,
checkboxStr = checkboxStr.replace(' checked>', '>') checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr optionsStr += checkboxStr
# checkbox for permission to post to featured articles
if newsInstance and optionsDomainFull == domainFull:
adminNickname = getConfigParam(baseDir, 'admin')
if (nickname == adminNickname or
(isModerator(baseDir, nickname) and
not isModerator(baseDir, optionsNickname))):
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="postsToFeatures" checked> ' + \
translate['Featured writer'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitPostToFeatures">' + \
translate['Submit'] + '</button><br>\n'
if not isFeaturedWriter(baseDir, optionsNickname,
optionsDomain):
checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr
optionsStr += optionsLinkStr optionsStr += optionsLinkStr
backPath = '/' backPath = '/'
if nickname: if nickname: