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