diff --git a/posts.py b/posts.py
index a83c23a2a..6c9beeb80 100644
--- a/posts.py
+++ b/posts.py
@@ -1133,6 +1133,17 @@ def _create_post_cw_from_reply(base_dir: str, nickname: str, domain: str,
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,
http_prefix: str, content: str, status_number: str,
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,
media_type, image_description, city, low_bandwidth,
content_license_url)
+ _attach_post_license(new_post['object'], content_license_url)
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,
media_type, image_description, city, low_bandwidth,
content_license_url)
+ _attach_post_license(new_post, content_license_url)
return new_post
diff --git a/webapp_post.py b/webapp_post.py
index 9dc94656e..7a0df75e1 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -1567,7 +1567,7 @@ def _get_footer_with_icons(show_icons: bool,
delete_str: str, mute_str: str, edit_str: str,
post_json_object: {}, published_link: 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
"""
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
footer_str += delete_str + mute_str + edit_str
if not is_news_post(post_json_object):
+ footer_str += ' '
+ if content_license_url:
+ # show the CC symbol
+ footer_str += '' + \
+ ' 🅠'
+ # show the date
date_link = '/users/' + nickname + '?convthread=' + \
published_link.replace('/', '--')
- footer_str += ' \n'
else:
+ # show the date
footer_str += ' ' + \
@@ -1698,6 +1707,36 @@ def _add_dogwhistle_warnings(summary: str, content: str,
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,
allow_downloads: bool,
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):
reply_str = ''
+ content_license_url = _get_content_license(post_json_object)
new_footer_str = \
_get_footer_with_icons(show_icons,
container_class_icons,
@@ -2317,7 +2357,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
like_str, reaction_str, bookmark_str,
delete_str, mute_str, edit_str,
post_json_object, published_link,
- time_class, published_str, nickname)
+ time_class, published_str, nickname,
+ content_license_url)
if new_footer_str:
footer_str = new_footer_str