mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
30e04544ae
commit
91bd28a664
183
blog.py
183
blog.py
|
@ -185,15 +185,15 @@ def _getBlogReplies(base_dir: str, http_prefix: str, translate: {},
|
|||
return ''
|
||||
|
||||
|
||||
def _htmlBlogPostContent(debug: bool, session, authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
peertube_instances: [],
|
||||
system_language: str,
|
||||
person_cache: {},
|
||||
blogSeparator: str = '<hr>') -> str:
|
||||
def _html_blog_post_content(debug: bool, session, authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
peertube_instances: [],
|
||||
system_language: str,
|
||||
person_cache: {},
|
||||
blogSeparator: str = '<hr>') -> str:
|
||||
"""Returns the content for a single blog post
|
||||
"""
|
||||
linkedAuthor = False
|
||||
|
@ -346,12 +346,12 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
|
|||
return blogStr
|
||||
|
||||
|
||||
def _htmlBlogPostRSS2(authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
system_language: str) -> str:
|
||||
def _html_blog_post_rss2(authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
system_language: str) -> str:
|
||||
"""Returns the RSS version 2 feed for a single blog post
|
||||
"""
|
||||
rssStr = ''
|
||||
|
@ -381,12 +381,12 @@ def _htmlBlogPostRSS2(authorized: bool,
|
|||
return rssStr
|
||||
|
||||
|
||||
def _htmlBlogPostRSS3(authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
system_language: str) -> str:
|
||||
def _html_blog_post_rss3(authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
handle: str, restrictToDomain: bool,
|
||||
system_language: str) -> str:
|
||||
"""Returns the RSS version 3 feed for a single blog post
|
||||
"""
|
||||
rssStr = ''
|
||||
|
@ -442,13 +442,13 @@ def _getSnippetFromBlogContent(post_json_object: {},
|
|||
return content
|
||||
|
||||
|
||||
def htmlBlogPost(session, authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
peertube_instances: [],
|
||||
system_language: str, person_cache: {},
|
||||
debug: bool, content_license_url: str) -> str:
|
||||
def html_blog_post(session, authorized: bool,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, domain_full: str,
|
||||
post_json_object: {},
|
||||
peertube_instances: [],
|
||||
system_language: str, person_cache: {},
|
||||
debug: bool, content_license_url: str) -> str:
|
||||
"""Returns a html blog post
|
||||
"""
|
||||
blogStr = ''
|
||||
|
@ -474,13 +474,13 @@ def htmlBlogPost(session, authorized: bool,
|
|||
content_license_url)
|
||||
_htmlBlogRemoveCwButton(blogStr, translate)
|
||||
|
||||
blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, post_json_object,
|
||||
None, False,
|
||||
peertube_instances, system_language,
|
||||
person_cache)
|
||||
blogStr += _html_blog_post_content(debug, session, authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, post_json_object,
|
||||
None, False,
|
||||
peertube_instances, system_language,
|
||||
person_cache)
|
||||
|
||||
# show rss links
|
||||
blogStr += '<p class="rssfeed">'
|
||||
|
@ -504,12 +504,12 @@ def htmlBlogPost(session, authorized: bool,
|
|||
return blogStr + htmlFooter()
|
||||
|
||||
|
||||
def htmlBlogPage(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
peertube_instances: [], system_language: str,
|
||||
person_cache: {}, debug: bool) -> str:
|
||||
def html_blog_page(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
peertube_instances: [], system_language: str,
|
||||
person_cache: {}, debug: bool) -> str:
|
||||
"""Returns a html blog page containing posts
|
||||
"""
|
||||
if ' ' in nickname or '@' in nickname or \
|
||||
|
@ -566,14 +566,15 @@ def htmlBlogPage(authorized: bool, session,
|
|||
if item['type'] != 'Create':
|
||||
continue
|
||||
|
||||
blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True,
|
||||
peertube_instances,
|
||||
system_language,
|
||||
person_cache)
|
||||
blogStr += _html_blog_post_content(debug, session, authorized,
|
||||
base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True,
|
||||
peertube_instances,
|
||||
system_language,
|
||||
person_cache)
|
||||
|
||||
if len(timelineJson['orderedItems']) >= noOfItems:
|
||||
blogStr += navigateStr
|
||||
|
@ -597,11 +598,11 @@ def htmlBlogPage(authorized: bool, session,
|
|||
return blogStr + htmlFooter()
|
||||
|
||||
|
||||
def htmlBlogPageRSS2(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
includeHeader: bool, system_language: str) -> str:
|
||||
def html_blog_page_rss2(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
includeHeader: bool, system_language: str) -> str:
|
||||
"""Returns an RSS version 2 feed containing posts
|
||||
"""
|
||||
if ' ' in nickname or '@' in nickname or \
|
||||
|
@ -640,11 +641,11 @@ def htmlBlogPageRSS2(authorized: bool, session,
|
|||
continue
|
||||
|
||||
blogRSS2 += \
|
||||
_htmlBlogPostRSS2(authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True, system_language)
|
||||
_html_blog_post_rss2(authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True, system_language)
|
||||
|
||||
if includeHeader:
|
||||
return blogRSS2 + rss2Footer()
|
||||
|
@ -652,11 +653,11 @@ def htmlBlogPageRSS2(authorized: bool, session,
|
|||
return blogRSS2
|
||||
|
||||
|
||||
def htmlBlogPageRSS3(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
system_language: str) -> str:
|
||||
def html_blog_page_rss3(authorized: bool, session,
|
||||
base_dir: str, http_prefix: str, translate: {},
|
||||
nickname: str, domain: str, port: int,
|
||||
noOfItems: int, pageNumber: int,
|
||||
system_language: str) -> str:
|
||||
"""Returns an RSS version 3 feed containing posts
|
||||
"""
|
||||
if ' ' in nickname or '@' in nickname or \
|
||||
|
@ -686,12 +687,12 @@ def htmlBlogPageRSS3(authorized: bool, session,
|
|||
continue
|
||||
|
||||
blogRSS3 += \
|
||||
_htmlBlogPostRSS3(authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True,
|
||||
system_language)
|
||||
_html_blog_post_rss3(authorized, base_dir,
|
||||
http_prefix, translate,
|
||||
nickname, domain,
|
||||
domain_full, item,
|
||||
None, True,
|
||||
system_language)
|
||||
|
||||
return blogRSS3
|
||||
|
||||
|
@ -727,12 +728,12 @@ def _singleBlogAccountNickname(base_dir: str) -> str:
|
|||
return None
|
||||
|
||||
|
||||
def htmlBlogView(authorized: bool,
|
||||
session, base_dir: str, http_prefix: str,
|
||||
translate: {}, domain: str, port: int,
|
||||
noOfItems: int,
|
||||
peertube_instances: [], system_language: str,
|
||||
person_cache: {}, debug: bool) -> str:
|
||||
def html_blog_view(authorized: bool,
|
||||
session, base_dir: str, http_prefix: str,
|
||||
translate: {}, domain: str, port: int,
|
||||
noOfItems: int,
|
||||
peertube_instances: [], system_language: str,
|
||||
person_cache: {}, debug: bool) -> str:
|
||||
"""Show the blog main page
|
||||
"""
|
||||
blogStr = ''
|
||||
|
@ -747,11 +748,11 @@ def htmlBlogView(authorized: bool,
|
|||
if _noOfBlogAccounts(base_dir) <= 1:
|
||||
nickname = _singleBlogAccountNickname(base_dir)
|
||||
if nickname:
|
||||
return htmlBlogPage(authorized, session,
|
||||
base_dir, http_prefix, translate,
|
||||
nickname, domain, port,
|
||||
noOfItems, 1, peertube_instances,
|
||||
system_language, person_cache, debug)
|
||||
return html_blog_page(authorized, session,
|
||||
base_dir, http_prefix, translate,
|
||||
nickname, domain, port,
|
||||
noOfItems, 1, peertube_instances,
|
||||
system_language, person_cache, debug)
|
||||
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
||||
|
@ -772,12 +773,12 @@ def htmlBlogView(authorized: bool,
|
|||
return blogStr + htmlFooter()
|
||||
|
||||
|
||||
def htmlEditBlog(media_instance: bool, translate: {},
|
||||
base_dir: str, http_prefix: str,
|
||||
path: str,
|
||||
pageNumber: int,
|
||||
nickname: str, domain: str,
|
||||
postUrl: str, system_language: str) -> str:
|
||||
def html_edit_blog(media_instance: bool, translate: {},
|
||||
base_dir: str, http_prefix: str,
|
||||
path: str,
|
||||
pageNumber: int,
|
||||
nickname: str, domain: str,
|
||||
postUrl: str, system_language: str) -> str:
|
||||
"""Edit a blog post after it was created
|
||||
"""
|
||||
post_filename = locate_post(base_dir, nickname, domain, postUrl)
|
||||
|
@ -917,9 +918,9 @@ def htmlEditBlog(media_instance: bool, translate: {},
|
|||
return editBlogForm
|
||||
|
||||
|
||||
def pathContainsBlogLink(base_dir: str,
|
||||
http_prefix: str, domain: str,
|
||||
domain_full: str, path: str) -> (str, str):
|
||||
def path_contains_blog_link(base_dir: str,
|
||||
http_prefix: str, domain: str,
|
||||
domain_full: str, path: str) -> (str, str):
|
||||
"""If the path contains a blog entry then return its filename
|
||||
"""
|
||||
if '/users/' not in path:
|
||||
|
@ -947,7 +948,7 @@ def pathContainsBlogLink(base_dir: str,
|
|||
return locate_post(base_dir, nickname, domain, messageId), nickname
|
||||
|
||||
|
||||
def getBlogAddress(actor_json: {}) -> str:
|
||||
def get_blog_address(actor_json: {}) -> str:
|
||||
"""Returns blog address for the given actor
|
||||
"""
|
||||
return get_actor_property_url(actor_json, 'Blog')
|
||||
|
|
251
daemon.py
251
daemon.py
|
@ -142,20 +142,20 @@ from blocking import remove_global_block
|
|||
from blocking import is_blocked_hashtag
|
||||
from blocking import is_blocked_domain
|
||||
from blocking import get_domain_blocklist
|
||||
from roles import getActorRolesList
|
||||
from roles import setRole
|
||||
from roles import clearModeratorStatus
|
||||
from roles import clearEditorStatus
|
||||
from roles import clearCounselorStatus
|
||||
from roles import clearArtistStatus
|
||||
from blog import pathContainsBlogLink
|
||||
from blog import htmlBlogPageRSS2
|
||||
from blog import htmlBlogPageRSS3
|
||||
from blog import htmlBlogView
|
||||
from blog import htmlBlogPage
|
||||
from blog import htmlBlogPost
|
||||
from blog import htmlEditBlog
|
||||
from blog import getBlogAddress
|
||||
from roles import get_actor_roles_list
|
||||
from roles import set_role
|
||||
from roles import clear_moderator_status
|
||||
from roles import clear_editor_status
|
||||
from roles import clear_counselor_status
|
||||
from roles import clear_artist_status
|
||||
from blog import path_contains_blog_link
|
||||
from blog import html_blog_page_rss2
|
||||
from blog import html_blog_page_rss3
|
||||
from blog import html_blog_view
|
||||
from blog import html_blog_page
|
||||
from blog import html_blog_post
|
||||
from blog import html_edit_blog
|
||||
from blog import get_blog_address
|
||||
from webapp_themeDesigner import htmlThemeDesigner
|
||||
from webapp_minimalbutton import setMinimal
|
||||
from webapp_minimalbutton import isMinimal
|
||||
|
@ -5312,7 +5312,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actorChanged = True
|
||||
|
||||
# change blog address
|
||||
currentBlogAddress = getBlogAddress(actor_json)
|
||||
currentBlogAddress = get_blog_address(actor_json)
|
||||
if fields.get('blogAddress'):
|
||||
if fields['blogAddress'] != currentBlogAddress:
|
||||
setBlogAddress(actor_json,
|
||||
|
@ -5639,7 +5639,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
moderatorsFile = \
|
||||
base_dir + \
|
||||
'/accounts/moderators.txt'
|
||||
clearModeratorStatus(base_dir)
|
||||
clear_moderator_status(base_dir)
|
||||
if ',' in fields['moderators']:
|
||||
# if the list was given as comma separated
|
||||
mods = fields['moderators'].split(',')
|
||||
|
@ -5665,9 +5665,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/accounts/' + modNick + \
|
||||
'@' + domain
|
||||
if os.path.isdir(modDir):
|
||||
setRole(base_dir,
|
||||
modNick, domain,
|
||||
'moderator')
|
||||
set_role(base_dir,
|
||||
modNick, domain,
|
||||
'moderator')
|
||||
else:
|
||||
# nicknames on separate lines
|
||||
mods = fields['moderators'].split('\n')
|
||||
|
@ -5696,9 +5696,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
modNick + '@' + \
|
||||
domain
|
||||
if os.path.isdir(modDir):
|
||||
setRole(base_dir,
|
||||
modNick, domain,
|
||||
'moderator')
|
||||
set_role(base_dir,
|
||||
modNick, domain,
|
||||
'moderator')
|
||||
|
||||
# change site editors list
|
||||
if fields.get('editors'):
|
||||
|
@ -5707,7 +5707,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
editorsFile = \
|
||||
base_dir + \
|
||||
'/accounts/editors.txt'
|
||||
clearEditorStatus(base_dir)
|
||||
clear_editor_status(base_dir)
|
||||
if ',' in fields['editors']:
|
||||
# if the list was given as comma separated
|
||||
eds = fields['editors'].split(',')
|
||||
|
@ -5730,9 +5730,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/accounts/' + edNick + \
|
||||
'@' + domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'editor')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'editor')
|
||||
else:
|
||||
# nicknames on separate lines
|
||||
eds = fields['editors'].split('\n')
|
||||
|
@ -5759,9 +5759,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
edNick + '@' + \
|
||||
domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'editor')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'editor')
|
||||
|
||||
# change site counselors list
|
||||
if fields.get('counselors'):
|
||||
|
@ -5770,7 +5770,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
counselorsFile = \
|
||||
base_dir + \
|
||||
'/accounts/counselors.txt'
|
||||
clearCounselorStatus(base_dir)
|
||||
clear_counselor_status(base_dir)
|
||||
if ',' in fields['counselors']:
|
||||
# if the list was given as comma separated
|
||||
eds = fields['counselors'].split(',')
|
||||
|
@ -5795,9 +5795,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/accounts/' + edNick + \
|
||||
'@' + domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'counselor')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'counselor')
|
||||
else:
|
||||
# nicknames on separate lines
|
||||
eds = fields['counselors'].split('\n')
|
||||
|
@ -5825,9 +5825,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
edNick + '@' + \
|
||||
domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'counselor')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'counselor')
|
||||
|
||||
# change site artists list
|
||||
if fields.get('artists'):
|
||||
|
@ -5836,7 +5836,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
artistsFile = \
|
||||
base_dir + \
|
||||
'/accounts/artists.txt'
|
||||
clearArtistStatus(base_dir)
|
||||
clear_artist_status(base_dir)
|
||||
if ',' in fields['artists']:
|
||||
# if the list was given as comma separated
|
||||
eds = fields['artists'].split(',')
|
||||
|
@ -5859,9 +5859,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'/accounts/' + edNick + \
|
||||
'@' + domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'artist')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'artist')
|
||||
else:
|
||||
# nicknames on separate lines
|
||||
eds = fields['artists'].split('\n')
|
||||
|
@ -5887,9 +5887,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
edNick + '@' + \
|
||||
domain
|
||||
if os.path.isdir(edDir):
|
||||
setRole(base_dir,
|
||||
edNick, domain,
|
||||
'artist')
|
||||
set_role(base_dir,
|
||||
edNick, domain,
|
||||
'artist')
|
||||
|
||||
# remove scheduled posts
|
||||
if fields.get('removeScheduledPosts'):
|
||||
|
@ -6858,17 +6858,17 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
|
||||
msg = \
|
||||
htmlBlogPageRSS2(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
self.server.translate,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
True,
|
||||
self.server.system_language)
|
||||
html_blog_page_rss2(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
self.server.translate,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
True,
|
||||
self.server.system_language)
|
||||
if msg is not None:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
@ -6908,17 +6908,17 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname = acct.split('@')[0]
|
||||
domain = acct.split('@')[1]
|
||||
msg += \
|
||||
htmlBlogPageRSS2(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
self.server.translate,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
False,
|
||||
self.server.system_language)
|
||||
html_blog_page_rss2(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
self.server.translate,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
False,
|
||||
self.server.system_language)
|
||||
break
|
||||
if msg:
|
||||
msg = rss2Header(http_prefix,
|
||||
|
@ -7026,13 +7026,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._404()
|
||||
return
|
||||
msg = \
|
||||
htmlBlogPageRSS3(authorized,
|
||||
self.server.session,
|
||||
base_dir, http_prefix,
|
||||
self.server.translate,
|
||||
nickname, domain, port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
system_language)
|
||||
html_blog_page_rss3(authorized,
|
||||
self.server.session,
|
||||
base_dir, http_prefix,
|
||||
self.server.translate,
|
||||
nickname, domain, port,
|
||||
max_posts_in_rss_feed, 1,
|
||||
system_language)
|
||||
if msg is not None:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
@ -7117,7 +7117,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
xmppAddress = get_xmpp_address(actor_json)
|
||||
matrixAddress = get_matrix_address(actor_json)
|
||||
ssbAddress = get_ssb_address(actor_json)
|
||||
blogAddress = getBlogAddress(actor_json)
|
||||
blogAddress = get_blog_address(actor_json)
|
||||
toxAddress = get_tox_address(actor_json)
|
||||
briarAddress = get_briar_address(actor_json)
|
||||
jamiAddress = get_jami_address(actor_json)
|
||||
|
@ -9689,7 +9689,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.server.keyShortcuts.get(nickname):
|
||||
accessKeys = self.server.keyShortcuts[nickname]
|
||||
|
||||
rolesList = getActorRolesList(actor_json)
|
||||
rolesList = get_actor_roles_list(actor_json)
|
||||
city = \
|
||||
getSpoofedCity(self.server.city,
|
||||
base_dir, nickname, domain)
|
||||
|
@ -9736,7 +9736,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.debug)
|
||||
else:
|
||||
if self._secure_mode():
|
||||
rolesList = getActorRolesList(actor_json)
|
||||
rolesList = get_actor_roles_list(actor_json)
|
||||
msg = json.dumps(rolesList,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
|
@ -12393,18 +12393,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
msg = htmlBlogPage(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
translate,
|
||||
nickname,
|
||||
domain, port,
|
||||
max_posts_in_blogs_feed, pageNumber,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug)
|
||||
msg = html_blog_page(authorized,
|
||||
self.server.session,
|
||||
base_dir,
|
||||
http_prefix,
|
||||
translate,
|
||||
nickname,
|
||||
domain, port,
|
||||
max_posts_in_blogs_feed, pageNumber,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug)
|
||||
if msg is not None:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
@ -14065,18 +14065,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not self._establishSession("show the main blog page"):
|
||||
self._404()
|
||||
return
|
||||
msg = htmlBlogView(authorized,
|
||||
self.server.session,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.translate,
|
||||
self.server.domain,
|
||||
self.server.port,
|
||||
max_posts_in_blogs_feed,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug)
|
||||
msg = html_blog_view(authorized,
|
||||
self.server.session,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.translate,
|
||||
self.server.domain,
|
||||
self.server.port,
|
||||
max_posts_in_blogs_feed,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug)
|
||||
if msg is not None:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
@ -14161,27 +14161,27 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.debug)
|
||||
# show blog post
|
||||
blogFilename, nickname = \
|
||||
pathContainsBlogLink(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.domain,
|
||||
self.server.domain_full,
|
||||
self.path)
|
||||
path_contains_blog_link(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.domain,
|
||||
self.server.domain_full,
|
||||
self.path)
|
||||
if blogFilename and nickname:
|
||||
post_json_object = load_json(blogFilename)
|
||||
if is_blog_post(post_json_object):
|
||||
msg = htmlBlogPost(self.server.session,
|
||||
authorized,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.translate,
|
||||
nickname, self.server.domain,
|
||||
self.server.domain_full,
|
||||
post_json_object,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug,
|
||||
self.server.content_license_url)
|
||||
msg = html_blog_post(self.server.session,
|
||||
authorized,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.server.translate,
|
||||
nickname, self.server.domain,
|
||||
self.server.domain_full,
|
||||
post_json_object,
|
||||
self.server.peertube_instances,
|
||||
self.server.system_language,
|
||||
self.server.person_cache,
|
||||
self.server.debug,
|
||||
self.server.content_license_url)
|
||||
if msg is not None:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
@ -15700,14 +15700,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
local_actor_url(self.server.http_prefix, nickname,
|
||||
self.server.domain_full) + \
|
||||
'/statuses/' + messageId
|
||||
msg = htmlEditBlog(self.server.media_instance,
|
||||
self.server.translate,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.path,
|
||||
replyPageNumber,
|
||||
nickname, self.server.domain,
|
||||
postUrl, self.server.system_language)
|
||||
msg = html_edit_blog(self.server.media_instance,
|
||||
self.server.translate,
|
||||
self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
self.path,
|
||||
replyPageNumber,
|
||||
nickname, self.server.domain,
|
||||
postUrl,
|
||||
self.server.system_language)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
|
|
@ -21,7 +21,7 @@ from person import remove_account
|
|||
from person import activate_account
|
||||
from person import deactivate_account
|
||||
from skills import setSkillLevel
|
||||
from roles import setRole
|
||||
from roles import set_role
|
||||
from webfinger import webfingerHandle
|
||||
from bookmarks import sendBookmarkViaServer
|
||||
from bookmarks import sendUndoBookmarkViaServer
|
||||
|
@ -2828,7 +2828,7 @@ if args.testdata:
|
|||
True, False, 'likewhateveryouwantscoob')
|
||||
setSkillLevel(base_dir, nickname, domain, 'testing', 60)
|
||||
setSkillLevel(base_dir, nickname, domain, 'typing', 50)
|
||||
setRole(base_dir, nickname, domain, 'admin')
|
||||
set_role(base_dir, nickname, domain, 'admin')
|
||||
setAvailability(base_dir, nickname, domain, 'busy')
|
||||
|
||||
addShare(base_dir,
|
||||
|
|
16
person.py
16
person.py
|
@ -34,9 +34,9 @@ from posts import createOutbox
|
|||
from posts import createModeration
|
||||
from auth import store_basic_credentials
|
||||
from auth import removePassword
|
||||
from roles import setRole
|
||||
from roles import setRolesFromList
|
||||
from roles import getActorRolesList
|
||||
from roles import set_role
|
||||
from roles import set_rolesFromList
|
||||
from roles import get_actor_roles_list
|
||||
from media import process_meta_data
|
||||
from utils import remove_html
|
||||
from utils import contains_invalid_chars
|
||||
|
@ -629,9 +629,9 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
|
|||
if nickname != 'news':
|
||||
# print(nickname+' becomes the instance admin and a moderator')
|
||||
set_config_param(base_dir, 'admin', nickname)
|
||||
setRole(base_dir, nickname, domain, 'admin')
|
||||
setRole(base_dir, nickname, domain, 'moderator')
|
||||
setRole(base_dir, nickname, domain, 'editor')
|
||||
set_role(base_dir, nickname, domain, 'admin')
|
||||
set_role(base_dir, nickname, domain, 'moderator')
|
||||
set_role(base_dir, nickname, domain, 'editor')
|
||||
|
||||
if not os.path.isdir(base_dir + '/accounts'):
|
||||
os.mkdir(base_dir + '/accounts')
|
||||
|
@ -820,12 +820,12 @@ def person_upgrade_actor(base_dir: str, personJson: {},
|
|||
|
||||
# if no roles are defined then ensure that the admin
|
||||
# roles are configured
|
||||
rolesList = getActorRolesList(personJson)
|
||||
rolesList = get_actor_roles_list(personJson)
|
||||
if not rolesList:
|
||||
admin_name = get_config_param(base_dir, 'admin')
|
||||
if personJson['id'].endswith('/users/' + admin_name):
|
||||
rolesList = ["admin", "moderator", "editor"]
|
||||
setRolesFromList(personJson, rolesList)
|
||||
set_rolesFromList(personJson, rolesList)
|
||||
updateActor = True
|
||||
|
||||
# remove the old roles format
|
||||
|
|
28
roles.py
28
roles.py
|
@ -34,14 +34,14 @@ def _clearRoleStatus(base_dir: str, role: str) -> None:
|
|||
actor_json = load_json(filename)
|
||||
if not actor_json:
|
||||
continue
|
||||
rolesList = getActorRolesList(actor_json)
|
||||
rolesList = get_actor_roles_list(actor_json)
|
||||
if role in rolesList:
|
||||
rolesList.remove(role)
|
||||
setRolesFromList(actor_json, rolesList)
|
||||
set_rolesFromList(actor_json, rolesList)
|
||||
save_json(actor_json, filename)
|
||||
|
||||
|
||||
def clearEditorStatus(base_dir: str) -> None:
|
||||
def clear_editor_status(base_dir: str) -> None:
|
||||
"""Removes editor status from all accounts
|
||||
This could be slow if there are many users, but only happens
|
||||
rarely when editors are appointed or removed
|
||||
|
@ -49,7 +49,7 @@ def clearEditorStatus(base_dir: str) -> None:
|
|||
_clearRoleStatus(base_dir, 'editor')
|
||||
|
||||
|
||||
def clearCounselorStatus(base_dir: str) -> None:
|
||||
def clear_counselor_status(base_dir: str) -> None:
|
||||
"""Removes counselor status from all accounts
|
||||
This could be slow if there are many users, but only happens
|
||||
rarely when counselors are appointed or removed
|
||||
|
@ -57,7 +57,7 @@ def clearCounselorStatus(base_dir: str) -> None:
|
|||
_clearRoleStatus(base_dir, 'editor')
|
||||
|
||||
|
||||
def clearArtistStatus(base_dir: str) -> None:
|
||||
def clear_artist_status(base_dir: str) -> None:
|
||||
"""Removes artist status from all accounts
|
||||
This could be slow if there are many users, but only happens
|
||||
rarely when artists are appointed or removed
|
||||
|
@ -65,7 +65,7 @@ def clearArtistStatus(base_dir: str) -> None:
|
|||
_clearRoleStatus(base_dir, 'artist')
|
||||
|
||||
|
||||
def clearModeratorStatus(base_dir: str) -> None:
|
||||
def clear_moderator_status(base_dir: str) -> None:
|
||||
"""Removes moderator status from all accounts
|
||||
This could be slow if there are many users, but only happens
|
||||
rarely when moderators are appointed or removed
|
||||
|
@ -182,7 +182,7 @@ def _setActorRole(actor_json: {}, roleName: str) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def setRolesFromList(actor_json: {}, rolesList: []) -> None:
|
||||
def set_rolesFromList(actor_json: {}, rolesList: []) -> None:
|
||||
"""Sets roles from a list
|
||||
"""
|
||||
# clear Roles from the occupation list
|
||||
|
@ -202,7 +202,7 @@ def setRolesFromList(actor_json: {}, rolesList: []) -> None:
|
|||
_setActorRole(actor_json, roleName)
|
||||
|
||||
|
||||
def getActorRolesList(actor_json: {}) -> []:
|
||||
def get_actor_roles_list(actor_json: {}) -> []:
|
||||
"""Gets a list of role names from an actor
|
||||
"""
|
||||
if not actor_json.get('hasOccupation'):
|
||||
|
@ -223,8 +223,8 @@ def getActorRolesList(actor_json: {}) -> []:
|
|||
return rolesList
|
||||
|
||||
|
||||
def setRole(base_dir: str, nickname: str, domain: str,
|
||||
role: str) -> bool:
|
||||
def set_role(base_dir: str, nickname: str, domain: str,
|
||||
role: str) -> bool:
|
||||
"""Set a person's role
|
||||
Setting the role to an empty string or None will remove it
|
||||
"""
|
||||
|
@ -246,7 +246,7 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
|||
if actor_json:
|
||||
if not actor_json.get('hasOccupation'):
|
||||
return False
|
||||
rolesList = getActorRolesList(actor_json)
|
||||
rolesList = get_actor_roles_list(actor_json)
|
||||
actorChanged = False
|
||||
if role:
|
||||
# add the role
|
||||
|
@ -255,7 +255,7 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
|||
if role not in rolesList:
|
||||
rolesList.append(role)
|
||||
rolesList.sort()
|
||||
setRolesFromList(actor_json, rolesList)
|
||||
set_rolesFromList(actor_json, rolesList)
|
||||
actorChanged = True
|
||||
else:
|
||||
# remove the role
|
||||
|
@ -263,7 +263,7 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
|||
_removeRole(base_dir, nickname, roleFiles[role])
|
||||
if role in rolesList:
|
||||
rolesList.remove(role)
|
||||
setRolesFromList(actor_json, rolesList)
|
||||
set_rolesFromList(actor_json, rolesList)
|
||||
actorChanged = True
|
||||
if actorChanged:
|
||||
save_json(actor_json, actorFilename)
|
||||
|
@ -273,5 +273,5 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
|||
def actorHasRole(actor_json: {}, roleName: str) -> bool:
|
||||
"""Returns true if the given actor has the given role
|
||||
"""
|
||||
rolesList = getActorRolesList(actor_json)
|
||||
rolesList = get_actor_roles_list(actor_json)
|
||||
return roleName in rolesList
|
||||
|
|
8
tests.py
8
tests.py
|
@ -101,8 +101,8 @@ from skills import setSkillLevel
|
|||
from skills import actor_skill_value
|
||||
from skills import setSkillsFromDict
|
||||
from skills import actor_has_skill
|
||||
from roles import setRolesFromList
|
||||
from roles import setRole
|
||||
from roles import set_rolesFromList
|
||||
from roles import set_role
|
||||
from roles import actorHasRole
|
||||
from auth import constantTimeStringCheck
|
||||
from auth import create_basic_auth_header
|
||||
|
@ -704,7 +704,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
|||
deleteAllPosts(path, nickname, domain, 'inbox')
|
||||
deleteAllPosts(path, nickname, domain, 'outbox')
|
||||
assert setSkillLevel(path, nickname, domain, 'hacking', 90)
|
||||
assert setRole(path, nickname, domain, 'guru')
|
||||
assert set_role(path, nickname, domain, 'guru')
|
||||
if hasFollows:
|
||||
follow_person(path, nickname, domain, 'bob', bobAddress,
|
||||
federation_list, False, False)
|
||||
|
@ -5496,7 +5496,7 @@ def _testRoles() -> None:
|
|||
]
|
||||
}
|
||||
testRolesList = ["admin", "moderator"]
|
||||
setRolesFromList(actor_json, testRolesList)
|
||||
set_rolesFromList(actor_json, testRolesList)
|
||||
assert actorHasRole(actor_json, "admin")
|
||||
assert actorHasRole(actor_json, "moderator")
|
||||
assert not actorHasRole(actor_json, "editor")
|
||||
|
|
|
@ -70,7 +70,7 @@ from webapp_utils import editTextField
|
|||
from webapp_utils import editTextArea
|
||||
from webapp_utils import beginEditSection
|
||||
from webapp_utils import endEditSection
|
||||
from blog import getBlogAddress
|
||||
from blog import get_blog_address
|
||||
from webapp_post import individualPostAsHtml
|
||||
from webapp_timeline import htmlIndividualShare
|
||||
from blocking import get_cw_list_variable
|
||||
|
@ -634,7 +634,7 @@ def htmlProfile(signing_priv_key_pem: str,
|
|||
donateSection = ''
|
||||
donateUrl = get_donation_url(profile_json)
|
||||
websiteUrl = get_website(profile_json, translate)
|
||||
blogAddress = getBlogAddress(profile_json)
|
||||
blogAddress = get_blog_address(profile_json)
|
||||
EnigmaPubKey = get_enigma_pub_key(profile_json)
|
||||
PGPpubKey = get_pgp_pub_key(profile_json)
|
||||
PGPfingerprint = get_pgp_fingerprint(profile_json)
|
||||
|
@ -2135,7 +2135,7 @@ def htmlEditProfile(css_cache: {}, translate: {}, base_dir: str, path: str,
|
|||
xmppAddress = get_xmpp_address(actor_json)
|
||||
matrixAddress = get_matrix_address(actor_json)
|
||||
ssbAddress = get_ssb_address(actor_json)
|
||||
blogAddress = getBlogAddress(actor_json)
|
||||
blogAddress = get_blog_address(actor_json)
|
||||
toxAddress = get_tox_address(actor_json)
|
||||
briarAddress = get_briar_address(actor_json)
|
||||
jamiAddress = get_jami_address(actor_json)
|
||||
|
|
Loading…
Reference in New Issue