indev: added pic to share to social network
This commit is contained in:
parent
7595e6cc43
commit
60079467f6
|
@ -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
|
||||
----------
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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():
|
|||
' <meta property="og:type" content="article" />\n' + \
|
||||
' <meta property="og:url" content="%s" />\n'%post_url + \
|
||||
' <meta property="og:description" content="%s" />\n'%about + \
|
||||
' <meta property="og:image" content="" />\n' + \
|
||||
' <meta property="og:image" content="%s" />\n'%snpic + \
|
||||
'%s'%relme + \
|
||||
'\n<!--# include virtual="/template/metas.html"-->\n' + \
|
||||
' <title>%s</title>'%title
|
||||
|
|
|
@ -108,7 +108,8 @@ headers = (
|
|||
'file:',
|
||||
'abbr:',
|
||||
'raw:',
|
||||
'#'
|
||||
'#',
|
||||
'snpic:',
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue