New user URI process
This commit is contained in:
parent
7d36fb858d
commit
405cdde94d
|
@ -59,6 +59,7 @@ target = args.set_target()
|
|||
import dom, status
|
||||
status.domain()
|
||||
|
||||
|
||||
# Command start argument
|
||||
import check, form, html, new, publish, show, wip, infos
|
||||
actions = {
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* All class / ID used by Tyto - Littérateur in a page
|
||||
* DOMAIN MUST be changed by domain css set in configuration
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header
|
||||
*/
|
||||
header#header_page {
|
||||
}
|
||||
|
||||
div#site_logo {
|
||||
}
|
||||
|
||||
a#site_logo_link {
|
||||
}
|
||||
|
||||
img#site_logo_image {
|
||||
}
|
||||
|
||||
div#site_infos {
|
||||
}
|
||||
|
||||
a#site_link {
|
||||
}
|
||||
|
||||
h1#site_title {
|
||||
}
|
||||
|
||||
p#site_about {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* navbar
|
||||
*/
|
||||
nav#site_menu {
|
||||
}
|
||||
|
||||
ul#site_menu_items {
|
||||
}
|
||||
|
||||
li.site_menu_item {
|
||||
}
|
||||
|
||||
a.site_menu_link {
|
||||
}
|
||||
|
||||
/*
|
||||
* article
|
||||
*/
|
||||
article#article_main {
|
||||
}
|
||||
|
||||
h1#main_title {
|
||||
}
|
||||
h2.title_2 {
|
||||
}
|
||||
h3.title_3 {
|
||||
}
|
||||
h4.title_4 {
|
||||
}
|
||||
h5.title_5 {
|
||||
}
|
||||
h6.title_6 {
|
||||
}
|
||||
|
||||
/* Between every <h2-6> IF CONTENTS */
|
||||
div.contents {
|
||||
}
|
||||
|
||||
/* Default if not set in post */
|
||||
p.DOMAIN {
|
||||
}
|
||||
|
||||
br.DOMAIN {
|
||||
}
|
||||
|
||||
a.link {
|
||||
}
|
||||
|
||||
a.anchor_link {
|
||||
}
|
||||
|
||||
abbr.DOMAIN {
|
||||
}
|
||||
|
||||
img.DOMAIN_image {
|
||||
}
|
||||
|
||||
code.icode {
|
||||
}
|
||||
|
||||
ul.DOMAIN {
|
||||
}
|
||||
li.DOMAIN
|
||||
|
||||
strong.strong {
|
||||
}
|
||||
b.bold {
|
||||
}
|
||||
em.em{
|
||||
}
|
||||
i.italic {
|
||||
}
|
||||
del.del {
|
||||
}
|
||||
u.underline {
|
||||
}
|
||||
cite.cite {
|
||||
}
|
||||
span.custom {
|
||||
}
|
||||
|
||||
|
||||
/* section for author and date */
|
||||
section#article_infos {
|
||||
}
|
||||
|
||||
span#article_author {
|
||||
}
|
||||
|
||||
span#article_pub {
|
||||
}
|
||||
|
||||
span#article_code {
|
||||
}
|
||||
|
||||
a#article_code_link {
|
||||
}
|
||||
|
||||
/*
|
||||
* sidebar
|
||||
*/
|
||||
|
||||
/*
|
||||
* footer
|
||||
*/
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#**********************************************************************
|
||||
|
||||
import sys
|
||||
import os, sys
|
||||
import infos, logs
|
||||
|
||||
|
||||
|
@ -123,11 +123,6 @@ try: target = sys.argv[2]
|
|||
except: target = ''
|
||||
|
||||
|
||||
# Some conditions exiting
|
||||
#if action == "check" and target == "newer":
|
||||
# logs.out("11", '"%s" with "%s"'%(target, action), True)
|
||||
|
||||
|
||||
# Set action and target for binary
|
||||
def set_action():
|
||||
return(action)
|
||||
|
|
|
@ -40,7 +40,7 @@ from datetime import datetime
|
|||
from time import gmtime, strftime
|
||||
import args, dom, logs, status, db, form, tyto, langs
|
||||
|
||||
domain_dir = post_err = False
|
||||
domain_dir = post_err = multi_chk = False
|
||||
|
||||
|
||||
#=========================#
|
||||
|
@ -68,8 +68,8 @@ def manage(target):
|
|||
logs.out("1", db.uri_file, True)
|
||||
|
||||
# Already check
|
||||
elif db.exists \
|
||||
and not db.old_chk:
|
||||
elif db.exists and not db.old_chk:
|
||||
print(' ├─ [%s] > %s'%(db.title, db.uri_file))
|
||||
logs.out("20", '%s > %s'%(db.date_chk, db.uri_file), False)
|
||||
answer = form.asking(' ├ %s%s '%(
|
||||
langs.site.check_a, langs.site.q
|
||||
|
@ -112,13 +112,15 @@ def check_module(target):
|
|||
# but check only if article source has changed #
|
||||
#----------------------------------------------#
|
||||
def check_all(option):
|
||||
global domain_dir
|
||||
global multi_chk
|
||||
multi_chk = True
|
||||
found = False
|
||||
|
||||
# With [added], article must NOT have a DB
|
||||
# Search every .tyto in domain from articles/
|
||||
# Then Do a check, and return
|
||||
#-----------------------------------------
|
||||
if option == "added":
|
||||
os.chdir(dom.articles_d)
|
||||
domain_dir = True
|
||||
|
||||
for root, dirs, files in os.walk(dom.articles_d[:-1]):
|
||||
for file in files:
|
||||
if (file.endswith('.tyto')):
|
||||
|
@ -134,14 +136,17 @@ def check_all(option):
|
|||
print()
|
||||
return
|
||||
|
||||
|
||||
# With [updated], Article must have changed
|
||||
# with [again], force check
|
||||
# Article must have a DB
|
||||
#------------------------------------------
|
||||
for post_db in os.listdir(dom.articles_db_d):
|
||||
if post_db.endswith('.config'):
|
||||
# Load DB
|
||||
post_db = '%s%s'%(dom.articles_db_d, post_db)
|
||||
try:
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
args.target = short_src
|
||||
importlib.reload(db)
|
||||
except:
|
||||
continue
|
||||
|
@ -161,7 +166,8 @@ def check_all(option):
|
|||
# Check articles process #
|
||||
#------------------------#
|
||||
def check_process(target):
|
||||
if not db.post: sys.exit(1)
|
||||
if not db.post:
|
||||
logs.out("1", db.post, True)
|
||||
|
||||
global post_bottom, article_bottom
|
||||
global date_wip, hash_wip, date_www, hash_www, post_bottom
|
||||
|
@ -964,5 +970,7 @@ def create_database():
|
|||
#---------------
|
||||
database = '%s\n%s\n%s'%(database, opt_tags, db_stats)
|
||||
tyto.set_file(db.config, 'New', database)
|
||||
logs.out("21", db.uri_file, False)
|
||||
|
||||
if not multi_chk:
|
||||
logs.out("21", db.uri_file, False)
|
||||
|
||||
|
|
|
@ -34,16 +34,12 @@
|
|||
#**********************************************************************
|
||||
|
||||
import os
|
||||
import args, logs, dom, form, tyto, check
|
||||
import args, logs, dom, form, tyto, check, publish
|
||||
|
||||
remove = exists = post = corrupt = False
|
||||
|
||||
try:
|
||||
# with check newer, use domain root directory
|
||||
if check.domain_dir:
|
||||
os.chdir(dom.articles_d)
|
||||
in_dir = os.getcwd()
|
||||
except: logs.out("13", '', True)
|
||||
if dom.hole:
|
||||
logs.out("13", '', True)
|
||||
|
||||
|
||||
# target needs db (file).
|
||||
|
@ -56,7 +52,7 @@ if args.target \
|
|||
# Domain must be valid
|
||||
if not dom.exists: logs.out("10", '', True)
|
||||
|
||||
uri_file = '%s/%s'%(in_dir, args.target)
|
||||
uri_file = '%s%s'%(dom.articles_d, args.target)
|
||||
uri_id = tyto.get_filesum(uri_file, False)
|
||||
|
||||
# Set DB file
|
||||
|
|
|
@ -34,15 +34,21 @@
|
|||
#**********************************************************************
|
||||
|
||||
import os, sys, importlib, langs
|
||||
import args
|
||||
|
||||
lib = 'tyto_domain'
|
||||
exists = incomplete = active = ready = shortname = corrupt = False
|
||||
local_user = articles_db_d = False
|
||||
hole = False
|
||||
hole = False
|
||||
|
||||
# Set current directory
|
||||
try: in_dir = os.getcwd()
|
||||
except: hole = True
|
||||
try:
|
||||
user_dir
|
||||
except:
|
||||
try:
|
||||
user_dir = os.getcwd() + "/"
|
||||
except:
|
||||
hole = True
|
||||
|
||||
# Settings for domain, check if db is not corrupted
|
||||
dom_values = \
|
||||
|
@ -133,12 +139,12 @@ if not hole:
|
|||
home_dir = os.path.expanduser('~')
|
||||
|
||||
# Set configuration domain directory
|
||||
folder = in_dir
|
||||
if '/articles' in in_dir:
|
||||
folder = in_dir.rsplit('/articles')[0]
|
||||
root_dir = user_dir
|
||||
if '/articles' in user_dir:
|
||||
root_dir = user_dir.rsplit('/articles')[0] + "/"
|
||||
|
||||
# Set configuration domain file
|
||||
config = '%s/tyto_domain.py'%folder
|
||||
config = '%styto_domain.py'%root_dir
|
||||
shortname = config
|
||||
|
||||
# Set exists if configuration file
|
||||
|
@ -146,8 +152,16 @@ if not hole:
|
|||
exists = True
|
||||
try:
|
||||
exec(open(config).read())
|
||||
try:
|
||||
os.path.exists(articles_d)
|
||||
user_uri_dir = user_dir.rsplit(articles_d)[1]
|
||||
os.chdir(articles_d)
|
||||
except: corrupt = True
|
||||
except:
|
||||
corrupt = True
|
||||
corrupt = True
|
||||
|
||||
if not args.target in args.pass_targets:
|
||||
args.target = user_uri_dir + args.target
|
||||
|
||||
# For logs: show uri if not shortname known
|
||||
try: shortname
|
||||
|
|
|
@ -165,8 +165,8 @@ def create_main_page(target, article_bottom):
|
|||
' </a>\n' + \
|
||||
' <p id="site_about">%s</p>\n'%dom.about + \
|
||||
' </div>\n' + \
|
||||
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||
' </header>\n' + \
|
||||
'<!--# include virtual="/template/navbar.html"-->\n' + \
|
||||
'\n' + \
|
||||
' <article id="article_main">\n' + \
|
||||
' <h1 id="main_title"\n' + \
|
||||
|
@ -295,8 +295,8 @@ def create_navbar(option):
|
|||
|
||||
# Set first HTML line
|
||||
menu_html = \
|
||||
'%s<nav id="site_menu">\n'%(6 * ' ') + \
|
||||
'%s<ul id="site_menu_items">'%(8 * ' ')
|
||||
'%s<nav id="site_menu">\n'%(4 * ' ') + \
|
||||
'%s<ul id="site_menu_items">'%(6 * ' ')
|
||||
|
||||
navbar_lines = open(dom.navbar_f, 'r').read()
|
||||
|
||||
|
@ -353,13 +353,13 @@ def create_navbar(option):
|
|||
# Add link to HTML structure
|
||||
navbar_items = True
|
||||
menu_item = \
|
||||
'\n%s<li class="site_menu_item">\n'%(10 * ' ') + \
|
||||
'%s<a class="site_menu_link"\n'%(12 * ' ') + \
|
||||
'\n%s<li class="site_menu_item">\n'%(8 * ' ') + \
|
||||
'%s<a class="site_menu_link"\n'%(10 * ' ') + \
|
||||
'%s'%title + \
|
||||
'%shref="/%s/">%s</a>\n'%(
|
||||
15 * ' ', direc, direc
|
||||
) + \
|
||||
'%s</li>'%(10 * ' ')
|
||||
'%s</li>'%(8 * ' ')
|
||||
|
||||
menu_html = '%s%s'%(menu_html, menu_item)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ def manage_publish(target):
|
|||
#-----------------------------------------
|
||||
if target in args.pass_targets:
|
||||
do = {
|
||||
'updated' : publish_all,
|
||||
'updated' : publish_all,
|
||||
'again' : publish_all,
|
||||
'added' : publish_all,
|
||||
'sidebar' : html.create_sidebar,
|
||||
|
@ -82,8 +82,8 @@ def manage_publish(target):
|
|||
#---------------#
|
||||
def publish_article():
|
||||
# Copy wip page to www page
|
||||
os.makedirs('%s%s'%(dom.srv_www, db.direc_src), exist_ok=True)
|
||||
logs.out("33", '%s%s'%(dom.srv_www, db.direc_src), False)
|
||||
if not os.makedirs('%s%s'%(dom.srv_www, db.direc_src), exist_ok=True):
|
||||
logs.out("33", '%s%s'%(dom.srv_www, db.direc_src), False)
|
||||
|
||||
# Replace in DB hash_wip and date_wip
|
||||
tyto.replace_in_db(db.config, 'www', db.hash_post)
|
||||
|
@ -188,10 +188,20 @@ def publish_template(option):
|
|||
#--------------------------------------------#
|
||||
def publish_all(option):
|
||||
# Ask or show what to do
|
||||
tyto.process_all('Publish')
|
||||
if args.target == "again":
|
||||
form.asking(" ├ %s%s "%(
|
||||
langs.site.wip_again, langs.site.q
|
||||
), True)
|
||||
|
||||
elif args.target == "addedd":
|
||||
print(' │ %s'%langs.site.wip_older)
|
||||
#os.chdir(dom.articles_d)
|
||||
|
||||
elif args.target == "updated":
|
||||
print(' │ %s'%langs.site.wip_newer)
|
||||
|
||||
# Sort by newer articles (created by last check)
|
||||
db_articles = sorted(Path(db.articles_db).iterdir(),
|
||||
db_articles = sorted(Path(dom.articles_db_d).iterdir(),
|
||||
key=os.path.getmtime
|
||||
)
|
||||
|
||||
|
@ -199,18 +209,17 @@ def publish_all(option):
|
|||
option = args.target
|
||||
found = False
|
||||
for post_db in db_articles:
|
||||
if not str(post_db).endswith('.conf'): continue
|
||||
if not str(post_db).endswith('.config'): continue
|
||||
|
||||
# Load DB
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
args.target = short_src
|
||||
importlib.reload(db)
|
||||
|
||||
if not db.hash_wip: continue
|
||||
if option == "again" and not db.sync_srvs: continue
|
||||
if option == "added" and not db.old_www: continue
|
||||
|
||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||
if db.old_chk:
|
||||
logs.out("9", '', False)
|
||||
continue
|
||||
|
@ -235,6 +244,8 @@ def check_to_publish(process):
|
|||
global err_pub
|
||||
err_pub = False
|
||||
|
||||
print(' │\n ├─ [%s] > %s'%(db.title, db.post_src))
|
||||
|
||||
# Article was not checked or changed
|
||||
if db.no_chk:
|
||||
logs.out("25", db.uri_file, False)
|
||||
|
|
|
@ -33,16 +33,20 @@
|
|||
|
||||
#**********************************************************************
|
||||
|
||||
import dom, logs, tyto, form
|
||||
import args, dom, logs, tyto, form
|
||||
|
||||
print("")
|
||||
def domain():
|
||||
if dom.hole: logs.out("13", '', True)
|
||||
elif dom.corrupt: logs.out("39", dom.shortname, True)
|
||||
#elif not dom.shortname: return
|
||||
elif dom.incomplete: logs.out("41", dom.shortname, False)
|
||||
elif dom.active: logs.out("42", dom.shortname, False)
|
||||
elif not dom.active: logs.out("40", dom.shortname, False)
|
||||
|
||||
# No backward in target
|
||||
if "../" in args.target:
|
||||
logs.out("11", '"../"', True)
|
||||
|
||||
# Show unused values
|
||||
for err_val in dom.err_val:
|
||||
logs.out("16", err_val, False)
|
||||
|
|
|
@ -124,7 +124,7 @@ words_tags = [
|
|||
# Tags that do not need to be paired
|
||||
#-----------------------------------
|
||||
single_tags = [
|
||||
('|', '<br />'), # New Line
|
||||
('|', '<br class="%s" />'), # New Line
|
||||
('->', '<a class="anchor_target" id="%s"></a>') # Anchors
|
||||
]
|
||||
|
||||
|
@ -521,8 +521,8 @@ def files_to_srv(server):
|
|||
|
||||
# Create sub-directories in server
|
||||
try:
|
||||
os.makedirs(d_dst, exist_ok=True)
|
||||
logs.out("33", d_dst, False)
|
||||
if os.makedirs(d_dst, exist_ok=True):
|
||||
logs.out("33", d_dst, False)
|
||||
except:
|
||||
logs.out('4', d_dst, True)
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ def wip_all(process):
|
|||
# Load DB
|
||||
try:
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
args.target = short_src
|
||||
importlib.reload(db)
|
||||
except:
|
||||
continue
|
||||
|
@ -151,7 +151,7 @@ def wip_all(process):
|
|||
found = True
|
||||
wip_article(db.post_src)
|
||||
|
||||
if not found: logs.out("28", '(wip)', True)
|
||||
if not found: sys.exit(28)
|
||||
|
||||
|
||||
#===================#
|
||||
|
@ -201,8 +201,8 @@ def wip_article(target):
|
|||
#print(html.main_page)
|
||||
|
||||
# Create wip file
|
||||
os.makedirs('%s%s'%(dom.srv_wip, db.direc_src), exist_ok=True)
|
||||
logs.out("33", '%s%s'%(dom.srv_wip, db.direc_src), False)
|
||||
if os.makedirs('%s%s'%(dom.srv_wip, db.direc_src), exist_ok=True):
|
||||
logs.out("33", '%s%s'%(dom.srv_wip, db.direc_src), False)
|
||||
tyto.set_file(db.post_wip, 'New', html.main_page)
|
||||
|
||||
# Copy needed files (Also create sub-folders)
|
||||
|
@ -247,7 +247,7 @@ def replace_in_post(src, html):
|
|||
def wip_single_tags():
|
||||
# <br /> from "|"
|
||||
replace_in_post(tyto.single_tags[0][0],
|
||||
tyto.single_tags[0][1]
|
||||
tyto.single_tags[0][1]%dom.css
|
||||
)
|
||||
|
||||
# Anchor source
|
||||
|
@ -812,7 +812,7 @@ def wip_lists():
|
|||
'<ul class="%s">'%css, 1
|
||||
).replace('<li>',
|
||||
'<li class="%s">'%css
|
||||
) + '</ul>'
|
||||
)
|
||||
replace_in_post(content_list, html_list)
|
||||
|
||||
if in_list:
|
||||
|
|
|
@ -41,7 +41,7 @@ file_e = "Fichier présent"
|
|||
dir_c = "Dossier créé"
|
||||
dir_e = "Dossier présent"
|
||||
|
||||
was_chk = "Article déjà vérifié"
|
||||
was_chk = "Article déjà vérifié"
|
||||
was_wip = "Article déjà 'wip'"
|
||||
check_m = "Vérifier manuellement"
|
||||
post_inc = "Donnée manquante dans l'article"
|
||||
|
|
Loading…
Reference in New Issue