diff --git a/art.py b/art.py new file mode 100644 index 000000000..58bdb8a5c --- /dev/null +++ b/art.py @@ -0,0 +1,116 @@ +__filename__ = "art.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.5.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@libreserver.org" +__status__ = "Production" +__module_group__ = "Profile Metadata" + + +from utils import get_attachment_property_value +from utils import remove_html +from utils import string_contains +from utils import resembles_url + +art_fieldnames = ('art') + +art_sites = ( + 'etsy.com', 'shopify.com', 'folksy.com', 'aftcra.com', + 'justartisan.com', 'goimagine.com', 'artfire.com', + 'indiecart.com', 'madeit.com.au', 'icraftgifts.com', + 'felt.co.nz', 'shootproof.com', 'pixieset.com', + 'instaproofs.com', 'smugmug.com', 'singulart.com', + 'pic-time.com', 'zenfolio.com', 'photoshelter.com', + 'squarespace.com', 'alamy.com', 'shutterstock.com', + 'dreamstime.com', 'canstockphoto.com', + 'stock.adobe.com', 'gettyimages.', 'istockphoto.com', + 'stocksy.com', '500px.com', 'fineartamerica.com' +) + + +def get_art_site_url(actor_json: {}) -> str: + """Returns art site url for the given actor + """ + if not actor_json.get('attachment'): + return '' + if not isinstance(actor_json['attachment'], list): + return '' + for property_value in actor_json['attachment']: + if not property_value.get('type'): + continue + if not isinstance(property_value['type'], str): + continue + if not property_value['type'].endswith('PropertyValue'): + continue + prop_value_name, _ = \ + get_attachment_property_value(property_value) + if not prop_value_name: + continue + art_text = remove_html(property_value[prop_value_name]) + if not string_contains(art_text, art_sites): + continue + if not resembles_url(art_text): + continue + return art_text + return '' + + +def set_art_site_url(actor_json: {}, art_site_url: str) -> None: + """Sets art site url for the given actor + """ + art_site_url = remove_html(art_site_url) + if not resembles_url(art_site_url): + return + + if not actor_json.get('attachment'): + actor_json['attachment'] = [] + + # remove any existing value + property_found = None + for property_value in actor_json['attachment']: + name_value = None + if property_value.get('name'): + name_value = property_value['name'].lower() + elif property_value.get('schema:name'): + name_value = property_value['schema:name'].lower() + if not name_value: + continue + if not property_value.get('type'): + continue + if not string_contains(name_value, art_fieldnames): + continue + property_found = property_value + break + + if property_found: + actor_json['attachment'].remove(property_found) + + for property_value in actor_json['attachment']: + name_value = None + if property_value.get('name'): + name_value = property_value['name'] + elif property_value.get('schema:name'): + name_value = property_value['schema:name'] + if not name_value: + continue + if not property_value.get('type'): + continue + name_value = name_value.lower() + if not string_contains(name_value, art_fieldnames): + continue + if not property_value['type'].endswith('PropertyValue'): + continue + prop_value_name, _ = \ + get_attachment_property_value(property_value) + if not prop_value_name: + continue + property_value[prop_value_name] = remove_html(art_site_url) + return + + new_art = { + "type": "PropertyValue", + "name": "Art", + "value": remove_html(art_site_url) + } + actor_json['attachment'].append(new_art) diff --git a/daemon_post_profile.py b/daemon_post_profile.py index faf1eccb2..03b2fbfa1 100644 --- a/daemon_post_profile.py +++ b/daemon_post_profile.py @@ -85,6 +85,8 @@ from discord import get_discord from discord import set_discord from music import get_music_site_url from music import set_music_site_url +from art import get_art_site_url +from art import set_art_site_url from youtube import get_youtube from youtube import set_youtube from pixelfed import get_pixelfed @@ -2026,6 +2028,23 @@ def _profile_post_music_site_url(actor_json: {}, fields: {}, return actor_changed +def _profile_post_art_site_url(actor_json: {}, fields: {}, + actor_changed: bool) -> bool: + """ HTTP POST change art site url address + """ + current_art = get_art_site_url(actor_json) + if fields.get('artSiteUrl'): + if fields['artSiteUrl'] != current_art: + set_art_site_url(actor_json, + fields['artSiteUrl']) + actor_changed = True + else: + if current_art: + set_art_site_url(actor_json, '') + actor_changed = True + return actor_changed + + def _profile_post_discord(actor_json: {}, fields: {}, actor_changed: bool) -> bool: """ HTTP POST change discord channel address @@ -2960,6 +2979,10 @@ def profile_edit(self, calling_domain: str, cookie: str, _profile_post_music_site_url(actor_json, fields, actor_changed) + actor_changed = \ + _profile_post_art_site_url(actor_json, fields, + actor_changed) + actor_changed = \ _profile_post_peertube(actor_json, fields, actor_changed) diff --git a/daemon_utils.py b/daemon_utils.py index eb248e6ee..3c16c5375 100644 --- a/daemon_utils.py +++ b/daemon_utils.py @@ -46,6 +46,7 @@ from donate import get_website from donate import get_gemini_link from pronouns import get_pronouns from discord import get_discord +from art import get_art_site_url from music import get_music_site_url from youtube import get_youtube from pixelfed import get_pixelfed @@ -663,6 +664,7 @@ def show_person_options(self, calling_domain: str, path: str, pronouns = None pixelfed = None discord = None + art_site_url = None music_site_url = None youtube = None peertube = None @@ -697,6 +699,7 @@ def show_person_options(self, calling_domain: str, path: str, pronouns = get_pronouns(actor_json) pixelfed = get_pixelfed(actor_json) discord = get_discord(actor_json) + art_site_url = get_art_site_url(actor_json) music_site_url = get_music_site_url(actor_json) youtube = get_youtube(actor_json) peertube = get_peertube(actor_json) @@ -774,7 +777,8 @@ def show_person_options(self, calling_domain: str, path: str, repo_url, self.server.sites_unavailable, youtube, peertube, pixelfed, - discord, music_site_url) + discord, music_site_url, + art_site_url) if msg: msg = msg.encode('utf-8') msglen = len(msg) diff --git a/pgp.py b/pgp.py index 06d8a959c..3d18922c3 100644 --- a/pgp.py +++ b/pgp.py @@ -29,6 +29,7 @@ from session import post_json from pronouns import get_pronouns from pixelfed import get_pixelfed from discord import get_discord +from art import get_art_site_url from music import get_music_site_url from youtube import get_youtube from peertube import get_peertube @@ -762,6 +763,10 @@ def actor_to_vcard(actor: {}, domain: str, translate: {}) -> str: pixelfed = get_pixelfed(actor) if pixelfed: vcard_str += 'SOCIALPROFILE;SERVICE-TYPE=Pixelfed:' + pixelfed + '\n' + art_site_url = get_art_site_url(actor) + if art_site_url: + vcard_str += \ + 'SOCIALPROFILE;SERVICE-TYPE=Art:' + art_site_url + '\n' music_site_url = get_music_site_url(actor) if music_site_url: vcard_str += \ @@ -871,6 +876,11 @@ def actor_to_vcard_xml(actor: {}, domain: str, translate: {}) -> str: vcard_str += ' ' + \ 'youtube' + \ '' + youtube + '\n' + art_site_url = get_art_site_url(actor) + if art_site_url: + vcard_str += ' ' + \ + 'art' + \ + '' + art_site_url + '\n' music_site_url = get_music_site_url(actor) if music_site_url: vcard_str += ' ' + \ diff --git a/translations/ar.json b/translations/ar.json index 60b2172bc..89d7342f1 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -698,5 +698,6 @@ "Watermark image": "صورة العلامة المائية", "Apply a watermark to uploaded images": "إضافة علامة مائية على الصور التي تم تحميلها", "Pronouns": "الضمائر", - "Music": "موسيقى" + "Music": "موسيقى", + "Art": "فن" } diff --git a/translations/bn.json b/translations/bn.json index 24a596f58..7bc005298 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -698,5 +698,6 @@ "Watermark image": "ওয়াটারমার্ক ইমেজ", "Apply a watermark to uploaded images": "আপলোড করা ছবিগুলিতে একটি জলছাপ প্রয়োগ করুন", "Pronouns": "সর্বনাম", - "Music": "সঙ্গীত" + "Music": "সঙ্গীত", + "Art": "শিল্প" } diff --git a/translations/ca.json b/translations/ca.json index 0421ee041..3ffa1784d 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -698,5 +698,6 @@ "Watermark image": "Imatge de filigrana", "Apply a watermark to uploaded images": "Apliqueu una marca d'aigua a les imatges penjades", "Pronouns": "Els pronoms", - "Music": "Música" + "Music": "Música", + "Art": "Art" } diff --git a/translations/cy.json b/translations/cy.json index ced5e6778..5cd4bb13b 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -698,5 +698,6 @@ "Watermark image": "Delwedd dyfrnod", "Apply a watermark to uploaded images": "Cymhwyso dyfrnod i ddelweddau sydd wedi'u llwytho i fyny", "Pronouns": "Rhagenwau", - "Music": "Cerddoriaeth" + "Music": "Cerddoriaeth", + "Art": "Celf" } diff --git a/translations/de.json b/translations/de.json index c375658c7..0e89d998c 100644 --- a/translations/de.json +++ b/translations/de.json @@ -698,5 +698,6 @@ "Watermark image": "Wasserzeichenbild", "Apply a watermark to uploaded images": "Hochgeladenen Bildern ein Wasserzeichen hinzufügen", "Pronouns": "Pronomen", - "Music": "Musik" + "Music": "Musik", + "Art": "Kunst" } diff --git a/translations/el.json b/translations/el.json index 0cc959de0..a19c961c8 100644 --- a/translations/el.json +++ b/translations/el.json @@ -698,5 +698,6 @@ "Watermark image": "Εικόνα υδατογραφήματος", "Apply a watermark to uploaded images": "Εφαρμόστε ένα υδατογράφημα στις μεταφορτωμένες εικόνες", "Pronouns": "Αντωνυμίες", - "Music": "Μουσική" + "Music": "Μουσική", + "Art": "Τέχνη" } diff --git a/translations/en.json b/translations/en.json index a7a71d750..c0c7b6981 100644 --- a/translations/en.json +++ b/translations/en.json @@ -698,5 +698,6 @@ "Watermark image": "Watermark image", "Apply a watermark to uploaded images": "Apply a watermark to uploaded images", "Pronouns": "Pronouns", - "Music": "Music" + "Music": "Music", + "Art": "Art" } diff --git a/translations/es.json b/translations/es.json index 102c8aa9b..1c9697747 100644 --- a/translations/es.json +++ b/translations/es.json @@ -698,5 +698,6 @@ "Watermark image": "Imagen de marca de agua", "Apply a watermark to uploaded images": "Aplicar una marca de agua a las imágenes cargadas", "Pronouns": "Pronombres", - "Music": "Música" + "Music": "Música", + "Art": "Arte" } diff --git a/translations/fa.json b/translations/fa.json index 53acd8217..913feffbc 100644 --- a/translations/fa.json +++ b/translations/fa.json @@ -698,5 +698,6 @@ "Watermark image": "تصویر واترمارک", "Apply a watermark to uploaded images": "اعمال واترمارک روی تصاویر آپلود شده", "Pronouns": "ضمایر", - "Music": "موسیقی" + "Music": "موسیقی", + "Art": "هنر" } diff --git a/translations/fi.json b/translations/fi.json index 0e292d82d..4e73d8cad 100644 --- a/translations/fi.json +++ b/translations/fi.json @@ -698,5 +698,6 @@ "Watermark image": "Vesileiman kuva", "Apply a watermark to uploaded images": "Lisää ladattuihin kuviin vesileima", "Pronouns": "Pronominit", - "Music": "Musiikki" + "Music": "Musiikki", + "Art": "Taide" } diff --git a/translations/fr.json b/translations/fr.json index 715cd77f6..23585dc6c 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -698,5 +698,6 @@ "Watermark image": "Image en filigrane", "Apply a watermark to uploaded images": "Appliquer un filigrane aux images téléchargées", "Pronouns": "Pronoms", - "Music": "Musique" + "Music": "Musique", + "Art": "Art" } diff --git a/translations/ga.json b/translations/ga.json index 4bcd57368..35c1a2bf3 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -698,5 +698,6 @@ "Watermark image": "Íomhá comhartha uisce", "Apply a watermark to uploaded images": "Cuir comhartha uisce i bhfeidhm ar íomhánna uaslódáilte", "Pronouns": "Forainmneacha", - "Music": "Ceol" + "Music": "Ceol", + "Art": "Ealaín" } diff --git a/translations/he.json b/translations/he.json index 043d85c88..2c1b8deab 100644 --- a/translations/he.json +++ b/translations/he.json @@ -698,5 +698,6 @@ "Watermark image": "תמונת סימן מים", "Apply a watermark to uploaded images": "החל סימן מים על תמונות שהועלו", "Pronouns": "כינויים", - "Music": "מוּסִיקָה" + "Music": "מוּסִיקָה", + "Art": "אָמָנוּת" } diff --git a/translations/hi.json b/translations/hi.json index ba26149b4..771fd7fd9 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -698,5 +698,6 @@ "Watermark image": "वॉटरमार्क छवि", "Apply a watermark to uploaded images": "अपलोड की गई छवियों पर वॉटरमार्क लागू करें", "Pronouns": "सर्वनाम", - "Music": "संगीत" + "Music": "संगीत", + "Art": "कला" } diff --git a/translations/it.json b/translations/it.json index 99daa9961..603bb14f7 100644 --- a/translations/it.json +++ b/translations/it.json @@ -698,5 +698,6 @@ "Watermark image": "Immagine filigrana", "Apply a watermark to uploaded images": "Applicare una filigrana alle immagini caricate", "Pronouns": "Pronomi", - "Music": "Musica" + "Music": "Musica", + "Art": "Arte" } diff --git a/translations/ja.json b/translations/ja.json index 2faeb375e..90a5ea69f 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -698,5 +698,6 @@ "Watermark image": "透かし画像", "Apply a watermark to uploaded images": "アップロードした画像に透かしを適用する", "Pronouns": "代名詞", - "Music": "音楽" + "Music": "音楽", + "Art": "美術" } diff --git a/translations/ko.json b/translations/ko.json index 59d8f50ef..f57b05737 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -698,5 +698,6 @@ "Watermark image": "워터마크 이미지", "Apply a watermark to uploaded images": "업로드한 이미지에 워터마크를 적용합니다", "Pronouns": "대명사", - "Music": "음악" + "Music": "음악", + "Art": "미술" } diff --git a/translations/ku.json b/translations/ku.json index 6103affe6..304b47fff 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -698,5 +698,6 @@ "Watermark image": "Wêneyê Watermark", "Apply a watermark to uploaded images": "Li ser wêneyên barkirî ava nîşanek bicîh bikin", "Pronouns": "Cînavk", - "Music": "Mûzîk" + "Music": "Mûzîk", + "Art": "Fen" } diff --git a/translations/nl.json b/translations/nl.json index 9df0b1d46..f69ed1e54 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -698,5 +698,6 @@ "Watermark image": "Watermerk afbeelding", "Apply a watermark to uploaded images": "Een watermerk toepassen op geüploade afbeeldingen", "Pronouns": "Voornaamwoorden", - "Music": "Muziek" + "Music": "Muziek", + "Art": "Kunst" } diff --git a/translations/oc.json b/translations/oc.json index 8cadbb41f..7098de9bc 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -694,5 +694,6 @@ "Watermark image": "Watermark image", "Apply a watermark to uploaded images": "Apply a watermark to uploaded images", "Pronouns": "Pronouns", - "Music": "Music" + "Music": "Music", + "Art": "Art" } diff --git a/translations/pl.json b/translations/pl.json index 04e8f9115..4d6b58f45 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -698,5 +698,6 @@ "Watermark image": "Obraz znaku wodnego", "Apply a watermark to uploaded images": "Zastosuj znak wodny do przesłanych obrazów", "Pronouns": "Zaimki", - "Music": "Muzyka" + "Music": "Muzyka", + "Art": "Sztuka" } diff --git a/translations/pt.json b/translations/pt.json index ce3805e58..1b6a7bf21 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -698,5 +698,6 @@ "Watermark image": "Imagem de marca de água", "Apply a watermark to uploaded images": "Aplicar uma marca de água nas imagens enviadas", "Pronouns": "Pronomes", - "Music": "Música" + "Music": "Música", + "Art": "Arte" } diff --git a/translations/ru.json b/translations/ru.json index 6445e7431..fa187e546 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -698,5 +698,6 @@ "Watermark image": "Изображение водяного знака", "Apply a watermark to uploaded images": "Накладывать водяной знак на загружаемые изображения", "Pronouns": "Местоимения", - "Music": "Музыка" + "Music": "Музыка", + "Art": "Искусство" } diff --git a/translations/sw.json b/translations/sw.json index d13fa0d4a..85a4c8db8 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -698,5 +698,6 @@ "Watermark image": "Picha ya watermark", "Apply a watermark to uploaded images": "Tumia watermark kwa picha zilizopakiwa", "Pronouns": "Viwakilishi", - "Music": "Muziki" + "Music": "Muziki", + "Art": "Sanaa" } diff --git a/translations/tr.json b/translations/tr.json index bb8238e5b..64248cc86 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -698,5 +698,6 @@ "Watermark image": "Filigran resmi", "Apply a watermark to uploaded images": "Yüklenen görsellere filigran uygulayın", "Pronouns": "Zamirler", - "Music": "Müzik" + "Music": "Müzik", + "Art": "Sanat" } diff --git a/translations/uk.json b/translations/uk.json index 6cb33964c..d62086890 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -698,5 +698,6 @@ "Watermark image": "Зображення водяного знака", "Apply a watermark to uploaded images": "Застосування водяного знака до завантажених зображень", "Pronouns": "Займенники", - "Music": "музика" + "Music": "музика", + "Art": "ст" } diff --git a/translations/yi.json b/translations/yi.json index 9e7c5db75..977002eb8 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -698,5 +698,6 @@ "Watermark image": "וואָטערמאַרק בילד", "Apply a watermark to uploaded images": "צולייגן אַ וואָטערמאַרק צו ופּלאָאַדעד בילדער", "Pronouns": "פּראָנאָונס", - "Music": "מוזיק" + "Music": "מוזיק", + "Art": "קונסט" } diff --git a/translations/zh.json b/translations/zh.json index 9eb52b061..2816e1af9 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -698,5 +698,6 @@ "Watermark image": "水印图像", "Apply a watermark to uploaded images": "将水印应用于上传的图像", "Pronouns": "代词", - "Music": "音乐" + "Music": "音乐", + "Art": "艺术" } diff --git a/webapp_person_options.py b/webapp_person_options.py index 96f688421..130f8a1db 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -174,7 +174,8 @@ def html_person_options(default_timeline: str, youtube: str, peertube: str, pixelfed: str, discord: str, - music_site_url: str) -> str: + music_site_url: str, + art_site_url: str) -> str: """Show options for a person: view/follow/block/report """ options_link_str = '' @@ -449,6 +450,11 @@ def html_person_options(default_timeline: str, '

