Alternative license representation. See https://blahaj.zone/notes/9ev0kge0aj

main
Bob Mottram 2023-05-17 21:31:50 +01:00
parent b1793ea22c
commit 51c97949f1
4 changed files with 29 additions and 2 deletions

View File

@ -630,8 +630,10 @@ def attach_media(base_dir: str, http_prefix: str,
]
if content_license_url:
attachment_json['schema:license'] = content_license_url
attachment_json['license'] = content_license_url
if creator:
attachment_json['schema:creator'] = creator
attachment_json['attribution'] = creator
if media_type.startswith('image/'):
attachment_json['blurhash'] = _get_blur_hash()
# find the dimensions of the image and add them as metadata

View File

@ -1146,6 +1146,7 @@ def _attach_post_license(post_json_object: {},
"value": content_license_url
})
post_json_object['schema:license'] = content_license_url
post_json_object['license'] = content_license_url
def _attach_buy_link(post_json_object: {},

View File

@ -1819,7 +1819,8 @@ def _get_content_license(post_json_object: {}) -> str:
"""
if not post_json_object['object'].get('attachment'):
if not post_json_object['object'].get('schema:license'):
return None
if not post_json_object['object'].get('license'):
return None
if post_json_object['object'].get('schema:license'):
value = post_json_object['object']['schema:license']
@ -1827,6 +1828,12 @@ def _get_content_license(post_json_object: {}) -> str:
value = license_link_from_name(value)
return value
if post_json_object['object'].get('license'):
value = post_json_object['object']['license']
if '://' not in value:
value = license_link_from_name(value)
return value
for item in post_json_object['object']['attachment']:
if not item.get('name'):
continue

View File

@ -1278,14 +1278,31 @@ def get_post_attachments_as_html(base_dir: str,
media_license = attach['schema:license']
else:
media_license = attach['schema:license']
elif attach.get('license'):
if not dangerous_markup(attach['license'], False):
if not is_filtered(base_dir, nickname, domain,
attach['license'],
system_language):
if '://' not in attach['license']:
if len(attach['license']) < 60:
media_license = attach['license']
else:
media_license = attach['license']
media_creator = ''
if attach.get('schema:creator'):
if len(attach['schema:creator']) < 60:
if len(attach['schema:creator']) < 120:
if not dangerous_markup(attach['schema:creator'], False):
if not is_filtered(base_dir, nickname, domain,
attach['schema:creator'],
system_language):
media_creator = attach['schema:creator']
elif attach.get('attribution'):
if len(attach['attribution']) < 120:
if not dangerous_markup(attach['attribution'], False):
if not is_filtered(base_dir, nickname, domain,
attach['attribution'],
system_language):
media_creator = attach['attribution']
media_type = attach['mediaType']
image_description = ''