diff --git a/picoblogger/main.py b/picoblogger/main.py index 9acec39..24bfc1d 100755 --- a/picoblogger/main.py +++ b/picoblogger/main.py @@ -82,6 +82,9 @@ draftDir = os.path.join(blog_dir,"drafts") # path to articles articleDir = os.path.join(blog_dir,"articles") +# path to archive +archiveDir = os.path.join(blog_dir,"archive") + # paths to configs pbconfpath = os.path.join("/","etc","picoblogger","pb.conf") # global config blogconfpath = os.path.join(blog_dir,"pb.conf") # local config @@ -129,6 +132,7 @@ try: dateFormat = blogconf['BLOG_DATE_FORMAT'] timeFormat = blogconf['BLOG_TIME_FORMAT'] amountRecent = int(blogconf['RECENT_AMOUNT']) + notToArchive = blogconf['BLOG_CURRENT_ARTICLES'] except: print("Couldn't parse blog's local configuration (%s)."%blogconfpath) @@ -254,6 +258,11 @@ def recent_articles(amount): return joined_html +def archive_articles(notToArchive): + articles= [item for os.listdir(artDir) if not "\~" in item] + for i in range(notToArchive,): + + os.replace(draft, article) def update_blog(subsection): # Joins config defined variables into templates @@ -261,8 +270,6 @@ def update_blog(subsection): tplIndex = os.path.join(tplDir,"index.htm") blogIndex = os.path.join(blog_dir,"index.html") - blogArchive = os.path.join(blog_dir,"archive.html") - tpl = Template(open(tplIndex,'r').read()) sNAV = open(os.path.join(tplDir,"nav.htm")).read() @@ -270,7 +277,6 @@ def update_blog(subsection): # sMAIN = open(os.path.join(tplDir,"main.htm")).read() # sMAIN = Template(sMAIN).safe_substitute(join_articles()) sMAIN = join_articles() - sARCHIVE = join_articles() sASIDE = open(os.path.join(tplDir,"aside.htm")).read() sRECENT = open(os.path.join(tplDir,"recent.htm")).read() @@ -311,16 +317,6 @@ def update_blog(subsection): with open(blogIndex,"w", encoding=l10nconf['BLOG_CHARSET']) as f: print(tmpIndex, file=f) - tplSub['TEMPLATE_MAIN'] = sARCHIVE - - tmpIndex = Template(tmpIndex).safe_substitute(tplSub) - - with open(blogArchive,"w", encoding=l10nconf['BLOG_CHARSET']) as f: - print(tmpIndex, file=f) - - - - # def article_to_html(name): # article = os.path.join(blog_dir,"articles",name + ".txt")