Discord' + \ ': ' + \ discord + '

\n' + if art_site_url: + options_str += \ + '

' + translate['Art'] + \ + ': ' + \ + art_site_url + '

\n' if music_site_url: options_str += \ '

' + translate['Music'] + \ diff --git a/webapp_profile.py b/webapp_profile.py index b24bae8b3..9e1ceb858 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -69,6 +69,7 @@ from donate import get_gemini_link from pronouns import get_pronouns from pixelfed import get_pixelfed from discord import get_discord +from art import get_art_site_url from music import get_music_site_url from youtube import get_youtube from peertube import get_peertube @@ -332,6 +333,7 @@ def html_profile_after_search(authorized: bool, pronouns = get_pronouns(profile_json) discord = get_discord(profile_json) + art_site_url = get_art_site_url(profile_json) music_site_url = get_music_site_url(profile_json) youtube = get_youtube(profile_json) peertube = get_peertube(profile_json) @@ -461,7 +463,8 @@ def html_profile_after_search(authorized: bool, person_url, no_of_books, birth_date, youtube, peertube, pixelfed, - discord, music_site_url) + discord, music_site_url, + art_site_url) domain_full = get_full_domain(domain, port) @@ -834,7 +837,8 @@ def _get_profile_header_after_search(base_dir: str, peertube: str, pixelfed: str, discord: str, - music_site_url: str) -> str: + music_site_url: str, + art_site_url: str) -> str: """The header of a searched for handle, containing background image and avatar """ @@ -959,6 +963,9 @@ def _get_profile_header_after_search(base_dir: str, if discord: html_str += '

Discord: ' + \ discord + '

\n' + if art_site_url: + html_str += '

' + translate['Art'] + ': ' + art_site_url + '

\n' if music_site_url: html_str += '

' + translate['Music'] + ': ' + music_site_url + '

\n' @@ -1130,6 +1137,7 @@ def html_profile(signing_priv_key_pem: str, pronouns = get_pronouns(profile_json) pixelfed = get_pixelfed(profile_json) discord = get_discord(profile_json) + art_site_url = get_art_site_url(profile_json) music_site_url = get_music_site_url(profile_json) youtube = get_youtube(profile_json) peertube = get_peertube(profile_json) @@ -1142,7 +1150,7 @@ def html_profile(signing_priv_key_pem: str, verified_site_checkmark = '✔' premium = is_premium_account(base_dir, nickname, domain) if donate_url or website_url or repo_url or pronouns or discord or \ - music_site_url or youtube or peertube or pixelfed or \ + art_site_url or music_site_url or youtube or peertube or pixelfed or \ xmpp_address or matrix_address or \ ssb_address or tox_address or briar_address or cwtch_address or \ pgp_pub_key or enigma_pub_key or pgp_fingerprint or email_address: @@ -1217,6 +1225,11 @@ def html_profile(signing_priv_key_pem: str, donate_section += \ '

Discord: ' + discord + '

\n' + if art_site_url: + donate_section += \ + '

' + translate['Art'] + ': ' + \ + art_site_url + '

\n' if music_site_url: donate_section += \ '

' + translate['Music'] + ':