diff --git a/README.md b/README.md index ea91fe9..355a99c 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ abbr: NOM (en majuscule) Définition du NOM nom (forme à afficher dans l'artile (optionnel)) +# L'image doit d'abord être configurée +# Utiliser l'image précisée comme défaut dans les réseaux sociaux +snpic: Nom + # Séparateur d'au moins 5 "-" pour définir la fin # des métadonnées d'entête de l'article ---------- diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 26fbc82..e7a098b 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -185,6 +185,10 @@ def check_headers(post_header): global date, title, author, tags, about global stat_links, stat_images, stat_files, stat_raws, stat_abbrs global post_tags + global snpic_url + + snshare = False + snpic_name = '' # Needed Tags title = author = tags = about = '' @@ -454,6 +458,21 @@ def check_headers(post_header): '__%s'%file_name, web_link ) + # snpic (set image to share to social networks) + if snpic_name: continue + tag = tyto.headers[11] # snpic: + if line.startswith(tag): + snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip() + for ln, line in enumerate(post_header, 1): + if re.search(r"^image:\s+hello$", line): + image_uri = post_header[ln].lstrip() + check_file_uri('image', image_uri, ln + 1) + snshare = True + snpic_url = '%s%s'%(domain_url, web_uri) + break + if not snshare: + tyto.exiting("10", '%s %s'%(tyto.headers[6], snpic_name), True) + # Exit if error in optional tags #------------------------------- if post_err: @@ -644,6 +663,7 @@ def create_database(): 'author = "%s"\n'%author + \ 'tags = "%s"\n'%tags + \ 'date = %s\n'%str(date) + \ + 'snpic = "%s"\n'%snpic_url + \ '\n# Post configuration from optional tags' if stat_abbrs > 0: diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index 87aeb39..a193600 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -18,7 +18,7 @@ #********************************************************************** import os, sys -import tyto, domain, html +import tyto, domain # Load domain configuration DB exec(open(tyto.domain_conf).read()) @@ -126,7 +126,7 @@ def create_metas_page(): ' \n' + \ ' \n'%post_url + \ ' \n'%about + \ - ' \n' + \ + ' \n'%snpic + \ '%s'%relme + \ '\n\n' + \ ' %s'%title diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 2099f25..57c9c7d 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -108,7 +108,8 @@ headers = ( 'file:', 'abbr:', 'raw:', - '#' + '#', + 'snpic:', )