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