sidebar: create sidebar.html in wip/template

This commit is contained in:
Cyrille L 2022-12-01 15:32:56 +01:00
parent 0fa06f997f
commit 4e864d0d1e
4 changed files with 18 additions and 8 deletions

View File

@ -66,7 +66,7 @@ def post_IDs(file_post):
# Set HTML file from file_post # Set HTML file from file_post
file_html = file_post.replace('.tyto','.html') file_html = file_post.replace('.tyto','.html')
if file_html.endswith('index.html'): if file_html.endswith('index.html'):
file_html = file_html.remplace('index.html', '') file_html = file_html.replace('index.html', '')
# Complete URL post file # Complete URL post file
global post_url global post_url

View File

@ -82,18 +82,23 @@ def loop_sidebar(create):
msg_log = 'Sidebar > Not created. Mismatch some article\'s URI' msg_log = 'Sidebar > Not created. Mismatch some article\'s URI'
log.append_f(domain.tyto_logs, msg_log, 1) log.append_f(domain.tyto_logs, msg_log, 1)
else: else:
print('>', sdb_posts, posts_uri)
# Create sidebar.html # Create sidebar.html
file = open(sidebar_file, 'w') file = open(sidebar_file, 'w')
file.close() file.close()
for item, post in sdb_posts, posts_uri: i = 0
for item in sdb_posts:
db_article = '%s%s.conf'%(domain.domain_db, item) db_article = '%s%s.conf'%(domain.domain_db, item)
if os.path.exists(db_article): if os.path.exists(db_article):
print("OK for",item, post) print("OK for",item, posts_uri[i])
create_sdb_item(db_article) create_sdb_item(db_article)
else: else:
msg_log = 'Sidebar > Article not yet ready: %s'%post msg_log = 'Sidebar > Article not yet ready: %s'%posts_uri[i]
log.append_f(domain.tyto_logs, msg_log, 1) log.append_f(domain.tyto_logs, msg_log, 1)
i += 1
#==========================================# #==========================================#
@ -142,7 +147,7 @@ def create_sdb_item(db_article):
with open(sidebar_file, 'a') as file: with open(sidebar_file, 'a') as file:
for line in sdb_html_item.rsplit('\n'): for line in sdb_html_item.rsplit('\n'):
file.write('%s%s\n'%(8*' ', line)) file.write('%s%s\n'%(16*' ', line))

View File

@ -121,11 +121,16 @@ def manage_wip(file_post, Force):
print('> Article HTML:\n', wip_html) print('> Article HTML:\n', wip_html)
# Create file to wip srv (replace file, if exists) # Create file to wip srv (replace file, if exists)
wip_file = '%s%s'%(domain.srv_wip, file_post.replace('.tyto','.html')) 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), '')
if os.path.exists(wip_file): if os.path.exists(wip_file):
os.remove(wip_file) os.remove(wip_file)
page_file = open(wip_file, 'w') # Create sub folder if needed
os.makedirs(wip_dir, exist_ok=True)
page_file = open(wip_uri, 'w')
page_file.write(wip_html) page_file.write(wip_html)
page_file.close() page_file.close()