From 616fed7a8e8fd1d4fa08e64ffbe21e6fecf65167 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 7 Mar 2023 11:30:35 +0100 Subject: [PATCH] some fixes. sub-folders #2 --- src/var/lib/tyto/program/check.py | 10 ++++++---- src/var/lib/tyto/program/publish.py | 9 +-------- src/var/lib/tyto/program/wip.py | 13 +++---------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index e368929..8777817 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -544,11 +544,13 @@ def check_file_uri(filetype, filename, ln): elif filetype == 'file': fileuri = db.domain_files + filename[1: len(filename)] - elif filename.startswith('/'): - fileuri = tyto.post_dir + filename[1: len(filename)] - else: - fileuri = tyto.post_dir + filename + post_dir = db.uri_file.split("/")[-1] + post_dir = db.uri_file.rsplit(post_dir)[0] + if filename.startswith('/'): + fileuri = post_dir + filename[1: len(filename)] + else: + fileuri = post_dir + filename # Check if file exists if not os.path.exists(fileuri): diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index af19884..6f80842 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -85,15 +85,8 @@ def publish_article(): shutil.copy2(db.post_wip, db.post_www) logs.out("33", db.post_www, False) + # Copy needed files (Also create sub-folders) 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/wip.py b/src/var/lib/tyto/program/wip.py index 4e42dd2..3bd629e 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -142,16 +142,9 @@ 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 + # Copy needed files (Also create sub-folders) 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 # @@ -240,7 +233,7 @@ def wip_links(): # Doing files, first, becase of similar marker if db.uniq_files > 0: for i in range(1, db.uniq_files + 1): - file = 'file_%s'%i + file = 'db.file_%s'%i article_bottom = article_bottom.replace( eval(file)[0]+'+', eval(file)[1]%('_blank') )