mirror of https://gitlab.com/bashrc2/epicyon
merge-requests/30/head
commit
489e75c27a
13
posts.py
13
posts.py
|
@ -1133,6 +1133,17 @@ def _create_post_cw_from_reply(base_dir: str, nickname: str, domain: str,
|
||||||
return sensitive, summary
|
return sensitive, summary
|
||||||
|
|
||||||
|
|
||||||
|
def _attach_post_license(post_json_object: {},
|
||||||
|
content_license_url: str) -> None:
|
||||||
|
"""Attaches a license to each post
|
||||||
|
"""
|
||||||
|
post_json_object['attachment'].append({
|
||||||
|
"type": "PropertyValue",
|
||||||
|
"name": "license",
|
||||||
|
"value": content_license_url
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
http_prefix: str, content: str, status_number: str,
|
http_prefix: str, content: str, status_number: str,
|
||||||
published: str, new_post_id: str, post_context: {},
|
published: str, new_post_id: str, post_context: {},
|
||||||
|
@ -1205,6 +1216,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
new_post['object'], attach_image_filename,
|
new_post['object'], attach_image_filename,
|
||||||
media_type, image_description, city, low_bandwidth,
|
media_type, image_description, city, low_bandwidth,
|
||||||
content_license_url)
|
content_license_url)
|
||||||
|
_attach_post_license(new_post['object'], content_license_url)
|
||||||
return new_post
|
return new_post
|
||||||
|
|
||||||
|
|
||||||
|
@ -1270,6 +1282,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
new_post, attach_image_filename,
|
new_post, attach_image_filename,
|
||||||
media_type, image_description, city, low_bandwidth,
|
media_type, image_description, city, low_bandwidth,
|
||||||
content_license_url)
|
content_license_url)
|
||||||
|
_attach_post_license(new_post, content_license_url)
|
||||||
return new_post
|
return new_post
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1567,7 +1567,7 @@ def _get_footer_with_icons(show_icons: bool,
|
||||||
delete_str: str, mute_str: str, edit_str: str,
|
delete_str: str, mute_str: str, edit_str: str,
|
||||||
post_json_object: {}, published_link: str,
|
post_json_object: {}, published_link: str,
|
||||||
time_class: str, published_str: str,
|
time_class: str, published_str: str,
|
||||||
nickname: str) -> str:
|
nickname: str, content_license_url: str) -> str:
|
||||||
"""Returns the html for a post footer containing icons
|
"""Returns the html for a post footer containing icons
|
||||||
"""
|
"""
|
||||||
if not show_icons:
|
if not show_icons:
|
||||||
|
@ -1579,12 +1579,21 @@ def _get_footer_with_icons(show_icons: bool,
|
||||||
reply_str + announce_str + like_str + bookmark_str + reaction_str
|
reply_str + announce_str + like_str + bookmark_str + reaction_str
|
||||||
footer_str += delete_str + mute_str + edit_str
|
footer_str += delete_str + mute_str + edit_str
|
||||||
if not is_news_post(post_json_object):
|
if not is_news_post(post_json_object):
|
||||||
|
footer_str += ' '
|
||||||
|
if content_license_url:
|
||||||
|
# show the CC symbol
|
||||||
|
footer_str += '<a href="' + \
|
||||||
|
content_license_url + '" class="' + \
|
||||||
|
time_class + '" tabindex="10">' + \
|
||||||
|
'<span itemprop="license"> 🅭</span></a> '
|
||||||
|
# show the date
|
||||||
date_link = '/users/' + nickname + '?convthread=' + \
|
date_link = '/users/' + nickname + '?convthread=' + \
|
||||||
published_link.replace('/', '--')
|
published_link.replace('/', '--')
|
||||||
footer_str += ' <a href="' + date_link + '" class="' + \
|
footer_str += '<a href="' + date_link + '" class="' + \
|
||||||
time_class + '" tabindex="10"><span itemprop="datePublished">' + \
|
time_class + '" tabindex="10"><span itemprop="datePublished">' + \
|
||||||
published_str + '</span></a>\n'
|
published_str + '</span></a>\n'
|
||||||
else:
|
else:
|
||||||
|
# show the date
|
||||||
footer_str += ' <a href="' + \
|
footer_str += ' <a href="' + \
|
||||||
published_link.replace('/news/', '/news/statuses/') + \
|
published_link.replace('/news/', '/news/statuses/') + \
|
||||||
'" class="' + time_class + '" tabindex="10">' + \
|
'" class="' + time_class + '" tabindex="10">' + \
|
||||||
|
@ -1698,6 +1707,36 @@ def _add_dogwhistle_warnings(summary: str, content: str,
|
||||||
return summary
|
return summary
|
||||||
|
|
||||||
|
|
||||||
|
def _get_content_license(post_json_object: {}) -> str:
|
||||||
|
"""Returns the content license for the given post
|
||||||
|
"""
|
||||||
|
if not post_json_object['object'].get('attachment'):
|
||||||
|
return None
|
||||||
|
for item in post_json_object['object']['attachment']:
|
||||||
|
if not item.get('name'):
|
||||||
|
continue
|
||||||
|
if not item.get('value'):
|
||||||
|
continue
|
||||||
|
if item['name'] != 'license':
|
||||||
|
continue
|
||||||
|
value = item['value']
|
||||||
|
if '://' not in value:
|
||||||
|
if value in ('CC-BY-SA-NC', 'CC-BY-NC-SA'):
|
||||||
|
value = 'https://creativecommons.org/licenses/by-nc-sa/4.0'
|
||||||
|
elif value == 'CC-BY':
|
||||||
|
value = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
|
elif value in ('CC-BY-SA', 'CC-SA-BY'):
|
||||||
|
value = 'https://creativecommons.org/licenses/by-sa/4.0'
|
||||||
|
elif value == 'CC-BY-NC':
|
||||||
|
value = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||||
|
elif value == 'CC-BY-ND':
|
||||||
|
value = 'https://creativecommons.org/licenses/by-nc-nd/4.0'
|
||||||
|
else:
|
||||||
|
value = 'https://creativecommons.org/publicdomain/zero/1.0'
|
||||||
|
return value
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def individual_post_as_html(signing_priv_key_pem: str,
|
def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
allow_downloads: bool,
|
allow_downloads: bool,
|
||||||
recent_posts_cache: {}, max_recent_posts: int,
|
recent_posts_cache: {}, max_recent_posts: int,
|
||||||
|
@ -2310,6 +2349,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
if disallow_reply(content_all_str):
|
if disallow_reply(content_all_str):
|
||||||
reply_str = ''
|
reply_str = ''
|
||||||
|
|
||||||
|
content_license_url = _get_content_license(post_json_object)
|
||||||
new_footer_str = \
|
new_footer_str = \
|
||||||
_get_footer_with_icons(show_icons,
|
_get_footer_with_icons(show_icons,
|
||||||
container_class_icons,
|
container_class_icons,
|
||||||
|
@ -2317,7 +2357,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
like_str, reaction_str, bookmark_str,
|
like_str, reaction_str, bookmark_str,
|
||||||
delete_str, mute_str, edit_str,
|
delete_str, mute_str, edit_str,
|
||||||
post_json_object, published_link,
|
post_json_object, published_link,
|
||||||
time_class, published_str, nickname)
|
time_class, published_str, nickname,
|
||||||
|
content_license_url)
|
||||||
if new_footer_str:
|
if new_footer_str:
|
||||||
footer_str = new_footer_str
|
footer_str = new_footer_str
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue