From 903bedbf018c1f4d67c27691a5bda0e7e09cdc29 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 7 Nov 2022 11:15:08 +0000
Subject: [PATCH 1/7] Check that video site has a path
---
webapp_media.py | 67 ++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/webapp_media.py b/webapp_media.py
index f91ae26a2..441fa1f94 100644
--- a/webapp_media.py
+++ b/webapp_media.py
@@ -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 += \
- "\n\n" + \
- "\n" + \
- "\n\n"
- return content
+ if url:
+ content += \
+ "\n\n" + \
+ "\n" + \
+ "\n\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 += \
- "\n\n" + \
- "\n" + \
- "\n\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 += \
+ "\n\n" + \
+ "\n" + \
+ "\n\n"
+ return content
if '"https://' in content:
if peertube_instances:
From 99d6fbec20f73b8b3754a3f6aea6e5f29b590ae3 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 7 Nov 2022 16:00:16 +0000
Subject: [PATCH 2/7] Website and blog verified status
---
webapp_profile.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/webapp_profile.py b/webapp_profile.py
index f780fecba..f7f91dfca 100644
--- a/webapp_profile.py
+++ b/webapp_profile.py
@@ -726,11 +726,13 @@ def html_profile(signing_priv_key_pem: str,
if website_url:
donate_section += \
'' + translate['Website'] + ': ' + website_url + '
\n'
+ website_url + '" rel="me" tabindex="1">' + \
+ website_url + '
\n'
if gemini_link:
donate_section += \
'' + 'Gemini' + ': ' + gemini_link + '
\n'
+ gemini_link + '" tabindex="1">' + \
+ gemini_link + '\n'
if email_address:
donate_section += \
'' + translate['Email'] + ': ' + blog_address + '
\n'
+ blog_address + '" rel="me" tabindex="1">' + \
+ blog_address + '\n'
if xmpp_address:
donate_section += \
'' + translate['XMPP'] + ': 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()
+ following_list_csv += person_notes
+ msg = 'Account address,Show boosts,Notes\n' + following_list_csv
return msg
return ''
From 5a9ef67775a2e6b3b9de65a0e64ea14a47305c19 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 7 Nov 2022 18:38:20 +0000
Subject: [PATCH 5/7] Import notes from following csv
---
importFollowing.py | 18 +++++++++++++++++-
webapp_utils.py | 2 ++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/importFollowing.py b/importFollowing.py
index 021009683..f848e8e62 100644
--- a/importFollowing.py
+++ b/importFollowing.py
@@ -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,17 @@ def _update_import_following(base_dir: str,
# don't follow yourself
continue
following_handle = following_nickname + '@' + following_domain
+ if notes:
+ 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
diff --git a/webapp_utils.py b/webapp_utils.py
index cd97d0318..575785987 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -122,6 +122,8 @@ def csv_following_list(following_filename: str,
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(' ', ' ')
following_list_csv += person_notes
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
return msg
From 5fa549f011b4d34847f51c44b12e3b8b544661dc Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 7 Nov 2022 18:42:08 +0000
Subject: [PATCH 6/7] Handle newlines
---
webapp_utils.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/webapp_utils.py b/webapp_utils.py
index 575785987..ff6ffa833 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -123,6 +123,7 @@ def csv_following_list(following_filename: str,
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
person_notes = person_notes.replace(',', ' ')
+ person_notes = person_notes.replace('\n', ' ')
person_notes = person_notes.replace(' ', ' ')
following_list_csv += person_notes
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
From 7536c12761aee7582b2e0feb8a1d9cc9f71570bc Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 7 Nov 2022 18:44:17 +0000
Subject: [PATCH 7/7] Handle newlines
---
importFollowing.py | 1 +
webapp_utils.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/importFollowing.py b/importFollowing.py
index f848e8e62..de74ae990 100644
--- a/importFollowing.py
+++ b/importFollowing.py
@@ -80,6 +80,7 @@ def _update_import_following(base_dir: str,
continue
following_handle = following_nickname + '@' + following_domain
if notes:
+ notes = notes.replace('
', '\n')
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + following_handle + '.txt'
diff --git a/webapp_utils.py b/webapp_utils.py
index ff6ffa833..e75e39a38 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -123,7 +123,7 @@ def csv_following_list(following_filename: str,
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
person_notes = person_notes.replace(',', ' ')
- person_notes = person_notes.replace('\n', ' ')
+ person_notes = person_notes.replace('\n', '
')
person_notes = person_notes.replace(' ', ' ')
following_list_csv += person_notes
msg = 'Account address,Show boosts,Notes\n' + following_list_csv