diff --git a/daemon.py b/daemon.py index d52c6b29b..8525442b4 100644 --- a/daemon.py +++ b/daemon.py @@ -140,7 +140,6 @@ from webapp_login import htmlGetLoginCredentials from webapp import htmlSuspended from webapp import htmlFollowConfirm from webapp import htmlUnfollowConfirm -from webapp import htmlEditNewsPost from webapp import htmlTermsOfService from webapp import htmlModerationInfo from webapp import htmlHashtagBlocked @@ -154,6 +153,7 @@ from webapp_column_left import htmlEditLinks from webapp_column_right import htmlNewswireMobile from webapp_column_right import htmlEditNewswire from webapp_column_right import htmlCitations +from webapp_column_right import htmlEditNewsPost from webapp_search import htmlSkillsSearch from webapp_search import htmlHistorySearch from webapp_search import htmlHashtagSearch diff --git a/webapp.py b/webapp.py index ee0f02002..b395b0be6 100644 --- a/webapp.py +++ b/webapp.py @@ -14,7 +14,6 @@ from utils import getDomainFromActor from utils import locatePost from utils import loadJson from utils import getConfigParam -from posts import isEditor from shares import getValidSharedItemID from webapp_utils import getAltPath from webapp_utils import getIconsDir @@ -115,84 +114,6 @@ def htmlModerationInfo(cssCache: {}, translate: {}, return infoForm -def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str, - domain: str, port: int, - httpPrefix: str, postUrl: str) -> str: - """Edits a news post - """ - if '/users/' not in path: - return '' - pathOriginal = path - - nickname = getNicknameFromActor(path) - if not nickname: - return '' - - # is the user an editor? - if not isEditor(baseDir, nickname): - return '' - - postUrl = postUrl.replace('/', '#') - postFilename = locatePost(baseDir, nickname, domain, postUrl) - if not postFilename: - return '' - postJsonObject = loadJson(postFilename) - if not postJsonObject: - return '' - - cssFilename = baseDir + '/epicyon-links.css' - if os.path.isfile(baseDir + '/links.css'): - cssFilename = baseDir + '/links.css' - - editCSS = getCSS(baseDir, cssFilename, cssCache) - if editCSS: - if httpPrefix != 'https': - editCSS = \ - editCSS.replace('https://', httpPrefix + '://') - - editNewsPostForm = htmlHeader(cssFilename, editCSS) - editNewsPostForm += \ - '
\n' - editNewsPostForm += \ - '
\n' - editNewsPostForm += \ - '

' + translate['Edit News Post'] + '

' - editNewsPostForm += \ - '
\n' - editNewsPostForm += \ - ' ' + \ - '\n' - editNewsPostForm += \ - ' \n' - editNewsPostForm += \ - '
\n' - - editNewsPostForm += \ - '
' - - editNewsPostForm += \ - ' \n' - - newsPostTitle = postJsonObject['object']['summary'] - editNewsPostForm += \ - '
\n' - - newsPostContent = postJsonObject['object']['content'] - editNewsPostForm += \ - ' ' - - editNewsPostForm += \ - '
' - - editNewsPostForm += htmlFooter() - return editNewsPostForm - - def htmlTermsOfService(cssCache: {}, baseDir: str, httpPrefix: str, domainFull: str) -> str: """Show the terms of service screen diff --git a/webapp_column_right.py b/webapp_column_right.py index c8b72a7b4..0e3cff85a 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -10,6 +10,8 @@ import os from datetime import datetime from shutil import copyfile from content import removeLongWords +from utils import locatePost +from utils import loadJson from utils import getCSS from utils import getConfigParam from utils import votesOnNewswireItem @@ -565,3 +567,81 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str, editNewswireForm += htmlFooter() return editNewswireForm + + +def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str, + domain: str, port: int, + httpPrefix: str, postUrl: str) -> str: + """Edits a news post on the news/features timeline + """ + if '/users/' not in path: + return '' + pathOriginal = path + + nickname = getNicknameFromActor(path) + if not nickname: + return '' + + # is the user an editor? + if not isEditor(baseDir, nickname): + return '' + + postUrl = postUrl.replace('/', '#') + postFilename = locatePost(baseDir, nickname, domain, postUrl) + if not postFilename: + return '' + postJsonObject = loadJson(postFilename) + if not postJsonObject: + return '' + + cssFilename = baseDir + '/epicyon-links.css' + if os.path.isfile(baseDir + '/links.css'): + cssFilename = baseDir + '/links.css' + + editCSS = getCSS(baseDir, cssFilename, cssCache) + if editCSS: + if httpPrefix != 'https': + editCSS = \ + editCSS.replace('https://', httpPrefix + '://') + + editNewsPostForm = htmlHeader(cssFilename, editCSS) + editNewsPostForm += \ + '\n' + editNewsPostForm += \ + '
\n' + editNewsPostForm += \ + '

' + translate['Edit News Post'] + '

' + editNewsPostForm += \ + '
\n' + editNewsPostForm += \ + ' ' + \ + '\n' + editNewsPostForm += \ + ' \n' + editNewsPostForm += \ + '
\n' + + editNewsPostForm += \ + '
' + + editNewsPostForm += \ + ' \n' + + newsPostTitle = postJsonObject['object']['summary'] + editNewsPostForm += \ + '
\n' + + newsPostContent = postJsonObject['object']['content'] + editNewsPostForm += \ + ' ' + + editNewsPostForm += \ + '
' + + editNewsPostForm += htmlFooter() + return editNewsPostForm