mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
37da0662e4
commit
f2b734ca8d
|
@ -33,179 +33,179 @@ from webapp_utils import header_buttons_front_screen
|
||||||
from webapp_utils import edit_text_field
|
from webapp_utils import edit_text_field
|
||||||
|
|
||||||
|
|
||||||
def _votes_indicator(totalVotes: int, positive_voting: bool) -> str:
|
def _votes_indicator(total_votes: int, positive_voting: bool) -> str:
|
||||||
"""Returns an indicator of the number of votes on a newswire item
|
"""Returns an indicator of the number of votes on a newswire item
|
||||||
"""
|
"""
|
||||||
if totalVotes <= 0:
|
if total_votes <= 0:
|
||||||
return ''
|
return ''
|
||||||
totalVotesStr = ' '
|
total_votes_str = ' '
|
||||||
for v in range(totalVotes):
|
for _ in range(total_votes):
|
||||||
if positive_voting:
|
if positive_voting:
|
||||||
totalVotesStr += '✓'
|
total_votes_str += '✓'
|
||||||
else:
|
else:
|
||||||
totalVotesStr += '✗'
|
total_votes_str += '✗'
|
||||||
return totalVotesStr
|
return total_votes_str
|
||||||
|
|
||||||
|
|
||||||
def get_right_column_content(base_dir: str, nickname: str, domain_full: str,
|
def get_right_column_content(base_dir: str, nickname: str, domain_full: str,
|
||||||
http_prefix: str, translate: {},
|
http_prefix: str, translate: {},
|
||||||
moderator: bool, editor: bool,
|
moderator: bool, editor: bool,
|
||||||
newswire: {}, positive_voting: bool,
|
newswire: {}, positive_voting: bool,
|
||||||
showBackButton: bool, timelinePath: str,
|
show_back_button: bool, timeline_path: str,
|
||||||
showPublishButton: bool,
|
show_publish_button: bool,
|
||||||
show_publish_as_icon: bool,
|
show_publish_as_icon: bool,
|
||||||
rss_icon_at_top: bool,
|
rss_icon_at_top: bool,
|
||||||
publish_button_at_top: bool,
|
publish_button_at_top: bool,
|
||||||
authorized: bool,
|
authorized: bool,
|
||||||
showHeaderImage: bool,
|
show_header_image: bool,
|
||||||
theme: str,
|
theme: str,
|
||||||
default_timeline: str,
|
default_timeline: str,
|
||||||
access_keys: {}) -> str:
|
access_keys: {}) -> str:
|
||||||
"""Returns html content for the right column
|
"""Returns html content for the right column
|
||||||
"""
|
"""
|
||||||
htmlStr = ''
|
html_str = ''
|
||||||
|
|
||||||
domain = remove_domain_port(domain_full)
|
domain = remove_domain_port(domain_full)
|
||||||
|
|
||||||
if authorized:
|
if authorized:
|
||||||
# only show the publish button if logged in, otherwise replace it with
|
# only show the publish button if logged in, otherwise replace it with
|
||||||
# a login button
|
# a login button
|
||||||
titleStr = translate['Publish a blog article']
|
title_str = translate['Publish a blog article']
|
||||||
if default_timeline == 'tlfeatures':
|
if default_timeline == 'tlfeatures':
|
||||||
titleStr = translate['Publish a news article']
|
title_str = translate['Publish a news article']
|
||||||
publishButtonStr = \
|
publish_button_str = \
|
||||||
' <a href="' + \
|
' <a href="' + \
|
||||||
'/users/' + nickname + '/newblog?nodropdown" ' + \
|
'/users/' + nickname + '/newblog?nodropdown" ' + \
|
||||||
'title="' + titleStr + '" ' + \
|
'title="' + title_str + '" ' + \
|
||||||
'accesskey="' + access_keys['menuNewPost'] + '">' + \
|
'accesskey="' + access_keys['menuNewPost'] + '">' + \
|
||||||
'<button class="publishbtn">' + \
|
'<button class="publishbtn">' + \
|
||||||
translate['Publish'] + '</button></a>\n'
|
translate['Publish'] + '</button></a>\n'
|
||||||
else:
|
else:
|
||||||
# if not logged in then replace the publish button with
|
# if not logged in then replace the publish button with
|
||||||
# a login button
|
# a login button
|
||||||
publishButtonStr = \
|
publish_button_str = \
|
||||||
' <a href="/login"><button class="publishbtn">' + \
|
' <a href="/login"><button class="publishbtn">' + \
|
||||||
translate['Login'] + '</button></a>\n'
|
translate['Login'] + '</button></a>\n'
|
||||||
|
|
||||||
# show publish button at the top if needed
|
# show publish button at the top if needed
|
||||||
if publish_button_at_top:
|
if publish_button_at_top:
|
||||||
htmlStr += '<center>' + publishButtonStr + '</center>'
|
html_str += '<center>' + publish_button_str + '</center>'
|
||||||
|
|
||||||
# show a column header image, eg. title of the theme or newswire banner
|
# show a column header image, eg. title of the theme or newswire banner
|
||||||
editImageClass = ''
|
edit_image_class = ''
|
||||||
if showHeaderImage:
|
if show_header_image:
|
||||||
rightImageFile, rightColumnImageFilename = \
|
right_image_file, right_column_image_filename = \
|
||||||
get_right_image_file(base_dir, nickname, domain, theme)
|
get_right_image_file(base_dir, nickname, domain, theme)
|
||||||
|
|
||||||
# show the image at the top of the column
|
# show the image at the top of the column
|
||||||
editImageClass = 'rightColEdit'
|
edit_image_class = 'rightColEdit'
|
||||||
if os.path.isfile(rightColumnImageFilename):
|
if os.path.isfile(right_column_image_filename):
|
||||||
editImageClass = 'rightColEditImage'
|
edit_image_class = 'rightColEditImage'
|
||||||
htmlStr += \
|
html_str += \
|
||||||
'\n <center>\n' + \
|
'\n <center>\n' + \
|
||||||
' <img class="rightColImg" ' + \
|
' <img class="rightColImg" ' + \
|
||||||
'alt="" loading="lazy" src="/users/' + \
|
'alt="" loading="lazy" src="/users/' + \
|
||||||
nickname + '/' + rightImageFile + '" />\n' + \
|
nickname + '/' + right_image_file + '" />\n' + \
|
||||||
' </center>\n'
|
' </center>\n'
|
||||||
|
|
||||||
if showPublishButton or editor or rss_icon_at_top:
|
if show_publish_button or editor or rss_icon_at_top:
|
||||||
if not showHeaderImage:
|
if not show_header_image:
|
||||||
htmlStr += '<div class="columnIcons">'
|
html_str += '<div class="columnIcons">'
|
||||||
|
|
||||||
if editImageClass == 'rightColEdit':
|
if edit_image_class == 'rightColEdit':
|
||||||
htmlStr += '\n <center>\n'
|
html_str += '\n <center>\n'
|
||||||
|
|
||||||
# whether to show a back icon
|
# whether to show a back icon
|
||||||
# This is probably going to be osolete soon
|
# This is probably going to be osolete soon
|
||||||
if showBackButton:
|
if show_back_button:
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <a href="' + timelinePath + '">' + \
|
' <a href="' + timeline_path + '">' + \
|
||||||
'<button class="cancelbtn">' + \
|
'<button class="cancelbtn">' + \
|
||||||
translate['Go Back'] + '</button></a>\n'
|
translate['Go Back'] + '</button></a>\n'
|
||||||
|
|
||||||
if showPublishButton and not publish_button_at_top:
|
if show_publish_button and not publish_button_at_top:
|
||||||
if not show_publish_as_icon:
|
if not show_publish_as_icon:
|
||||||
htmlStr += publishButtonStr
|
html_str += publish_button_str
|
||||||
|
|
||||||
# show the edit icon
|
# show the edit icon
|
||||||
if editor:
|
if editor:
|
||||||
if os.path.isfile(base_dir + '/accounts/newswiremoderation.txt'):
|
if os.path.isfile(base_dir + '/accounts/newswiremoderation.txt'):
|
||||||
# show the edit icon highlighted
|
# show the edit icon highlighted
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <a href="' + \
|
' <a href="' + \
|
||||||
'/users/' + nickname + '/editnewswire" ' + \
|
'/users/' + nickname + '/editnewswire" ' + \
|
||||||
'accesskey="' + access_keys['menuEdit'] + '">' + \
|
'accesskey="' + access_keys['menuEdit'] + '">' + \
|
||||||
'<img class="' + editImageClass + \
|
'<img class="' + edit_image_class + \
|
||||||
'" loading="lazy" alt="' + \
|
'" loading="lazy" alt="' + \
|
||||||
translate['Edit newswire'] + ' | " title="' + \
|
translate['Edit newswire'] + ' | " title="' + \
|
||||||
translate['Edit newswire'] + '" src="/' + \
|
translate['Edit newswire'] + '" src="/' + \
|
||||||
'icons/edit_notify.png" /></a>\n'
|
'icons/edit_notify.png" /></a>\n'
|
||||||
else:
|
else:
|
||||||
# show the edit icon
|
# show the edit icon
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <a href="' + \
|
' <a href="' + \
|
||||||
'/users/' + nickname + '/editnewswire" ' + \
|
'/users/' + nickname + '/editnewswire" ' + \
|
||||||
'accesskey="' + access_keys['menuEdit'] + '">' + \
|
'accesskey="' + access_keys['menuEdit'] + '">' + \
|
||||||
'<img class="' + editImageClass + \
|
'<img class="' + edit_image_class + \
|
||||||
'" loading="lazy" alt="' + \
|
'" loading="lazy" alt="' + \
|
||||||
translate['Edit newswire'] + ' | " title="' + \
|
translate['Edit newswire'] + ' | " title="' + \
|
||||||
translate['Edit newswire'] + '" src="/' + \
|
translate['Edit newswire'] + '" src="/' + \
|
||||||
'icons/edit.png" /></a>\n'
|
'icons/edit.png" /></a>\n'
|
||||||
|
|
||||||
# show the RSS icons
|
# show the RSS icons
|
||||||
rssIconStr = \
|
rss_icon_str = \
|
||||||
' <a href="/categories.xml">' + \
|
' <a href="/categories.xml">' + \
|
||||||
'<img class="' + editImageClass + \
|
'<img class="' + edit_image_class + \
|
||||||
'" loading="lazy" alt="' + \
|
'" loading="lazy" alt="' + \
|
||||||
translate['Hashtag Categories RSS Feed'] + ' | " title="' + \
|
translate['Hashtag Categories RSS Feed'] + ' | " title="' + \
|
||||||
translate['Hashtag Categories RSS Feed'] + '" src="/' + \
|
translate['Hashtag Categories RSS Feed'] + '" src="/' + \
|
||||||
'icons/categoriesrss.png" /></a>\n'
|
'icons/categoriesrss.png" /></a>\n'
|
||||||
rssIconStr += \
|
rss_icon_str += \
|
||||||
' <a href="/newswire.xml">' + \
|
' <a href="/newswire.xml">' + \
|
||||||
'<img class="' + editImageClass + \
|
'<img class="' + edit_image_class + \
|
||||||
'" loading="lazy" alt="' + \
|
'" loading="lazy" alt="' + \
|
||||||
translate['Newswire RSS Feed'] + ' | " title="' + \
|
translate['Newswire RSS Feed'] + ' | " title="' + \
|
||||||
translate['Newswire RSS Feed'] + '" src="/' + \
|
translate['Newswire RSS Feed'] + '" src="/' + \
|
||||||
'icons/logorss.png" /></a>\n'
|
'icons/logorss.png" /></a>\n'
|
||||||
if rss_icon_at_top:
|
if rss_icon_at_top:
|
||||||
htmlStr += rssIconStr
|
html_str += rss_icon_str
|
||||||
|
|
||||||
# show publish icon at top
|
# show publish icon at top
|
||||||
if showPublishButton:
|
if show_publish_button:
|
||||||
if show_publish_as_icon:
|
if show_publish_as_icon:
|
||||||
titleStr = translate['Publish a blog article']
|
title_str = translate['Publish a blog article']
|
||||||
if default_timeline == 'tlfeatures':
|
if default_timeline == 'tlfeatures':
|
||||||
titleStr = translate['Publish a news article']
|
title_str = translate['Publish a news article']
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <a href="' + \
|
' <a href="' + \
|
||||||
'/users/' + nickname + '/newblog?nodropdown" ' + \
|
'/users/' + nickname + '/newblog?nodropdown" ' + \
|
||||||
'accesskey="' + access_keys['menuNewPost'] + '">' + \
|
'accesskey="' + access_keys['menuNewPost'] + '">' + \
|
||||||
'<img class="' + editImageClass + \
|
'<img class="' + edit_image_class + \
|
||||||
'" loading="lazy" alt="' + \
|
'" loading="lazy" alt="' + \
|
||||||
titleStr + '" title="' + \
|
title_str + '" title="' + \
|
||||||
titleStr + '" src="/' + \
|
title_str + '" src="/' + \
|
||||||
'icons/publish.png" /></a>\n'
|
'icons/publish.png" /></a>\n'
|
||||||
|
|
||||||
if editImageClass == 'rightColEdit':
|
if edit_image_class == 'rightColEdit':
|
||||||
htmlStr += ' </center>\n'
|
html_str += ' </center>\n'
|
||||||
else:
|
else:
|
||||||
if showHeaderImage:
|
if show_header_image:
|
||||||
htmlStr += ' <br>\n'
|
html_str += ' <br>\n'
|
||||||
|
|
||||||
if showPublishButton or editor or rss_icon_at_top:
|
if show_publish_button or editor or rss_icon_at_top:
|
||||||
if not showHeaderImage:
|
if not show_header_image:
|
||||||
htmlStr += '</div><br>'
|
html_str += '</div><br>'
|
||||||
|
|
||||||
# show the newswire lines
|
# show the newswire lines
|
||||||
newswireContentStr = \
|
newswire_content_str = \
|
||||||
_html_newswire(base_dir, newswire, nickname, moderator, translate,
|
_html_newswire(base_dir, newswire, nickname, moderator, translate,
|
||||||
positive_voting)
|
positive_voting)
|
||||||
htmlStr += newswireContentStr
|
html_str += newswire_content_str
|
||||||
|
|
||||||
# show the rss icon at the bottom, typically on the right hand side
|
# show the rss icon at the bottom, typically on the right hand side
|
||||||
if newswireContentStr and not rss_icon_at_top:
|
if newswire_content_str and not rss_icon_at_top:
|
||||||
htmlStr += '<br><div class="columnIcons">' + rssIconStr + '</div>'
|
html_str += '<br><div class="columnIcons">' + rss_icon_str + '</div>'
|
||||||
return htmlStr
|
return html_str
|
||||||
|
|
||||||
|
|
||||||
def _get_broken_fav_substitute() -> str:
|
def _get_broken_fav_substitute() -> str:
|
||||||
|
@ -218,9 +218,9 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
|
||||||
translate: {}, positive_voting: bool) -> str:
|
translate: {}, positive_voting: bool) -> str:
|
||||||
"""Converts a newswire dict into html
|
"""Converts a newswire dict into html
|
||||||
"""
|
"""
|
||||||
separatorStr = html_post_separator(base_dir, 'right')
|
separator_str = html_post_separator(base_dir, 'right')
|
||||||
htmlStr = ''
|
html_str = ''
|
||||||
for dateStr, item in newswire.items():
|
for date_str, item in newswire.items():
|
||||||
item[0] = remove_html(item[0]).strip()
|
item[0] = remove_html(item[0]).strip()
|
||||||
if not item[0]:
|
if not item[0]:
|
||||||
continue
|
continue
|
||||||
|
@ -230,134 +230,134 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
|
||||||
if ']' in item[0]:
|
if ']' in item[0]:
|
||||||
item[0] = item[0].split(']')[0]
|
item[0] = item[0].split(']')[0]
|
||||||
try:
|
try:
|
||||||
publishedDate = \
|
published_date = \
|
||||||
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S%z")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('EX: _html_newswire bad date format ' + dateStr)
|
print('EX: _html_newswire bad date format ' + date_str)
|
||||||
continue
|
continue
|
||||||
dateShown = publishedDate.strftime("%Y-%m-%d %H:%M")
|
date_shown = published_date.strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
dateStrLink = dateStr.replace('T', ' ')
|
date_str_link = date_str.replace('T', ' ')
|
||||||
dateStrLink = dateStrLink.replace('Z', '')
|
date_str_link = date_str_link.replace('Z', '')
|
||||||
url = item[1]
|
url = item[1]
|
||||||
faviconUrl = get_newswire_favicon_url(url)
|
favicon_url = get_newswire_favicon_url(url)
|
||||||
faviconLink = ''
|
favicon_link = ''
|
||||||
if faviconUrl:
|
if favicon_url:
|
||||||
cachedFaviconFilename = \
|
cached_favicon_filename = \
|
||||||
get_fav_filename_from_url(base_dir, faviconUrl)
|
get_fav_filename_from_url(base_dir, favicon_url)
|
||||||
if os.path.isfile(cachedFaviconFilename):
|
if os.path.isfile(cached_favicon_filename):
|
||||||
faviconUrl = \
|
favicon_url = \
|
||||||
cachedFaviconFilename.replace(base_dir, '')
|
cached_favicon_filename.replace(base_dir, '')
|
||||||
else:
|
else:
|
||||||
extensions = ('png', 'jpg', 'gif', 'avif', 'svg', 'webp')
|
extensions = ('png', 'jpg', 'gif', 'avif', 'svg', 'webp')
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
cachedFaviconFilename = \
|
cached_favicon_filename = \
|
||||||
get_fav_filename_from_url(base_dir, faviconUrl)
|
get_fav_filename_from_url(base_dir, favicon_url)
|
||||||
cachedFaviconFilename = \
|
cached_favicon_filename = \
|
||||||
cachedFaviconFilename.replace('.ico', '.' + ext)
|
cached_favicon_filename.replace('.ico', '.' + ext)
|
||||||
if os.path.isfile(cachedFaviconFilename):
|
if os.path.isfile(cached_favicon_filename):
|
||||||
faviconUrl = \
|
favicon_url = \
|
||||||
cachedFaviconFilename.replace(base_dir, '')
|
cached_favicon_filename.replace(base_dir, '')
|
||||||
|
|
||||||
faviconLink = \
|
favicon_link = \
|
||||||
'<img loading="lazy" src="' + faviconUrl + '" ' + \
|
'<img loading="lazy" src="' + favicon_url + '" ' + \
|
||||||
'alt="" ' + _get_broken_fav_substitute() + '/>'
|
'alt="" ' + _get_broken_fav_substitute() + '/>'
|
||||||
moderatedItem = item[5]
|
moderated_item = item[5]
|
||||||
htmlStr += separatorStr
|
html_str += separator_str
|
||||||
if moderatedItem and 'vote:' + nickname in item[2]:
|
if moderated_item and 'vote:' + nickname in item[2]:
|
||||||
totalVotesStr = ''
|
total_votes_str = ''
|
||||||
totalVotes = 0
|
total_votes = 0
|
||||||
if moderator:
|
if moderator:
|
||||||
totalVotes = votes_on_newswire_item(item[2])
|
total_votes = votes_on_newswire_item(item[2])
|
||||||
totalVotesStr = \
|
total_votes_str = \
|
||||||
_votes_indicator(totalVotes, positive_voting)
|
_votes_indicator(total_votes, positive_voting)
|
||||||
|
|
||||||
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
||||||
title = limit_repeated_words(title, 6)
|
title = limit_repeated_words(title, 6)
|
||||||
htmlStr += '<p class="newswireItemVotedOn">' + \
|
html_str += '<p class="newswireItemVotedOn">' + \
|
||||||
'<a href="' + url + '" target="_blank" ' + \
|
'<a href="' + url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
'<span class="newswireItemVotedOn">' + \
|
'<span class="newswireItemVotedOn">' + \
|
||||||
faviconLink + title + '</span></a>' + totalVotesStr
|
favicon_link + title + '</span></a>' + total_votes_str
|
||||||
if moderator:
|
if moderator:
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' ' + dateShown + '<a href="/users/' + nickname + \
|
' ' + date_shown + '<a href="/users/' + nickname + \
|
||||||
'/newswireunvote=' + dateStrLink + '" ' + \
|
'/newswireunvote=' + date_str_link + '" ' + \
|
||||||
'title="' + translate['Remove Vote'] + '">'
|
'title="' + translate['Remove Vote'] + '">'
|
||||||
htmlStr += '<img loading="lazy" class="voteicon" src="/' + \
|
html_str += '<img loading="lazy" class="voteicon" src="/' + \
|
||||||
'alt="' + translate['Remove Vote'] + '" ' + \
|
'alt="' + translate['Remove Vote'] + '" ' + \
|
||||||
'icons/vote.png" /></a></p>\n'
|
'icons/vote.png" /></a></p>\n'
|
||||||
else:
|
else:
|
||||||
htmlStr += ' <span class="newswireDateVotedOn">'
|
html_str += ' <span class="newswireDateVotedOn">'
|
||||||
htmlStr += dateShown + '</span></p>\n'
|
html_str += date_shown + '</span></p>\n'
|
||||||
else:
|
else:
|
||||||
totalVotesStr = ''
|
total_votes_str = ''
|
||||||
totalVotes = 0
|
total_votes = 0
|
||||||
if moderator:
|
if moderator:
|
||||||
if moderatedItem:
|
if moderated_item:
|
||||||
totalVotes = votes_on_newswire_item(item[2])
|
total_votes = votes_on_newswire_item(item[2])
|
||||||
# show a number of ticks or crosses for how many
|
# show a number of ticks or crosses for how many
|
||||||
# votes for or against
|
# votes for or against
|
||||||
totalVotesStr = \
|
total_votes_str = \
|
||||||
_votes_indicator(totalVotes, positive_voting)
|
_votes_indicator(total_votes, positive_voting)
|
||||||
|
|
||||||
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
||||||
title = limit_repeated_words(title, 6)
|
title = limit_repeated_words(title, 6)
|
||||||
if moderator and moderatedItem:
|
if moderator and moderated_item:
|
||||||
htmlStr += '<p class="newswireItemModerated">' + \
|
html_str += '<p class="newswireItemModerated">' + \
|
||||||
'<a href="' + url + '" target="_blank" ' + \
|
'<a href="' + url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
faviconLink + title + '</a>' + totalVotesStr
|
favicon_link + title + '</a>' + total_votes_str
|
||||||
htmlStr += ' ' + dateShown
|
html_str += ' ' + date_shown
|
||||||
htmlStr += '<a href="/users/' + nickname + \
|
html_str += '<a href="/users/' + nickname + \
|
||||||
'/newswirevote=' + dateStrLink + '" ' + \
|
'/newswirevote=' + date_str_link + '" ' + \
|
||||||
'title="' + translate['Vote'] + '">'
|
'title="' + translate['Vote'] + '">'
|
||||||
htmlStr += '<img class="voteicon" ' + \
|
html_str += '<img class="voteicon" ' + \
|
||||||
'alt="' + translate['Vote'] + '" ' + \
|
'alt="' + translate['Vote'] + '" ' + \
|
||||||
'src="/icons/vote.png" /></a>'
|
'src="/icons/vote.png" /></a>'
|
||||||
htmlStr += '</p>\n'
|
html_str += '</p>\n'
|
||||||
else:
|
else:
|
||||||
htmlStr += '<p class="newswireItem">' + \
|
html_str += '<p class="newswireItem">' + \
|
||||||
'<a href="' + url + '" target="_blank" ' + \
|
'<a href="' + url + '" target="_blank" ' + \
|
||||||
'rel="nofollow noopener noreferrer">' + \
|
'rel="nofollow noopener noreferrer">' + \
|
||||||
faviconLink + title + '</a>' + totalVotesStr
|
favicon_link + title + '</a>' + total_votes_str
|
||||||
htmlStr += ' <span class="newswireDate">'
|
html_str += ' <span class="newswireDate">'
|
||||||
htmlStr += dateShown + '</span></p>\n'
|
html_str += date_shown + '</span></p>\n'
|
||||||
|
|
||||||
if htmlStr:
|
if html_str:
|
||||||
htmlStr = '<nav>\n' + htmlStr + '</nav>\n'
|
html_str = '<nav>\n' + html_str + '</nav>\n'
|
||||||
return htmlStr
|
return html_str
|
||||||
|
|
||||||
|
|
||||||
def html_citations(base_dir: str, nickname: str, domain: str,
|
def html_citations(base_dir: str, nickname: str, domain: str,
|
||||||
http_prefix: str, default_timeline: str,
|
http_prefix: str, default_timeline: str,
|
||||||
translate: {}, newswire: {}, css_cache: {},
|
translate: {}, newswire: {}, css_cache: {},
|
||||||
blogTitle: str, blogContent: str,
|
blog_title: str, blog_content: str,
|
||||||
blogImageFilename: str,
|
blog_image_filename: str,
|
||||||
blogImageAttachmentMediaType: str,
|
blog_image_attachment_media_type: str,
|
||||||
blogImageDescription: str,
|
blog_image_description: str,
|
||||||
theme: str) -> str:
|
theme: str) -> str:
|
||||||
"""Show the citations screen when creating a blog
|
"""Show the citations screen when creating a blog
|
||||||
"""
|
"""
|
||||||
htmlStr = ''
|
html_str = ''
|
||||||
|
|
||||||
# create a list of dates for citations
|
# create a list of dates for citations
|
||||||
# these can then be used to re-select checkboxes later
|
# these can then be used to re-select checkboxes later
|
||||||
citationsFilename = \
|
citations_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
|
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
|
||||||
citationsSelected = []
|
citations_selected = []
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citations_filename):
|
||||||
citationsSeparator = '#####'
|
citations_separator = '#####'
|
||||||
with open(citationsFilename, 'r') as f:
|
with open(citations_filename, 'r') as fp_cit:
|
||||||
citations = f.readlines()
|
citations = fp_cit.readlines()
|
||||||
for line in citations:
|
for line in citations:
|
||||||
if citationsSeparator not in line:
|
if citations_separator not in line:
|
||||||
continue
|
continue
|
||||||
sections = line.strip().split(citationsSeparator)
|
sections = line.strip().split(citations_separator)
|
||||||
if len(sections) != 3:
|
if len(sections) != 3:
|
||||||
continue
|
continue
|
||||||
dateStr = sections[0]
|
date_str = sections[0]
|
||||||
citationsSelected.append(dateStr)
|
citations_selected.append(date_str)
|
||||||
|
|
||||||
# the css filename
|
# the css filename
|
||||||
css_filename = base_dir + '/epicyon-profile.css'
|
css_filename = base_dir + '/epicyon-profile.css'
|
||||||
|
@ -366,49 +366,49 @@ def html_citations(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
instance_title = \
|
instance_title = \
|
||||||
get_config_param(base_dir, 'instanceTitle')
|
get_config_param(base_dir, 'instanceTitle')
|
||||||
htmlStr = \
|
html_str = \
|
||||||
html_header_with_external_style(css_filename, instance_title, None)
|
html_header_with_external_style(css_filename, instance_title, None)
|
||||||
|
|
||||||
# top banner
|
# top banner
|
||||||
banner_file, banner_filename = \
|
banner_file, _ = \
|
||||||
get_banner_file(base_dir, nickname, domain, theme)
|
get_banner_file(base_dir, nickname, domain, theme)
|
||||||
htmlStr += \
|
html_str += \
|
||||||
'<a href="/users/' + nickname + '/newblog" title="' + \
|
'<a href="/users/' + nickname + '/newblog" title="' + \
|
||||||
translate['Go Back'] + '" alt="' + \
|
translate['Go Back'] + '" alt="' + \
|
||||||
translate['Go Back'] + '">\n'
|
translate['Go Back'] + '">\n'
|
||||||
htmlStr += '<img loading="lazy" class="timeline-banner" ' + \
|
html_str += '<img loading="lazy" class="timeline-banner" ' + \
|
||||||
'alt="" src="' + \
|
'alt="" src="' + \
|
||||||
'/users/' + nickname + '/' + banner_file + '" /></a>\n'
|
'/users/' + nickname + '/' + banner_file + '" /></a>\n'
|
||||||
|
|
||||||
htmlStr += \
|
html_str += \
|
||||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="/users/' + nickname + \
|
'accept-charset="UTF-8" action="/users/' + nickname + \
|
||||||
'/citationsdata">\n'
|
'/citationsdata">\n'
|
||||||
htmlStr += ' <center>\n'
|
html_str += ' <center>\n'
|
||||||
htmlStr += translate['Choose newswire items ' +
|
html_str += translate['Choose newswire items ' +
|
||||||
'referenced in your article'] + '<br>'
|
'referenced in your article'] + '<br>'
|
||||||
if blogTitle is None:
|
if blog_title is None:
|
||||||
blogTitle = ''
|
blog_title = ''
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <input type="hidden" name="blogTitle" value="' + \
|
' <input type="hidden" name="blogTitle" value="' + \
|
||||||
blogTitle + '">\n'
|
blog_title + '">\n'
|
||||||
if blogContent is None:
|
if blog_content is None:
|
||||||
blogContent = ''
|
blog_content = ''
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <input type="hidden" name="blogContent" value="' + \
|
' <input type="hidden" name="blogContent" value="' + \
|
||||||
blogContent + '">\n'
|
blog_content + '">\n'
|
||||||
# submit button
|
# submit button
|
||||||
htmlStr += \
|
html_str += \
|
||||||
' <input type="submit" name="submitCitations" value="' + \
|
' <input type="submit" name="submitCitations" value="' + \
|
||||||
translate['Submit'] + '">\n'
|
translate['Submit'] + '">\n'
|
||||||
htmlStr += ' </center>\n'
|
html_str += ' </center>\n'
|
||||||
|
|
||||||
citationsSeparator = '#####'
|
citations_separator = '#####'
|
||||||
|
|
||||||
# list of newswire items
|
# list of newswire items
|
||||||
if newswire:
|
if newswire:
|
||||||
ctr = 0
|
ctr = 0
|
||||||
for dateStr, item in newswire.items():
|
for date_str, item in newswire.items():
|
||||||
item[0] = remove_html(item[0]).strip()
|
item[0] = remove_html(item[0]).strip()
|
||||||
if not item[0]:
|
if not item[0]:
|
||||||
continue
|
continue
|
||||||
|
@ -418,32 +418,32 @@ def html_citations(base_dir: str, nickname: str, domain: str,
|
||||||
if ']' in item[0]:
|
if ']' in item[0]:
|
||||||
item[0] = item[0].split(']')[0]
|
item[0] = item[0].split(']')[0]
|
||||||
# should this checkbox be selected?
|
# should this checkbox be selected?
|
||||||
selectedStr = ''
|
selected_str = ''
|
||||||
if dateStr in citationsSelected:
|
if date_str in citations_selected:
|
||||||
selectedStr = ' checked'
|
selected_str = ' checked'
|
||||||
|
|
||||||
publishedDate = \
|
published_date = \
|
||||||
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S%z")
|
||||||
dateShown = publishedDate.strftime("%Y-%m-%d %H:%M")
|
date_shown = published_date.strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
title = remove_long_words(item[0], 16, []).replace('\n', '<br>')
|
||||||
title = limit_repeated_words(title, 6)
|
title = limit_repeated_words(title, 6)
|
||||||
link = item[1]
|
link = item[1]
|
||||||
|
|
||||||
citationValue = \
|
citation_value = \
|
||||||
dateStr + citationsSeparator + \
|
date_str + citations_separator + \
|
||||||
title + citationsSeparator + \
|
title + citations_separator + \
|
||||||
link
|
link
|
||||||
htmlStr += \
|
html_str += \
|
||||||
'<input type="checkbox" name="newswire' + str(ctr) + \
|
'<input type="checkbox" name="newswire' + str(ctr) + \
|
||||||
'" value="' + citationValue + '"' + selectedStr + '/>' + \
|
'" value="' + citation_value + '"' + selected_str + '/>' + \
|
||||||
'<a href="' + link + '"><cite>' + title + '</cite></a> '
|
'<a href="' + link + '"><cite>' + title + '</cite></a> '
|
||||||
htmlStr += '<span class="newswireDate">' + \
|
html_str += '<span class="newswireDate">' + \
|
||||||
dateShown + '</span><br>\n'
|
date_shown + '</span><br>\n'
|
||||||
ctr += 1
|
ctr += 1
|
||||||
|
|
||||||
htmlStr += '</form>\n'
|
html_str += '</form>\n'
|
||||||
return htmlStr + html_footer()
|
return html_str + html_footer()
|
||||||
|
|
||||||
|
|
||||||
def html_newswire_mobile(css_cache: {}, base_dir: str, nickname: str,
|
def html_newswire_mobile(css_cache: {}, base_dir: str, nickname: str,
|
||||||
|
@ -451,7 +451,7 @@ def html_newswire_mobile(css_cache: {}, base_dir: str, nickname: str,
|
||||||
http_prefix: str, translate: {},
|
http_prefix: str, translate: {},
|
||||||
newswire: {},
|
newswire: {},
|
||||||
positive_voting: bool,
|
positive_voting: bool,
|
||||||
timelinePath: str,
|
timeline_path: str,
|
||||||
show_publish_as_icon: bool,
|
show_publish_as_icon: bool,
|
||||||
authorized: bool,
|
authorized: bool,
|
||||||
rss_icon_at_top: bool,
|
rss_icon_at_top: bool,
|
||||||
|
@ -461,7 +461,7 @@ def html_newswire_mobile(css_cache: {}, base_dir: str, nickname: str,
|
||||||
access_keys: {}) -> str:
|
access_keys: {}) -> str:
|
||||||
"""Shows the mobile version of the newswire right column
|
"""Shows the mobile version of the newswire right column
|
||||||
"""
|
"""
|
||||||
htmlStr = ''
|
html_str = ''
|
||||||
|
|
||||||
# the css filename
|
# the css filename
|
||||||
css_filename = base_dir + '/epicyon-profile.css'
|
css_filename = base_dir + '/epicyon-profile.css'
|
||||||
|
@ -478,47 +478,47 @@ def html_newswire_mobile(css_cache: {}, base_dir: str, nickname: str,
|
||||||
# is the user a site editor?
|
# is the user a site editor?
|
||||||
editor = is_editor(base_dir, nickname)
|
editor = is_editor(base_dir, nickname)
|
||||||
|
|
||||||
showPublishButton = editor
|
show_publish_button = editor
|
||||||
|
|
||||||
instance_title = \
|
instance_title = \
|
||||||
get_config_param(base_dir, 'instanceTitle')
|
get_config_param(base_dir, 'instanceTitle')
|
||||||
htmlStr = \
|
html_str = \
|
||||||
html_header_with_external_style(css_filename, instance_title, None)
|
html_header_with_external_style(css_filename, instance_title, None)
|
||||||
|
|
||||||
banner_file, banner_filename = \
|
banner_file, _ = \
|
||||||
get_banner_file(base_dir, nickname, domain, theme)
|
get_banner_file(base_dir, nickname, domain, theme)
|
||||||
htmlStr += \
|
html_str += \
|
||||||
'<a href="/users/' + nickname + '/' + default_timeline + '" ' + \
|
'<a href="/users/' + nickname + '/' + default_timeline + '" ' + \
|
||||||
'accesskey="' + access_keys['menuTimeline'] + '">' + \
|
'accesskey="' + access_keys['menuTimeline'] + '">' + \
|
||||||
'<img loading="lazy" class="timeline-banner" ' + \
|
'<img loading="lazy" class="timeline-banner" ' + \
|
||||||
'alt="' + translate['Timeline banner image'] + '" ' + \
|
'alt="' + translate['Timeline banner image'] + '" ' + \
|
||||||
'src="/users/' + nickname + '/' + banner_file + '" /></a>\n'
|
'src="/users/' + nickname + '/' + banner_file + '" /></a>\n'
|
||||||
|
|
||||||
htmlStr += '<div class="col-right-mobile">\n'
|
html_str += '<div class="col-right-mobile">\n'
|
||||||
|
|
||||||
htmlStr += '<center>' + \
|
html_str += '<center>' + \
|
||||||
header_buttons_front_screen(translate, nickname,
|
header_buttons_front_screen(translate, nickname,
|
||||||
'newswire', authorized,
|
'newswire', authorized,
|
||||||
icons_as_buttons) + '</center>'
|
icons_as_buttons) + '</center>'
|
||||||
htmlStr += \
|
html_str += \
|
||||||
get_right_column_content(base_dir, nickname, domain_full,
|
get_right_column_content(base_dir, nickname, domain_full,
|
||||||
http_prefix, translate,
|
http_prefix, translate,
|
||||||
moderator, editor,
|
moderator, editor,
|
||||||
newswire, positive_voting,
|
newswire, positive_voting,
|
||||||
False, timelinePath, showPublishButton,
|
False, timeline_path, show_publish_button,
|
||||||
show_publish_as_icon, rss_icon_at_top, False,
|
show_publish_as_icon, rss_icon_at_top, False,
|
||||||
authorized, False, theme,
|
authorized, False, theme,
|
||||||
default_timeline, access_keys)
|
default_timeline, access_keys)
|
||||||
if editor and not newswire:
|
if editor and not newswire:
|
||||||
htmlStr += '<br><br><br>\n'
|
html_str += '<br><br><br>\n'
|
||||||
htmlStr += '<center>\n '
|
html_str += '<center>\n '
|
||||||
htmlStr += translate['Select the edit icon to add RSS feeds']
|
html_str += translate['Select the edit icon to add RSS feeds']
|
||||||
htmlStr += '\n</center>\n'
|
html_str += '\n</center>\n'
|
||||||
# end of col-right-mobile
|
# end of col-right-mobile
|
||||||
htmlStr += '</div\n>'
|
html_str += '</div\n>'
|
||||||
|
|
||||||
htmlStr += html_footer()
|
html_str += html_footer()
|
||||||
return htmlStr
|
return html_str
|
||||||
|
|
||||||
|
|
||||||
def html_edit_newswire(css_cache: {}, translate: {}, base_dir: str, path: str,
|
def html_edit_newswire(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
|
@ -545,115 +545,115 @@ def html_edit_newswire(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
css_filename = base_dir + '/links.css'
|
css_filename = base_dir + '/links.css'
|
||||||
|
|
||||||
# filename of the banner shown at the top
|
# filename of the banner shown at the top
|
||||||
banner_file, banner_filename = \
|
banner_file, _ = \
|
||||||
get_banner_file(base_dir, nickname, domain, theme)
|
get_banner_file(base_dir, nickname, domain, theme)
|
||||||
|
|
||||||
instance_title = \
|
instance_title = \
|
||||||
get_config_param(base_dir, 'instanceTitle')
|
get_config_param(base_dir, 'instanceTitle')
|
||||||
editNewswireForm = \
|
edit_newswire_form = \
|
||||||
html_header_with_external_style(css_filename, instance_title, None)
|
html_header_with_external_style(css_filename, instance_title, None)
|
||||||
|
|
||||||
# top banner
|
# top banner
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
'<header>' + \
|
'<header>' + \
|
||||||
'<a href="/users/' + nickname + '/' + default_timeline + \
|
'<a href="/users/' + nickname + '/' + default_timeline + \
|
||||||
'" title="' + \
|
'" title="' + \
|
||||||
translate['Switch to timeline view'] + '" alt="' + \
|
translate['Switch to timeline view'] + '" alt="' + \
|
||||||
translate['Switch to timeline view'] + '" ' + \
|
translate['Switch to timeline view'] + '" ' + \
|
||||||
'accesskey="' + access_keys['menuTimeline'] + '">\n'
|
'accesskey="' + access_keys['menuTimeline'] + '">\n'
|
||||||
editNewswireForm += '<img loading="lazy" class="timeline-banner" src="' + \
|
edit_newswire_form += \
|
||||||
|
'<img loading="lazy" class="timeline-banner" src="' + \
|
||||||
'/users/' + nickname + '/' + banner_file + '" ' + \
|
'/users/' + nickname + '/' + banner_file + '" ' + \
|
||||||
'alt="" /></a>\n</header>'
|
'alt="" /></a>\n</header>'
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="' + path + '/newswiredata">\n'
|
'accept-charset="UTF-8" action="' + path + '/newswiredata">\n'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <div class="vertical-center">\n'
|
' <div class="vertical-center">\n'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <h1>' + translate['Edit newswire'] + '</h1>'
|
' <h1>' + translate['Edit newswire'] + '</h1>'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <div class="containerSubmitNewPost">\n'
|
' <div class="containerSubmitNewPost">\n'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <input type="submit" name="submitNewswire" value="' + \
|
' <input type="submit" name="submitNewswire" value="' + \
|
||||||
translate['Submit'] + '" ' + \
|
translate['Submit'] + '" ' + \
|
||||||
'accesskey="' + access_keys['submitButton'] + '">\n'
|
'accesskey="' + access_keys['submitButton'] + '">\n'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' </div>\n'
|
' </div>\n'
|
||||||
|
|
||||||
newswireFilename = base_dir + '/accounts/newswire.txt'
|
newswire_filename = base_dir + '/accounts/newswire.txt'
|
||||||
newswireStr = ''
|
newswire_str = ''
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswire_filename):
|
||||||
with open(newswireFilename, 'r') as fp:
|
with open(newswire_filename, 'r') as fp_news:
|
||||||
newswireStr = fp.read()
|
newswire_str = fp_news.read()
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
'<div class="container">'
|
'<div class="container">'
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' ' + \
|
' ' + \
|
||||||
translate['Add RSS feed links below.'] + \
|
translate['Add RSS feed links below.'] + \
|
||||||
'<br>'
|
'<br>'
|
||||||
newFeedStr = translate['New feed URL']
|
new_feed_str = translate['New feed URL']
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
edit_text_field(None, 'newNewswireFeed', '', newFeedStr)
|
edit_text_field(None, 'newNewswireFeed', '', new_feed_str)
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <textarea id="message" name="editedNewswire" ' + \
|
' <textarea id="message" name="editedNewswire" ' + \
|
||||||
'style="height:80vh" spellcheck="false">' + \
|
'style="height:80vh" spellcheck="false">' + \
|
||||||
newswireStr + '</textarea>'
|
newswire_str + '</textarea>'
|
||||||
|
|
||||||
filterStr = ''
|
filter_str = ''
|
||||||
filterFilename = \
|
filter_filename = \
|
||||||
base_dir + '/accounts/news@' + domain + '/filters.txt'
|
base_dir + '/accounts/news@' + domain + '/filters.txt'
|
||||||
if os.path.isfile(filterFilename):
|
if os.path.isfile(filter_filename):
|
||||||
with open(filterFilename, 'r') as filterfile:
|
with open(filter_filename, 'r') as filterfile:
|
||||||
filterStr = filterfile.read()
|
filter_str = filterfile.read()
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <br><b><label class="labels">' + \
|
' <br><b><label class="labels">' + \
|
||||||
translate['Filtered words'] + '</label></b>\n'
|
translate['Filtered words'] + '</label></b>\n'
|
||||||
editNewswireForm += ' <br><label class="labels">' + \
|
edit_newswire_form += ' <br><label class="labels">' + \
|
||||||
translate['One per line'] + '</label>'
|
translate['One per line'] + '</label>'
|
||||||
editNewswireForm += ' <textarea id="message" ' + \
|
edit_newswire_form += ' <textarea id="message" ' + \
|
||||||
'name="filteredWordsNewswire" style="height:50vh" ' + \
|
'name="filteredWordsNewswire" style="height:50vh" ' + \
|
||||||
'spellcheck="true">' + filterStr + '</textarea>\n'
|
'spellcheck="true">' + filter_str + '</textarea>\n'
|
||||||
|
|
||||||
hashtagRulesStr = ''
|
hashtag_rules_str = ''
|
||||||
hashtagRulesFilename = \
|
hashtag_rules_filename = \
|
||||||
base_dir + '/accounts/hashtagrules.txt'
|
base_dir + '/accounts/hashtagrules.txt'
|
||||||
if os.path.isfile(hashtagRulesFilename):
|
if os.path.isfile(hashtag_rules_filename):
|
||||||
with open(hashtagRulesFilename, 'r') as rulesfile:
|
with open(hashtag_rules_filename, 'r') as rulesfile:
|
||||||
hashtagRulesStr = rulesfile.read()
|
hashtag_rules_str = rulesfile.read()
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <br><b><label class="labels">' + \
|
' <br><b><label class="labels">' + \
|
||||||
translate['News tagging rules'] + '</label></b>\n'
|
translate['News tagging rules'] + '</label></b>\n'
|
||||||
editNewswireForm += ' <br><label class="labels">' + \
|
edit_newswire_form += ' <br><label class="labels">' + \
|
||||||
translate['One per line'] + '.</label>\n'
|
translate['One per line'] + '.</label>\n'
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
' <a href="' + \
|
' <a href="' + \
|
||||||
'https://gitlab.com/bashrc2/epicyon/-/raw/main/hashtagrules.txt' + \
|
'https://gitlab.com/bashrc2/epicyon/-/raw/main/hashtagrules.txt' + \
|
||||||
'">' + translate['See instructions'] + '</a>\n'
|
'">' + translate['See instructions'] + '</a>\n'
|
||||||
editNewswireForm += ' <textarea id="message" ' + \
|
edit_newswire_form += ' <textarea id="message" ' + \
|
||||||
'name="hashtagRulesList" style="height:80vh" spellcheck="false">' + \
|
'name="hashtagRulesList" style="height:80vh" spellcheck="false">' + \
|
||||||
hashtagRulesStr + '</textarea>\n'
|
hashtag_rules_str + '</textarea>\n'
|
||||||
|
|
||||||
editNewswireForm += \
|
edit_newswire_form += \
|
||||||
'</div>'
|
'</div>'
|
||||||
|
|
||||||
editNewswireForm += html_footer()
|
edit_newswire_form += html_footer()
|
||||||
return editNewswireForm
|
return edit_newswire_form
|
||||||
|
|
||||||
|
|
||||||
def html_edit_news_post(css_cache: {}, translate: {}, base_dir: str, path: str,
|
def html_edit_news_post(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
domain: str, port: int,
|
domain: str, port: int, http_prefix: str, postUrl: str,
|
||||||
http_prefix: str, postUrl: str,
|
|
||||||
system_language: str) -> str:
|
system_language: str) -> str:
|
||||||
"""Edits a news post on the news/features timeline
|
"""Edits a news post on the news/features timeline
|
||||||
"""
|
"""
|
||||||
if '/users/' not in path:
|
if '/users/' not in path:
|
||||||
return ''
|
return ''
|
||||||
pathOriginal = path
|
path_original = path
|
||||||
|
|
||||||
nickname = get_nickname_from_actor(path)
|
nickname = get_nickname_from_actor(path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
|
@ -677,47 +677,47 @@ def html_edit_news_post(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
|
|
||||||
instance_title = \
|
instance_title = \
|
||||||
get_config_param(base_dir, 'instanceTitle')
|
get_config_param(base_dir, 'instanceTitle')
|
||||||
editNewsPostForm = \
|
edit_news_post_form = \
|
||||||
html_header_with_external_style(css_filename, instance_title, None)
|
html_header_with_external_style(css_filename, instance_title, None)
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="' + path + '/newseditdata">\n'
|
'accept-charset="UTF-8" action="' + path + '/newseditdata">\n'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <div class="vertical-center">\n'
|
' <div class="vertical-center">\n'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <h1>' + translate['Edit News Post'] + '</h1>'
|
' <h1>' + translate['Edit News Post'] + '</h1>'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <div class="container">\n'
|
' <div class="container">\n'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <a href="' + pathOriginal + '/tlnews">' + \
|
' <a href="' + path_original + '/tlnews">' + \
|
||||||
'<button class="cancelbtn">' + translate['Go Back'] + '</button></a>\n'
|
'<button class="cancelbtn">' + translate['Go Back'] + '</button></a>\n'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <input type="submit" name="submitEditedNewsPost" value="' + \
|
' <input type="submit" name="submitEditedNewsPost" value="' + \
|
||||||
translate['Submit'] + '">\n'
|
translate['Submit'] + '">\n'
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' </div>\n'
|
' </div>\n'
|
||||||
|
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
'<div class="container">'
|
'<div class="container">'
|
||||||
|
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <input type="hidden" name="newsPostUrl" value="' + \
|
' <input type="hidden" name="newsPostUrl" value="' + \
|
||||||
postUrl + '">\n'
|
postUrl + '">\n'
|
||||||
|
|
||||||
newsPostTitle = post_json_object['object']['summary']
|
news_post_title = post_json_object['object']['summary']
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <input type="text" name="newsPostTitle" value="' + \
|
' <input type="text" name="newsPostTitle" value="' + \
|
||||||
newsPostTitle + '"><br>\n'
|
news_post_title + '"><br>\n'
|
||||||
|
|
||||||
newsPostContent = get_base_content_from_post(post_json_object,
|
news_post_content = get_base_content_from_post(post_json_object,
|
||||||
system_language)
|
system_language)
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
' <textarea id="message" name="editedNewsPost" ' + \
|
' <textarea id="message" name="editedNewsPost" ' + \
|
||||||
'style="height:600px" spellcheck="true">' + \
|
'style="height:600px" spellcheck="true">' + \
|
||||||
newsPostContent + '</textarea>'
|
news_post_content + '</textarea>'
|
||||||
|
|
||||||
editNewsPostForm += \
|
edit_news_post_form += \
|
||||||
'</div>'
|
'</div>'
|
||||||
|
|
||||||
editNewsPostForm += html_footer()
|
edit_news_post_form += html_footer()
|
||||||
return editNewsPostForm
|
return edit_news_post_form
|
||||||
|
|
Loading…
Reference in New Issue