mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
9f0a12731a
commit
37da0662e4
|
@ -44,7 +44,7 @@ def _get_left_column_shares(base_dir: str,
|
|||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
# NOTE: this could potentially be slow if the number of federated
|
||||
# shared items is large
|
||||
shares_json, last_page = \
|
||||
shares_json, _ = \
|
||||
shares_timeline_json(actor, page_number, max_shares_in_left_column,
|
||||
base_dir, domain, nickname,
|
||||
max_shares_in_left_column,
|
||||
|
@ -54,7 +54,7 @@ def _get_left_column_shares(base_dir: str,
|
|||
|
||||
links_list = []
|
||||
ctr = 0
|
||||
for published, item in shares_json.items():
|
||||
for _, item in shares_json.items():
|
||||
sharedesc = item['displayName']
|
||||
if '<' in sharedesc or '?' in sharedesc:
|
||||
continue
|
||||
|
@ -63,9 +63,9 @@ def _get_left_column_shares(base_dir: str,
|
|||
share_link = actor + '?showshare=' + share_id
|
||||
if item.get('category'):
|
||||
share_link += '?category=' + item['category']
|
||||
shareCategory = share_category_icon(item['category'])
|
||||
share_category = share_category_icon(item['category'])
|
||||
|
||||
links_list.append(shareCategory + sharedesc + ' ' + share_link)
|
||||
links_list.append(share_category + sharedesc + ' ' + share_link)
|
||||
ctr += 1
|
||||
if ctr >= max_shares_in_left_column:
|
||||
break
|
||||
|
@ -87,7 +87,7 @@ def _get_left_column_wanted(base_dir: str,
|
|||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
# NOTE: this could potentially be slow if the number of federated
|
||||
# wanted items is large
|
||||
shares_json, last_page = \
|
||||
shares_json, _ = \
|
||||
shares_timeline_json(actor, page_number, max_shares_in_left_column,
|
||||
base_dir, domain, nickname,
|
||||
max_shares_in_left_column,
|
||||
|
@ -97,7 +97,7 @@ def _get_left_column_wanted(base_dir: str,
|
|||
|
||||
links_list = []
|
||||
ctr = 0
|
||||
for published, item in shares_json.items():
|
||||
for _, item in shares_json.items():
|
||||
sharedesc = item['displayName']
|
||||
if '<' in sharedesc or ';' in sharedesc:
|
||||
continue
|
||||
|
@ -117,9 +117,9 @@ def _get_left_column_wanted(base_dir: str,
|
|||
def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
||||
http_prefix: str, translate: {},
|
||||
editor: bool, artist: bool,
|
||||
showBackButton: bool, timelinePath: str,
|
||||
rss_icon_at_top: bool, showHeaderImage: bool,
|
||||
frontPage: bool, theme: str,
|
||||
show_back_button: bool, timelinePath: str,
|
||||
rss_icon_at_top: bool, show_header_image: bool,
|
||||
front_page: bool, theme: str,
|
||||
access_keys: {},
|
||||
shared_items_federated_domains: []) -> str:
|
||||
"""Returns html content for the left column
|
||||
|
@ -129,31 +129,31 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
|||
separator_str = html_post_separator(base_dir, 'left')
|
||||
domain = remove_domain_port(domain_full)
|
||||
|
||||
editImageClass = ''
|
||||
if showHeaderImage:
|
||||
leftImageFile, leftColumnImageFilename = \
|
||||
edit_image_class = ''
|
||||
if show_header_image:
|
||||
left_image_file, left_column_image_filename = \
|
||||
get_left_image_file(base_dir, nickname, domain, theme)
|
||||
|
||||
# show the image at the top of the column
|
||||
editImageClass = 'leftColEdit'
|
||||
if os.path.isfile(leftColumnImageFilename):
|
||||
editImageClass = 'leftColEditImage'
|
||||
edit_image_class = 'leftColEdit'
|
||||
if os.path.isfile(left_column_image_filename):
|
||||
edit_image_class = 'leftColEditImage'
|
||||
html_str += \
|
||||
'\n <center>\n <img class="leftColImg" ' + \
|
||||
'alt="" loading="lazy" src="/users/' + \
|
||||
nickname + '/' + leftImageFile + '" />\n' + \
|
||||
nickname + '/' + left_image_file + '" />\n' + \
|
||||
' </center>\n'
|
||||
|
||||
if showBackButton:
|
||||
if show_back_button:
|
||||
html_str += \
|
||||
' <div> <a href="' + timelinePath + '">' + \
|
||||
'<button class="cancelbtn">' + \
|
||||
translate['Go Back'] + '</button></a>\n'
|
||||
|
||||
if (editor or rss_icon_at_top) and not showHeaderImage:
|
||||
if (editor or rss_icon_at_top) and not show_header_image:
|
||||
html_str += '<div class="columnIcons">'
|
||||
|
||||
if editImageClass == 'leftColEdit':
|
||||
if edit_image_class == 'leftColEdit':
|
||||
html_str += '\n <center>\n'
|
||||
|
||||
html_str += ' <div class="leftColIcons">\n'
|
||||
|
@ -163,7 +163,7 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
|||
html_str += \
|
||||
' <a href="/users/' + nickname + '/editlinks" ' + \
|
||||
'accesskey="' + access_keys['menuEdit'] + '">' + \
|
||||
'<img class="' + editImageClass + '" loading="lazy" alt="' + \
|
||||
'<img class="' + edit_image_class + '" loading="lazy" alt="' + \
|
||||
translate['Edit Links'] + ' | " title="' + \
|
||||
translate['Edit Links'] + '" src="/icons/edit.png" /></a>\n'
|
||||
|
||||
|
@ -172,82 +172,82 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
|||
html_str += \
|
||||
' <a href="/users/' + nickname + '/themedesigner" ' + \
|
||||
'accesskey="' + access_keys['menuThemeDesigner'] + '">' + \
|
||||
'<img class="' + editImageClass + '" loading="lazy" alt="' + \
|
||||
'<img class="' + edit_image_class + '" loading="lazy" alt="' + \
|
||||
translate['Theme Designer'] + ' | " title="' + \
|
||||
translate['Theme Designer'] + '" src="/icons/theme.png" /></a>\n'
|
||||
|
||||
# RSS icon
|
||||
if nickname != 'news':
|
||||
# rss feed for this account
|
||||
rssUrl = http_prefix + '://' + domain_full + \
|
||||
rss_url = http_prefix + '://' + domain_full + \
|
||||
'/blog/' + nickname + '/rss.xml'
|
||||
else:
|
||||
# rss feed for all accounts on the instance
|
||||
rssUrl = http_prefix + '://' + domain_full + '/blog/rss.xml'
|
||||
if not frontPage:
|
||||
rssTitle = translate['RSS feed for your blog']
|
||||
rss_url = http_prefix + '://' + domain_full + '/blog/rss.xml'
|
||||
if not front_page:
|
||||
rss_title = translate['RSS feed for your blog']
|
||||
else:
|
||||
rssTitle = translate['RSS feed for this site']
|
||||
rssIconStr = \
|
||||
' <a href="' + rssUrl + '"><img class="' + editImageClass + \
|
||||
'" loading="lazy" alt="' + rssTitle + '" title="' + rssTitle + \
|
||||
rss_title = translate['RSS feed for this site']
|
||||
rss_icon_str = \
|
||||
' <a href="' + rss_url + '"><img class="' + edit_image_class + \
|
||||
'" loading="lazy" alt="' + rss_title + '" title="' + rss_title + \
|
||||
'" src="/icons/logorss.png" /></a>\n'
|
||||
if rss_icon_at_top:
|
||||
html_str += rssIconStr
|
||||
html_str += rss_icon_str
|
||||
html_str += ' </div>\n'
|
||||
|
||||
if editImageClass == 'leftColEdit':
|
||||
if edit_image_class == 'leftColEdit':
|
||||
html_str += ' </center>\n'
|
||||
|
||||
if (editor or rss_icon_at_top) and not showHeaderImage:
|
||||
if (editor or rss_icon_at_top) and not show_header_image:
|
||||
html_str += '</div><br>'
|
||||
|
||||
# if showHeaderImage:
|
||||
# if show_header_image:
|
||||
# html_str += '<br>'
|
||||
|
||||
# flag used not to show the first separator
|
||||
first_separator_added = False
|
||||
|
||||
links_filename = base_dir + '/accounts/links.txt'
|
||||
linksFileContainsEntries = False
|
||||
links_file_contains_entries = False
|
||||
links_list = None
|
||||
if os.path.isfile(links_filename):
|
||||
with open(links_filename, 'r') as f:
|
||||
links_list = f.readlines()
|
||||
with open(links_filename, 'r') as fp_links:
|
||||
links_list = fp_links.readlines()
|
||||
|
||||
if not frontPage:
|
||||
if not front_page:
|
||||
# show a number of shares
|
||||
max_shares_in_left_column = 3
|
||||
sharesList = \
|
||||
shares_list = \
|
||||
_get_left_column_shares(base_dir,
|
||||
http_prefix, domain, domain_full, nickname,
|
||||
max_shares_in_left_column, translate,
|
||||
shared_items_federated_domains)
|
||||
if links_list and sharesList:
|
||||
links_list = sharesList + links_list
|
||||
if links_list and shares_list:
|
||||
links_list = shares_list + links_list
|
||||
|
||||
wantedList = \
|
||||
wanted_list = \
|
||||
_get_left_column_wanted(base_dir,
|
||||
http_prefix, domain, domain_full, nickname,
|
||||
max_shares_in_left_column, translate,
|
||||
shared_items_federated_domains)
|
||||
if links_list and wantedList:
|
||||
links_list = wantedList + links_list
|
||||
if links_list and wanted_list:
|
||||
links_list = wanted_list + links_list
|
||||
|
||||
newTabStr = ' target="_blank" rel="nofollow noopener noreferrer"'
|
||||
new_tab_str = ' target="_blank" rel="nofollow noopener noreferrer"'
|
||||
if links_list:
|
||||
html_str += '<nav>\n'
|
||||
for lineStr in links_list:
|
||||
if ' ' not in lineStr:
|
||||
if '#' not in lineStr:
|
||||
if '*' not in lineStr:
|
||||
if not lineStr.startswith('['):
|
||||
if not lineStr.startswith('=> '):
|
||||
for line_str in links_list:
|
||||
if ' ' not in line_str:
|
||||
if '#' not in line_str:
|
||||
if '*' not in line_str:
|
||||
if not line_str.startswith('['):
|
||||
if not line_str.startswith('=> '):
|
||||
continue
|
||||
lineStr = lineStr.strip()
|
||||
linkStr = None
|
||||
if not lineStr.startswith('['):
|
||||
words = lineStr.split(' ')
|
||||
line_str = line_str.strip()
|
||||
link_str = None
|
||||
if not line_str.startswith('['):
|
||||
words = line_str.split(' ')
|
||||
# get the link
|
||||
for word in words:
|
||||
if word == '#':
|
||||
|
@ -257,74 +257,74 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
|||
if word == '=>':
|
||||
continue
|
||||
if '://' in word:
|
||||
linkStr = word
|
||||
link_str = word
|
||||
break
|
||||
else:
|
||||
# markdown link
|
||||
if ']' not in lineStr:
|
||||
if ']' not in line_str:
|
||||
continue
|
||||
if '(' not in lineStr:
|
||||
if '(' not in line_str:
|
||||
continue
|
||||
if ')' not in lineStr:
|
||||
if ')' not in line_str:
|
||||
continue
|
||||
linkStr = lineStr.split('(')[1]
|
||||
if ')' not in linkStr:
|
||||
link_str = line_str.split('(')[1]
|
||||
if ')' not in link_str:
|
||||
continue
|
||||
linkStr = linkStr.split(')')[0]
|
||||
if '://' not in linkStr:
|
||||
link_str = link_str.split(')')[0]
|
||||
if '://' not in link_str:
|
||||
continue
|
||||
lineStr = lineStr.split('[')[1]
|
||||
if ']' not in lineStr:
|
||||
line_str = line_str.split('[')[1]
|
||||
if ']' not in line_str:
|
||||
continue
|
||||
lineStr = lineStr.split(']')[0]
|
||||
if linkStr:
|
||||
lineStr = lineStr.replace(linkStr, '').strip()
|
||||
line_str = line_str.split(']')[0]
|
||||
if link_str:
|
||||
line_str = line_str.replace(link_str, '').strip()
|
||||
# avoid any dubious scripts being added
|
||||
if '<' not in lineStr:
|
||||
if '<' not in line_str:
|
||||
# remove trailing comma if present
|
||||
if lineStr.endswith(','):
|
||||
lineStr = lineStr[:len(lineStr)-1]
|
||||
if line_str.endswith(','):
|
||||
line_str = line_str[:len(line_str)-1]
|
||||
# add link to the returned html
|
||||
if '?showshare=' not in linkStr and \
|
||||
'?showwarning=' not in linkStr:
|
||||
if '?showshare=' not in link_str and \
|
||||
'?showwarning=' not in link_str:
|
||||
html_str += \
|
||||
' <p><a href="' + linkStr + \
|
||||
'"' + newTabStr + '>' + \
|
||||
lineStr + '</a></p>\n'
|
||||
' <p><a href="' + link_str + \
|
||||
'"' + new_tab_str + '>' + \
|
||||
line_str + '</a></p>\n'
|
||||
else:
|
||||
html_str += \
|
||||
' <p><a href="' + linkStr + \
|
||||
'">' + lineStr + '</a></p>\n'
|
||||
linksFileContainsEntries = True
|
||||
elif lineStr.startswith('=> '):
|
||||
' <p><a href="' + link_str + \
|
||||
'">' + line_str + '</a></p>\n'
|
||||
links_file_contains_entries = True
|
||||
elif line_str.startswith('=> '):
|
||||
# gemini style link
|
||||
lineStr = lineStr.replace('=> ', '')
|
||||
lineStr = lineStr.replace(linkStr, '')
|
||||
line_str = line_str.replace('=> ', '')
|
||||
line_str = line_str.replace(link_str, '')
|
||||
# add link to the returned html
|
||||
if '?showshare=' not in linkStr and \
|
||||
'?showwarning=' not in linkStr:
|
||||
if '?showshare=' not in link_str and \
|
||||
'?showwarning=' not in link_str:
|
||||
html_str += \
|
||||
' <p><a href="' + linkStr + \
|
||||
'"' + newTabStr + '>' + \
|
||||
lineStr.strip() + '</a></p>\n'
|
||||
' <p><a href="' + link_str + \
|
||||
'"' + new_tab_str + '>' + \
|
||||
line_str.strip() + '</a></p>\n'
|
||||
else:
|
||||
html_str += \
|
||||
' <p><a href="' + linkStr + \
|
||||
'">' + lineStr.strip() + '</a></p>\n'
|
||||
linksFileContainsEntries = True
|
||||
' <p><a href="' + link_str + \
|
||||
'">' + line_str.strip() + '</a></p>\n'
|
||||
links_file_contains_entries = True
|
||||
else:
|
||||
if lineStr.startswith('#') or lineStr.startswith('*'):
|
||||
lineStr = lineStr[1:].strip()
|
||||
if line_str.startswith('#') or line_str.startswith('*'):
|
||||
line_str = line_str[1:].strip()
|
||||
if first_separator_added:
|
||||
html_str += separator_str
|
||||
first_separator_added = True
|
||||
html_str += \
|
||||
' <h3 class="linksHeader">' + \
|
||||
lineStr + '</h3>\n'
|
||||
line_str + '</h3>\n'
|
||||
else:
|
||||
html_str += \
|
||||
' <p>' + lineStr + '</p>\n'
|
||||
linksFileContainsEntries = True
|
||||
' <p>' + line_str + '</p>\n'
|
||||
links_file_contains_entries = True
|
||||
html_str += '</nav>\n'
|
||||
|
||||
if first_separator_added:
|
||||
|
@ -344,8 +344,8 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
|
|||
'<p class="login-text"><a href="/terms">' + \
|
||||
translate['Terms of Service'] + '</a></p>'
|
||||
|
||||
if linksFileContainsEntries and not rss_icon_at_top:
|
||||
html_str += '<br><div class="columnIcons">' + rssIconStr + '</div>'
|
||||
if links_file_contains_entries and not rss_icon_at_top:
|
||||
html_str += '<br><div class="columnIcons">' + rss_icon_str + '</div>'
|
||||
|
||||
return html_str
|
||||
|
||||
|
@ -382,7 +382,7 @@ def html_links_mobile(css_cache: {}, base_dir: str,
|
|||
get_config_param(base_dir, 'instanceTitle')
|
||||
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)
|
||||
html_str += \
|
||||
'<a href="/users/' + nickname + '/' + default_timeline + '" ' + \
|
||||
|
@ -525,8 +525,8 @@ def html_edit_links(css_cache: {}, translate: {}, base_dir: str, path: str,
|
|||
tos_filename = base_dir + '/accounts/tos.md'
|
||||
tos_str = ''
|
||||
if os.path.isfile(tos_filename):
|
||||
with open(tos_filename, 'r') as fp:
|
||||
tos_str = fp.read()
|
||||
with open(tos_filename, 'r') as fp_tos:
|
||||
tos_str = fp_tos.read()
|
||||
|
||||
edit_links_form += \
|
||||
'<div class="container">'
|
||||
|
|
Loading…
Reference in New Issue