Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-11-07 19:09:19 +00:00
commit 4555667aa8
6 changed files with 84 additions and 41 deletions

View File

@ -37,7 +37,7 @@ https://somesite/emoji3.png, :emojiname3:
Then this can be imported with:
```bash
python3 epicyon.py --import-emoji [textfile]
python3 epicyon.py --import_emoji [textfile]
```
## Themes

View File

@ -16518,7 +16518,10 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(following_filename)
msg = csv_following_list(following_filename,
self.server.base_dir,
nickname,
self.server.domain)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))
@ -16553,7 +16556,10 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(followers_filename)
msg = csv_following_list(followers_filename,
self.server.base_dir,
nickname,
self.server.domain)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))

View File

@ -10,6 +10,7 @@ __module_group__ = "Core"
import os
import time
import random
from utils import acct_dir
from utils import is_account_dir
from utils import get_nickname_from_actor
from utils import get_domain_from_actor
@ -58,9 +59,13 @@ def _update_import_following(base_dir: str,
domain = handle.split('@')[1]
for line in lines:
orig_line = line
notes = None
line = line.strip()
if ',' in line:
line = line.split(',')[0].strip()
fields = line.split(',')
line = fields[0].strip()
if len(fields) >= 3:
notes = fields[2]
if line.startswith('#'):
continue
following_nickname = get_nickname_from_actor(line)
@ -74,6 +79,18 @@ def _update_import_following(base_dir: str,
# don't follow yourself
continue
following_handle = following_nickname + '@' + following_domain
if notes:
notes = notes.replace('<br>', '\n')
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + following_handle + '.txt'
try:
with open(person_notes_filename, 'w+',
encoding='utf-8') as fp_notes:
fp_notes.write(notes)
except OSError:
print('EX: Unable to import notes for ' +
following_handle)
if is_following_actor(base_dir,
nickname, domain, following_handle):
# remove the followed handle from the import list

View File

@ -63,17 +63,18 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('>vimeo.com/')[1]
if '<' in url:
url = url.split('<')[0]
content += \
"<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" decoding=\"async\" " + \
"src=\"https://player.vimeo.com/video/" + \
url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen " + \
"tabindex=\"10\"></iframe>\n" + \
"</span>\n</center>\n"
return content
if url:
content += \
"<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" decoding=\"async\" " + \
"src=\"https://player.vimeo.com/video/" + \
url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen " + \
"tabindex=\"10\"></iframe>\n" + \
"</span>\n</center>\n"
return content
video_site = 'https://www.youtube.com'
if 'https://m.youtube.com' in content:
@ -82,7 +83,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
if '/channel/' not in url and '/playlist' not in url:
if url and '/channel/' not in url and '/playlist' not in url:
url = url.replace('/watch?v=', '/embed/')
if '&' in url:
url = url.split('&')[0]
@ -104,7 +105,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
if '/channel/' not in url and '/playlist' not in url:
if url and '/channel/' not in url and '/playlist' not in url:
url = 'embed/' + url
if '&' in url:
url = url.split('&')[0]
@ -140,7 +141,10 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
if '"' + video_site in content:
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0].replace('/watch?v=', '/embed/')
url = url.split('"')[0]
if not url:
continue
url = url.replace('/watch?v=', '/embed/')
if '&' in url:
url = url.split('&')[0]
if '?utm_' in url:
@ -174,23 +178,24 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
video_site_settings = ''
if '#' in url:
video_site_settings = '#' + url.split('#', 1)[1]
url = url.split('#')[0]
if not url.endswith('/oembed'):
url = url + '/oembed'
url += video_site_settings
content += \
"<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" " + \
"decoding=\"async\" src=\"" + \
video_site + url + "\" width=\"" + \
str(width) + "\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"</span>\n</center>\n"
return content
if url:
video_site_settings = ''
if '#' in url:
video_site_settings = '#' + url.split('#', 1)[1]
url = url.split('#')[0]
if not url.endswith('/oembed'):
url = url + '/oembed'
url += video_site_settings
content += \
"<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" " + \
"decoding=\"async\" src=\"" + \
video_site + url + "\" width=\"" + \
str(width) + "\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"</span>\n</center>\n"
return content
if '"https://' in content:
if peertube_instances:

View File

@ -726,11 +726,13 @@ def html_profile(signing_priv_key_pem: str,
if website_url:
donate_section += \
'<p>' + translate['Website'] + ': <a href="' + \
website_url + '" tabindex="1">' + website_url + '</a></p>\n'
website_url + '" rel="me" tabindex="1">' + \
website_url + '</a></p>\n'
if gemini_link:
donate_section += \
'<p>' + 'Gemini' + ': <a href="' + \
gemini_link + '" tabindex="1">' + gemini_link + '</a></p>\n'
gemini_link + '" tabindex="1">' + \
gemini_link + '</a></p>\n'
if email_address:
donate_section += \
'<p>' + translate['Email'] + ': <a href="mailto:' + \
@ -739,7 +741,8 @@ def html_profile(signing_priv_key_pem: str,
if blog_address:
donate_section += \
'<p>Blog: <a href="' + \
blog_address + '" tabindex="1">' + blog_address + '</a></p>\n'
blog_address + '" rel="me" tabindex="1">' + \
blog_address + '</a></p>\n'
if xmpp_address:
donate_section += \
'<p>' + translate['XMPP'] + ': <a href="xmpp:' + \

View File

@ -99,7 +99,8 @@ def html_following_list(base_dir: str, following_filename: str) -> str:
return ''
def csv_following_list(following_filename: str) -> str:
def csv_following_list(following_filename: str,
base_dir: str, nickname: str, domain: str) -> str:
"""Returns a csv of handles being followed
"""
with open(following_filename, 'r', encoding='utf-8') as following_file:
@ -113,8 +114,19 @@ def csv_following_list(following_filename: str) -> str:
continue
if following_list_csv:
following_list_csv += '\n'
following_list_csv += following_address + ',true'
msg = 'Account address,Show boosts\n' + following_list_csv
following_list_csv += following_address + ',true,'
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + following_address + '.txt'
if os.path.isfile(person_notes_filename):
with open(person_notes_filename, 'r',
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
person_notes = person_notes.replace(',', ' ')
person_notes = person_notes.replace('\n', '<br>')
person_notes = person_notes.replace(' ', ' ')
following_list_csv += person_notes
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
return msg
return ''