diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index c68f163..b7c467b 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -76,7 +76,10 @@ def post_IDs(file_post): post_url = '%s%s/%s'%( domain.domain_protocol, domain.domain_name, file_html ) - + + global post_dir + post_dir = file_post.replace(os.path.basename(file_post), '') + # From argument file_post # Set WEB link prefix. Count / in uri global weburi @@ -824,9 +827,9 @@ def check_images(line, ln, stats_images_uniq): # Current or custom URI else: - usr_file = '%s%s'%(domain.domain_articles,image_uri) + usr_file = '%s%s%s'%(domain.domain_articles, post_dir, image_uri) if not os.path.exists(usr_file): - msg_log = 'Unused file for marker "file:" in %s'%usr_file + msg_log = 'Unused file for marker "image:" in %s'%usr_file log.append_f(post_logs, msg_log, 1) Post_Err = True @@ -1225,6 +1228,7 @@ def create_DB(post_db): 'post_ID = "%s"'%curr_post_ID, 'post_db = "%s"'%post_db, 'post_tmp = "%s"'%post_tmp, + 'post_dir = "%s"'%post_dir, 'post_url = "%s"'%post_url, 'post_srv = "%s"'%post_srv, 'web_uri = "%s"'%weburi, diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 69030fc..be5e537 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -16,7 +16,7 @@ #---------------------------------------------------------------------- #********************************************************************** -import sys, os, re +import sys, os, re, shutil import check, log, domain, html, rss Post_Err = False @@ -121,22 +121,21 @@ def manage_wip(file_post, Force): print('> Article HTML:\n', wip_html) # Create file to wip srv (replace file, if exists) - wip_file = file_post.replace('.tyto','.html') - wip_uri = '%s%s'%(domain.srv_wip, wip_file) - wip_dir = wip_uri.replace(os.path.basename(wip_uri), '') + wip_file = '%s%s'%(domain.srv_wip, check.post_srv) if os.path.exists(wip_file): os.remove(wip_file) # Create sub folder if needed + wip_dir = '%s%s'%(domain.srv_wip, check.post_dir) os.makedirs(wip_dir, exist_ok=True) - page_file = open(wip_uri, 'w') + + page_file = open(wip_file, 'w') page_file.write(wip_html) page_file.close() - post_uri = '%s%s'%(domain.domain_articles, file_post) time_wip = log.nowdate() - hash_wip = check.get_filesum(post_uri, True) + hash_wip = check.get_filesum(check.post_file, True) rep_post_wip = 'post_wip = (\'%s\', \'%s\')'%( check.post_wip[0], check.post_wip[1]) @@ -527,6 +526,18 @@ def wip_images(article): if var.startswith('image_'): image = globals()[var] + # Copy file in wip + image_src = '%s%s%s'%( + domain.domain_articles, check.post_dir, image[1] + ) + image_dst = '%s%s%s'%( + domain.srv_wip, check.post_dir, image[1] + ) + shutil.copy2(image_src, image_dst) + # log + msg_log = 'Wip > Image: %s > %s'%(image_src, image_dst) + log.append_f(check.post_logs, msg_log, 0) + # Search in article lines for _image: for line in article.rsplit('\n'): if not line.startswith('_image:'):