updated code for new arguments in wip/publish + html "meta" with date
This commit is contained in:
parent
a0c6366113
commit
6f141b6c30
|
@ -79,13 +79,15 @@ def create_metas_page():
|
|||
icon_ref = 'type="image/png" href="%stemplate/%s"'%(
|
||||
db.sub_uri, icon_file
|
||||
)
|
||||
en_date = tyto.set_en_date(db.date[0])
|
||||
relme = '' # External URL in metas (if exists in config domain)
|
||||
if db.domain_relme:
|
||||
relme = '\n <link rel="me" type="text/html" href="%s">'%(
|
||||
db.domain_relme
|
||||
)
|
||||
|
||||
# Create author and date publish section infos
|
||||
create_html_infos_section('wip')
|
||||
|
||||
# Set all raw HTML metas
|
||||
#-----------------------
|
||||
global metas
|
||||
|
@ -101,7 +103,7 @@ def create_metas_page():
|
|||
' <meta name="author" content="%s" />\n'%db.author + \
|
||||
' <meta name="description" content="%s" />\n'%db.about + \
|
||||
' <meta name="keywords" content="%s" />\n'%all_tags + \
|
||||
' <meta name="search_date" content="%s" />\n'%en_date + \
|
||||
'%s'%meta_pub + \
|
||||
' <link rel="canonical" href="%s" />\n'%db.http_www + \
|
||||
' <link rel="alternate" %s />\n'%(rss_ref) + \
|
||||
' <link rel="stylesheet" %s />\n'%css_ref + \
|
||||
|
@ -144,9 +146,6 @@ def create_main_page(target, article_bottom):
|
|||
'%sid="site_logo_image" />\n'%(15 * " ") + \
|
||||
'%s</a>'%(8 * " ")
|
||||
|
||||
# Create author and date publish section infos
|
||||
create_html_infos_section('wip')
|
||||
|
||||
#-----------------------#
|
||||
# Create main HTML Page #
|
||||
#-----------------------#
|
||||
|
@ -194,9 +193,9 @@ def create_html_infos_section(process):
|
|||
# Need to reload the DB to get last time updated
|
||||
exec(open(db.post_db).read(), globals())
|
||||
|
||||
global post_pub
|
||||
global post_pub, meta_pub, date_raw
|
||||
if process == 'wip':
|
||||
date_raw = date_wip # <time datetime=
|
||||
date_raw = date_wip # <time datetime= / meta search_date
|
||||
date_pub = date_wip.rsplit(' ')[0]
|
||||
time_pub = date_wip.rsplit(' ')[1]
|
||||
elif process == 'publish':
|
||||
|
@ -208,6 +207,7 @@ def create_html_infos_section(process):
|
|||
date_new = date_pub.rsplit('-')
|
||||
date_pub = date_new[2] + '/' + date_new[1] + '/' + date_new[0]
|
||||
|
||||
# in <article> > section info : line with new date
|
||||
post_pub = '%s<p>'%(8 * ' ') + \
|
||||
'<span id="article_title" title="%s">Article</span> '%(
|
||||
title
|
||||
|
@ -226,6 +226,11 @@ def create_html_infos_section(process):
|
|||
'</time>' + \
|
||||
'</p>'
|
||||
|
||||
# meta search_date=
|
||||
meta_pub = ' <meta name="search_date" content="%s" />\n'%(
|
||||
date_raw.rsplit(' ')[0]
|
||||
)
|
||||
|
||||
|
||||
#========================================================#
|
||||
# Create DB file with hash from [type]_load file content #
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#**********************************************************************
|
||||
|
||||
import os, sys, shutil
|
||||
import os, sys, shutil, importlib
|
||||
import db, logs, html, tyto
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ import db, logs, html, tyto
|
|||
# Manage action, get post db #
|
||||
# check if publish can be done #
|
||||
#------------------------------#
|
||||
def manage_publish(target, option):
|
||||
def manage_publish(target):
|
||||
err_pub = False # Default (publish)
|
||||
if not db.db_exists:
|
||||
logs.out("25", db.uri_file, True)
|
||||
|
@ -72,20 +72,21 @@ def manage_publish(target, option):
|
|||
|
||||
|
||||
def replace_line_pub():
|
||||
# Need to reload the DB to get last time updated
|
||||
exec(open(db.post_db).read(), globals())
|
||||
# Load config
|
||||
importlib.reload(db)
|
||||
|
||||
html.create_html_infos_section('publish')
|
||||
new_line = html.post_pub
|
||||
|
||||
newfile = ''
|
||||
wip_html_post = open(db.post_wip, 'r').read()
|
||||
for line in wip_html_post.rsplit('\n'):
|
||||
if line.startswith('%s<p><span id="article_title"'%(8 * ' ')):
|
||||
line = new_line
|
||||
line = html.post_pub
|
||||
if line.startswith('%s<meta name="search_date"'%(4 * ' ')):
|
||||
line = html.meta_pub
|
||||
|
||||
if not newfile: newfile = line
|
||||
else: newfile = '%s\n%s'%(newfile, line)
|
||||
|
||||
tyto.set_file(db.post_www, 'new', newfile)
|
||||
logs.out("34", '(date: %s): %s'%(date_www, db.post_www), False)
|
||||
logs.out("34", '(date: %s): %s'%(db.date_www, db.post_www), False)
|
||||
|
|
|
@ -54,11 +54,29 @@ def manage_show(target):
|
|||
"sidebar" : db.sidebar_load
|
||||
}
|
||||
|
||||
elif args.action in actions_wip:
|
||||
do = {
|
||||
"domain" : db.domain_conf,
|
||||
"footer" : db.wip_footer,
|
||||
"metas" : db.wip_metas,
|
||||
"navbar" : db.wip_navbar,
|
||||
"sidebar" : db.wip_sidebar
|
||||
}
|
||||
|
||||
elif args.action in actions_www:
|
||||
do = {
|
||||
"domain" : db.domain_conf,
|
||||
"footer" : db.www_footer,
|
||||
"metas" : db.www_metas,
|
||||
"navbar" : db.www_navbar,
|
||||
"sidebar" : db.www_sidebar
|
||||
}
|
||||
|
||||
# Target is a post uri
|
||||
#---------------------
|
||||
elif db.uri_file:
|
||||
|
||||
# Get hash when edit to ask to check again if change
|
||||
# Get hash when edit, and ask if file changed
|
||||
if args.action == "edit":
|
||||
curr_hash = tyto.get_filesum(db.uri_file, True)
|
||||
|
||||
|
@ -68,17 +86,15 @@ def manage_show(target):
|
|||
|
||||
# Post has database
|
||||
elif db.db_exists:
|
||||
if args.action in actions_wip:
|
||||
target = "wip"
|
||||
do = {"wip" : db.post_wip}
|
||||
do = {
|
||||
"db" : db.post_db,
|
||||
"wip" : db.post_wip,
|
||||
"www" : db.post_www
|
||||
|
||||
elif args.action in actions_www:
|
||||
target = "www"
|
||||
do = {"www" : db.post_www}
|
||||
|
||||
elif args.action in actions_db:
|
||||
target = "db"
|
||||
do = {"db" : db.post_db}
|
||||
}
|
||||
if args.action in actions_wip: target = "wip"
|
||||
elif args.action in actions_www: target = "www"
|
||||
elif args.action in actions_db: target = "db"
|
||||
|
||||
#print('> show: target', target)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import os, re, shutil
|
||||
import logs, db, tyto, html
|
||||
|
||||
def manage_wip(target, option):
|
||||
def manage_wip(target):
|
||||
global post_db, hash_post
|
||||
|
||||
# Domain configuration must exist and active
|
||||
|
@ -30,7 +30,7 @@ def manage_wip(target, option):
|
|||
#-----------------------------------------
|
||||
# Option 'Again' to wip again, based on DB
|
||||
#-----------------------------------------
|
||||
if option == 'Again':
|
||||
if target == 'all':
|
||||
ask = ''
|
||||
ask = input(":? wip again all already converted articles ? ")
|
||||
if not ask in ['y', 'Y']:
|
||||
|
@ -58,11 +58,6 @@ def manage_wip(target, option):
|
|||
# Exit if article has changed
|
||||
if db.hash_chk != db.hash_post: logs.out("9", target, True)
|
||||
|
||||
# In any case, if Force
|
||||
if option == 'Force':
|
||||
wip_article(db.uri_file)
|
||||
return
|
||||
|
||||
# Compare and check file
|
||||
if db.hash_wip != db.hash_chk:
|
||||
wip_article(db.uri_file)
|
||||
|
@ -71,8 +66,11 @@ def manage_wip(target, option):
|
|||
logs.out("24", '(wip article): %s'%db.post_wip, False)
|
||||
wip_article(db.uri_file)
|
||||
else:
|
||||
logs.out("19", db.date_wip, True)
|
||||
|
||||
logs.out("19", db.date_wip, False)
|
||||
ask = ''
|
||||
ask = input(' ├ Create new wip page ? ')
|
||||
if not ask in ['y', 'Y']: return
|
||||
wip_article(db.uri_file)
|
||||
|
||||
#===================#
|
||||
# Start wip modules #
|
||||
|
|
Loading…
Reference in New Issue