diff --git a/src/var/lib/tyto/program/sidebar.py b/src/var/lib/tyto/program/sidebar.py index e83ac74..a6fc77a 100644 --- a/src/var/lib/tyto/program/sidebar.py +++ b/src/var/lib/tyto/program/sidebar.py @@ -53,11 +53,12 @@ def manage_sidebar(article, Opt): # Read tyto.sidebar file # #------------------------# def loop_sidebar(create): - Post_Err = False - sdb_posts = posts_uri = [] - max_items = int(domain.domain_sdb_items) + 1 - counter = 0 # To not set more than set in config + Post_Err = False + sdb_posts = posts_uri = [] + max_items = int(domain.domain_sdb_items) + 1 + counter = 0 # To not set more than set in config sdb_loaded = (open(domain.domain_sdb_load)).read() + for line in sdb_loaded.rsplit('\n'): if create : print(line) elif line.startswith('#'): continue @@ -81,6 +82,10 @@ def loop_sidebar(create): msg_log = 'Sidebar > Not created. Mismatch some article\'s URI' log.append_f(domain.tyto_logs, msg_log, 1) else: + # Create sidebar.html + file = open(sidebar_file, 'w') + file.close() + for item, post in sdb_posts, posts_uri: db_article = '%s%s.conf'%(domain.domain_db, item) if os.path.exists(db_article): @@ -135,7 +140,7 @@ def create_sdb_item(db_article): ' \n' + \ '' - with open(sidebar_file, 'w') as file: + with open(sidebar_file, 'a') as file: for line in sdb_html_item.rsplit('\n'): file.write('%s%s\n'%(8*' ', line))