diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 11d0c0b..a7bb3e8 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -49,6 +49,7 @@ pass_actions = ( pass_db = \ ( 'check', + 'edit', 'edit-db', 'edit-wip', 'edit-www', diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 8471ff3..e368929 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -385,8 +385,9 @@ def check_headers(post_header): post_err = True else: check_file_uri('image', image_uri, ln + 1) - f_uri = web_uri[1:len(web_uri)] - files_post = (files_post + "'%s', "%f_uri) + if not post_err: + f_uri = web_uri[1:len(web_uri)] + files_post = (files_post + "'%s', "%f_uri) image_alt = post_header[ln + 1].lstrip() if image_alt.startswith(tyto.headers): image_alt = '' @@ -424,8 +425,9 @@ def check_headers(post_header): post_err = True else: check_file_uri('file', raw_uri, ln + 1) - f_uri = web_uri[1:len(web_uri)] - files_post = (files_post + "'%s', "%f_uri) + if not post_err: + f_uri = web_uri[1:len(web_uri)] + files_post = (files_post + "'%s', "%f_uri) raw_alt = post_header[ln + 1].lstrip() if raw_alt.startswith(tyto.headers): raw_alt = '' @@ -462,8 +464,9 @@ def check_headers(post_header): post_err = True else: check_file_uri('file', file_uri, ln + 1) - f_uri = web_uri[1:len(web_uri)] - files_post = (files_post + "'%s', "%f_uri) + if not post_err: + f_uri = web_uri[1:len(web_uri)] + files_post = (files_post + "'%s', "%f_uri) file_alt = post_header[ln + 1].lstrip() if file_alt.startswith(tyto.headers): file_alt = '' @@ -496,6 +499,7 @@ def check_headers(post_header): snshare = True snpic_url = '%s%s'%(db.domain_www_url, web_uri) break + if not snshare: logs.out("12", '%s %s'%(tyto.headers[6], snpic_name), False) post_err = True diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index da03348..af19884 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -76,22 +76,24 @@ def manage_publish(target): publish_article() -# -# Let's publish -# +#===============# +# Let's publish # +#---------------# def publish_article(): # Copy wip page to www page os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True) shutil.copy2(db.post_wip, db.post_www) logs.out("33", db.post_www, False) - + tyto.files_to_srv('www') + ''' # Copy files registred in article for uri in db.uris: f_src = '%s%s'%(db.srv_wip, uri) f_www = '%s%s'%(db.srv_www, uri) shutil.copy2(f_src, f_www) logs.out("33", f_www, False) + ''' # Replace in DB hash_wip and date_wip tyto.replace_in_db(db.post_db, 'www', db.hash_post) diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index b7f7687..b2e12cc 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -17,7 +17,7 @@ #********************************************************************** -import os, sys, subprocess, locale, base64, datetime +import os, sys, subprocess, locale, base64, datetime, shutil from hashlib import blake2b import db, logs @@ -422,3 +422,22 @@ def replace_in_db(post_db, process, hash_post): file = open(post_db, 'w') file.write(new_file) file.close() + + +#===================================# +# Copy files used by article to srv # +#-----------------------------------# +def files_to_srv(server): + for uri in db.uris: + # Destination file to server + f_src = '%s%s'%(db.domain_articles, uri) + if server == 'wip': f_dst = '%s%s'%(db.srv_wip, uri) + elif server == 'www': f_dst = '%s%s'%(db.srv_www, uri) + + # Create folder and subfolders + f_uri = uri.split("/")[-1] + f_uri = uri.rsplit(f_uri)[0] + os.makedirs('%s%s'%(f_dst, f_uri), exist_ok=True) + + shutil.copy2(f_src, f_dst) + logs.out("33", f_dst, False) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index cf7fa93..4e42dd2 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -142,13 +142,16 @@ def wip_article(target): tyto.set_file(db.post_wip, 'New', html.main_page) logs.out("33", db.post_wip, False) + # Copy needed file to wip + tyto.files_to_srv('wip') + ''' # Copy needed file to wip for uri in db.uris: f_src = '%s%s'%(db.domain_articles, uri) f_wip = '%s%s'%(db.srv_wip, uri) shutil.copy2(f_src, f_wip) logs.out("33", f_wip, False) - + ''' #=================================# # Create string article from file #