Mostly ok till line 534

This commit is contained in:
Phyks 2013-07-27 14:56:40 +02:00
parent 95e7413348
commit 59fc3b5d47

View File

@ -85,8 +85,8 @@ def auto_dir(path):
if not os.path.exists(directory): if not os.path.exists(directory):
os.makedirs(directory) os.makedirs(directory)
except IOError: except IOError:
sys.exit("[ERROR] An error occured while creating "+path+" file \ sys.exit("[ERROR] An error occured while creating "+path+" file "
and parent dirs.") "and parent dirs.")
# Replace some user specific syntax tags (to repplace smileys for example) # Replace some user specific syntax tags (to repplace smileys for example)
@ -100,17 +100,17 @@ def replace_tags(article, search_list, replace_list):
try: try:
opts, args = getopt.gnu_getopt(sys.argv, "hf", ["help", "force-regen"]) opts, args = getopt.gnu_getopt(sys.argv, "hf", ["help", "force-regen"])
except getopt.GetoptError: except getopt.GetoptError:
sys.exit("Error while parsing command line arguments. \ sys.exit("Error while parsing command line arguments. "
See pre-commit -h for more infos on how to use.") "See pre-commit -h for more infos on how to use.")
force_regen = False force_regen = False
for opt, arg in opts: for opt, arg in opts:
if opt in ("-h", "--help"): if opt in ("-h", "--help"):
print("Usage :") print("Usage :")
print("This should be called automatically as a pre-commit git hook. \ print("This should be called automatically as a pre-commit git hook. "
You can also launch it manually right before commiting.\n") "You can also launch it manually right before commiting.\n")
print("This script generates static pages ready to be served behind \ print("This script generates static pages ready to be served behind "
your webserver.\n") "your webserver.\n")
print("Usage :") print("Usage :")
print("-h \t --help \t displays this help message.") print("-h \t --help \t displays this help message.")
print("-f \t --force-regen \t force complete rebuild of all pages.") print("-f \t --force-regen \t force complete rebuild of all pages.")
@ -136,9 +136,9 @@ try:
else: else:
params[option.strip()] = value.strip() params[option.strip()] = value.strip()
except IOError: except IOError:
sys.exit("[ERROR] Unable to load raw/params file which defines important \ sys.exit("[ERROR] Unable to load raw/params file which defines important "
parameters. Does such a file exist ? \ "parameters. Does such a file exist ? See doc for more info "
See doc for more info on this file.") "on this file.")
# Fill lists for modified, deleted and added files # Fill lists for modified, deleted and added files
@ -151,13 +151,13 @@ if not force_regen:
try: try:
changes = subprocess.check_output(["git", "diff", "--cached", "--name-status"], universal_newlines=True) changes = subprocess.check_output(["git", "diff", "--cached", "--name-status"], universal_newlines=True)
except: except:
sys.exit("[ERROR] An error occured when fetching file changes \ sys.exit("[ERROR] An error occured when fetching file changes "
from git.") "from git.")
changes = changes.strip().split("\n") changes = changes.strip().split("\n")
if changes == [""]: if changes == [""]:
sys.exit("[ERROR] Nothing to do... Did you had new files with \ sys.exit("[ERROR] Nothing to do... Did you had new files with "
\"git add\" before ?") "\"git add\" before ?")
for changed_file in changes: for changed_file in changes:
if changed_file[0].startswith("A"): if changed_file[0].startswith("A"):
@ -174,15 +174,14 @@ else:
added_files = list_directory("raw") added_files = list_directory("raw")
if not added_files and not modified_files and not deleted_files: if not added_files and not modified_files and not deleted_files:
sys.exit("[ERROR] Nothing to do... Did you had new files with \ sys.exit("[ERROR] Nothing to do... Did you had new files with "
\"git add\" before ?") "\"git add\" before ?")
# Only keep modified raw articles files # Only keep modified raw articles files
for filename in list(added_files): for filename in list(added_files):
direct_copy = False direct_copy = False
if not filename.startswith("raw/"): if not filename.startswith("raw/"):
# TODO : Delete files starting by gen / blog ? + same thing for modified / deleted
added_files.remove(filename) added_files.remove(filename)
continue continue
@ -193,8 +192,9 @@ for filename in list(added_files):
if ((not filename.endswith(".html") and not filename.endswith(".ignore")) if ((not filename.endswith(".html") and not filename.endswith(".ignore"))
or direct_copy): or direct_copy):
print("[INFO] (Not HTML file) Copying directly not html file \ # Note : this deal with CSS, images or footer file
"+filename[4:]+" to blog dir.") print("[INFO] (Not HTML file) Copying directly not html file "
+ filename[4:]+" to blog dir.")
auto_dir("blog/"+filename[4:]) auto_dir("blog/"+filename[4:])
shutil.copy(filename, "blog/"+filename[4:]) shutil.copy(filename, "blog/"+filename[4:])
@ -202,8 +202,8 @@ for filename in list(added_files):
continue continue
if filename.endswith(".ignore"): if filename.endswith(".ignore"):
print("[INFO] (Not published) Found not published article \ print("[INFO] (Not published) Found not published article "
"+filename[4:-7]+".") + filename[4:-7]+".")
added_files.remove(filename) added_files.remove(filename)
continue continue
@ -221,16 +221,16 @@ for filename in list(modified_files):
if ((not filename.endswith("html") and not filename.endswith("ignore")) if ((not filename.endswith("html") and not filename.endswith("ignore"))
or direct_copy): or direct_copy):
print("[INFO] (Not HTML file) Updating directly not html file \ print("[INFO] (Not HTML file) Updating directly not html file "
"+filename[4:]+" to blog dir.") + filename[4:]+" to blog dir.")
auto_dir("blog/"+filename[4:]) auto_dir("blog/"+filename[4:])
shutil.copy(filename, "blog/"+filename[4:]) shutil.copy(filename, "blog/"+filename[4:])
modified_files.remove(filename) modified_files.remove(filename)
continue continue
if filename.endswith("ignore"): if filename.endswith("ignore"):
print("[INFO] (Not published) Found not published article \ print("[INFO] (Not published) Found not published article "
"+filename[4:-7]+".") + filename[4:-7]+".")
added_files.remove(filename) added_files.remove(filename)
continue continue
@ -248,16 +248,16 @@ for filename in list(deleted_files):
if ((not filename.endswith("html") and not filename.endswith("ignore")) if ((not filename.endswith("html") and not filename.endswith("ignore"))
or direct_copy): or direct_copy):
print("[INFO] (Not HTML file) Copying directly not html file \ print("[INFO] (Not HTML file) Copying directly not html file "
"+filename[4:]+" to blog dir.") + filename[4:]+" to blog dir.")
auto_dir("blog/"+filename[4:]) auto_dir("blog/"+filename[4:])
shutil.copy(filename, "blog/"+filename[4:]) shutil.copy(filename, "blog/"+filename[4:])
deleted_files.remove(filename) deleted_files.remove(filename)
continue continue
if filename.endswith("ignore"): if filename.endswith("ignore"):
print("[INFO] (Not published) Found not published article \ print("[INFO] (Not published) Found not published article "
"+filename[4:-7]+".") + filename[4:-7]+".")
added_files.remove(filename) added_files.remove(filename)
continue continue
@ -275,8 +275,8 @@ for filename in added_files:
sys.exit("[ERROR] Unable to open file "+filename+".") sys.exit("[ERROR] Unable to open file "+filename+".")
if not tags: if not tags:
sys.exit("[ERROR] (TAGS) In added article "+filename[4:]+" : \ sys.exit("[ERROR] (TAGS) In added article "+filename[4:]+" : "
No tags found !") "No tags found !")
for tag in tags: for tag in tags:
try: try:
auto_dir("gen/tags/"+tag+".tmp") auto_dir("gen/tags/"+tag+".tmp")
@ -284,11 +284,11 @@ for filename in added_files:
tag_file.seek(0) tag_file.seek(0)
if filename[4:] not in tag_file.read(): if filename[4:] not in tag_file.read():
tag_file.write(filename[4:]+"\n") tag_file.write(filename[4:]+"\n")
print("[INFO] (TAGS) Found tag "+tag+" in article \ print("[INFO] (TAGS) Found tag "+tag+" in article "
"+filename[4:]) + filename[4:])
except IOError: except IOError:
sys.exit("[ERROR] (TAGS) New tag found but an error \ sys.exit("[ERROR] (TAGS) New tag found but an error "
occured in article "+filename[4:]+": "+tag+".") "occured in article "+filename[4:]+": "+tag+".")
for filename in modified_files: for filename in modified_files:
try: try:
@ -298,8 +298,8 @@ for filename in modified_files:
sys.exit("[ERROR] Unable to open file "+filename+".") sys.exit("[ERROR] Unable to open file "+filename+".")
if not tags: if not tags:
sys.exit("[ERROR] (TAGS) In modified article "+filename[4:]+" : \ sys.exit("[ERROR] (TAGS) In modified article "+filename[4:]+" : "
No tags found !") " No tags found !")
for tag in list_directory("gen/tags/"): for tag in list_directory("gen/tags/"):
try: try:
@ -318,19 +318,19 @@ for filename in modified_files:
print("[INFO] (TAGS) Deleted tag "+tag[:tag.index(".tmp")]+" in modified article "+filename[4:]) print("[INFO] (TAGS) Deleted tag "+tag[:tag.index(".tmp")]+" in modified article "+filename[4:])
tags.remove(tag_file[9:]) tags.remove(tag_file[9:])
except IOError: except IOError:
sys.exit("[ERROR] (TAGS) An error occured when parsing tags \ sys.exit("[ERROR] (TAGS) An error occured when parsing tags "
of article "+filename[4:]+".") " of article "+filename[4:]+".")
for tag in tags: # New tags created for tag in tags: # New tags created
try: try:
auto_dir("gen/tags/"+tag+".tmp") auto_dir("gen/tags/"+tag+".tmp")
with open("gen/tags/"+tag+".tmp", "a+") as tag_file: # Delete tag file here if empty after deletion with open("gen/tags/"+tag+".tmp", "a+") as tag_file: # Delete tag file here if empty after deletion
tag_file.write(filename[4:]+"\n") tag_file.write(filename[4:]+"\n")
print("[INFO] (TAGS) Found new tag "+tag+" for \ print("[INFO] (TAGS) Found new tag "+tag+" for "
modified article "+filename[4:]) "modified article "+filename[4:])
except IOError: except IOError:
sys.exit("[ERROR] (TAGS) An error occured when parsing tags \ sys.exit("[ERROR] (TAGS) An error occured when parsing tags "
of article "+filename[4:]+".") "of article "+filename[4:]+".")
# Delete tags for deleted files and delete all generated files # Delete tags for deleted files and delete all generated files
for filename in deleted_files: for filename in deleted_files:
@ -341,8 +341,8 @@ for filename in deleted_files:
sys.exit("[ERROR] Unable to open file "+filename+".") sys.exit("[ERROR] Unable to open file "+filename+".")
if not tags: if not tags:
sys.exit("[ERROR] (TAGS) In deleted article "+filename[4:]+" : \ sys.exit("[ERROR] (TAGS) In deleted article "+filename[4:]+" : "
No tags found !") "No tags found !")
for tag in tags: for tag in tags:
try: try:
@ -350,38 +350,37 @@ for filename in deleted_files:
tag_file_old_content = tag_file.read() tag_file_old_content = tag_file.read()
tag_file.truncate() tag_file.truncate()
# Delete file in tag # Delete file in tag
tag_file.write(tag_file_old_content.replace(filename[4:]+"\n", "")) tag_file_write = tag_file_old_content.replace(filename[4:]+"\n", "")
if tag_file_write:
tag_file.write(tag_file_write)
except IOError: except IOError:
sys.exit("[ERROR] An error occured while deleting article \ sys.exit("[ERROR] An error occured while deleting article" +
"+filename[4:]+" from tags files.") filename[4:]+" from tags files.")
if not tag_file_write:
try:
os.unlink(tag)
print("[INFO] (TAGS) No more article with tag "+tag[8:-4]+", deleting it.")
except FileNotFoundError:
print("[INFO] "+tag+" was found to be empty but there was an error during deletion. You should check manually.")
# Delete generated files # Delete generated files
try: try:
os.unlink("gen/"+filename[4:-5]+".gen") os.unlink("gen/"+filename[4:-5]+".gen")
os.unlink("blog/"+filename[4:]) os.unlink("blog/"+filename[4:])
except FileNotFoundError: except FileNotFoundError:
print("[INFO] Article "+filename[4:]+" seems to not have already been \ print("[INFO] Article "+filename[4:]+" seems to not have already been "
generated. You should check manually.") "generated. You should check manually.")
print("[INFO] Deleted article "+filename[4:]+" in both gen and blog \ print("[INFO] Deleted article "+filename[4:]+" in both gen and blog "
directories") "directories")
# TODO : Delete following code
# Delete empty tags files
#for tag in list_directory("gen/tags"):
# try:
# with open(tag, 'r') as tag_file:
# content = tag_file.read().strip()
# if content == '':
# try:
# os.unlink(tag)
# os.unlink(tag.replace("gen", "blog"))
# except FileNotFoundError:
# print("[INFO] "+tag+" was found to be empty but there was an error during deletion. You should check manually.")
# print("[INFO] (TAGS) No more article with tag "+tag[8:-4]+", deleting it.")
# except IOError:
# sys.exit("[ERROR] Unable to open "+tag+".")
# Common lists that are used multiple times
last_articles = latest_articles("raw/", int(params["NB_ARTICLES_INDEX"]))
tags_full_list = list_directory("gen/tags")
# Generate html for each article
for filename in added_files+modified_files: for filename in added_files+modified_files:
try: try:
with open(filename, 'r') as fh: with open(filename, 'r') as fh:
@ -409,7 +408,7 @@ for filename in added_files+modified_files:
date_readable = "Le "+date[0:2]+"/"+date[2:4]+"/"+date[4:8]+" à "+date[9:11]+":"+date[11:13] date_readable = "Le "+date[0:2]+"/"+date[2:4]+"/"+date[4:8]+" à "+date[9:11]+":"+date[11:13]
# Write generated HTML for this article in gen / # Write generated HTML for this article in gen /
#TODO : Replace tags article = replace_tags(article, search_list, replace_list)
try: try:
auto_dir("gen/"+filename[4:-5]+".gen") auto_dir("gen/"+filename[4:-5]+".gen")
with open("gen/"+filename[4:-5]+".gen", 'w') as article_file: with open("gen/"+filename[4:-5]+".gen", 'w') as article_file:
@ -418,117 +417,97 @@ for filename in added_files+modified_files:
except IOError: except IOError:
sys.exit("[ERROR] An error occured when writing generated HTML for article "+filename[4:]+".") sys.exit("[ERROR] An error occured when writing generated HTML for article "+filename[4:]+".")
#===================================== # Starting to generate header file (except title)
#Generate headers file (except title) tags_header = "<ul>"
for tag in tags_full_list:
tags_header += "<li><a href=\""+params["BLOG_URL"]+tag[4:-4]+".html\">"+tag[9:-4]+"</a></li>"
tags_header += "</ul>"
try: try:
with open("raw/header.html", "r") as header_fh: with open("raw/header.html", "r") as header_fh:
#Tags
tags = list_directory("gen/tags")
header = header_fh.read() header = header_fh.read()
tags_header = "<ul>" except IOError:
for tag in tags: sys.exit("[ERROR] Unable to open raw/header.html file.")
tags_header += "<li><a href=\""+params["BLOG_URL"]+tag[4:-4]+".html\">"+tag[9:-4]+"</a></li>"
tags_header += "</ul>"
header = header.replace("@categories", tags_header, 1)
header = header.replace("@blog_url", params["BLOG_URL"], 1) header = header.replace("@tags", tags_header, 1)
header = header.replace("@blog_url", params["BLOG_URL"], 1)
articles_header = "<ul>"
articles_index = "<ul>"
#Articles # Generate header (except title) + index file
latest_articles_list = latest_articles("gen/", 5) del title
articles_header = "<ul>" for i, article in enumerate(last_articles):
for article in latest_articles_list:
try: try:
with open(article, 'r') as fh: with open(article, "r") as fh:
line = fh.readline() for line in fh.readlines():
while "@title" not in line: if "@title=" in line:
line = fh.readline() title = line[line.find("@title=")+7:].strip()
line = line.strip() break
title_pos = line.find("@title=")
title = line[title_pos+7:]
articles_header += "<li><a href=\""+params["BLOG_URL"]+article[4:-4]+".html\">"+title+"</a></li>"
except IOError: except IOError:
sys.exit("[ERROR] Unable to open file "+article+".") sys.exit("[ERROR] Unable to open "+article+" file.")
articles_header += "</ul>"
header = header.replace("@articles", articles_header, 1)
try: if not isset("title"):
sys.exit("[ERROR] No title found in article "+article[4:]+".")
if i < 5:
articles_header += "<li><a href=\""+params["BLOG_URL"]+article[4:-4]+".html\">"+title+"</a></li>"
articles_index += "<li><a href=\""+params["BLOG_URL"]+article[4:-4]+".html\">"+title+"</a></li>"
# Finishing header gen
articles_header += "</ul>"
header = header.replace("@articles", articles_header, 1)
try:
auto_dir("gen/header.gen") auto_dir("gen/header.gen")
with open("gen/header.gen", "w") as header_gen_fh: with open("gen/header.gen", "w") as header_gen_fh:
header_gen_fh.write(header) header_gen_fh.write(header)
print("[INFO] (HEADER) Header has been generated successfully.") print("[INFO] (HEADER) Header has been generated successfully.")
except FileNotFoundError: except FileNotFoundError:
sys.exit("[ERROR] (HEADER) An error occured while writing header file.") sys.exit("[ERROR] (HEADER) An error occured while writing header file.")
except IOError: except IOError:
sys.exit("[ERROR] Unable to open gen/header.gen for writing.") sys.exit("[ERROR] Unable to open gen/header.gen for writing.")
except IOError:
sys.exit("[ERROR] Unable to open raw/header.html file.")
#Generate footer file # Getting content from footer file
if not os.path.isfile("raw/footer.html"):
sys.exit("[ERROR] (FOOTER) Footer file (raw/footer.html) not found.")
try: try:
shutil.copy("raw/footer.html", "gen/footer.gen") with open("raw/footer.html", "r") as footer_fh:
print("[INFO] (FOOTER) Footer has been generated successfully") footer = footer_fh.read()
except IOError: except IOError:
sys.exit("[ERROR] Unable to copy the footer.html file.") sys.exit("[ERROR] An error occured while parsing footer file raw/footer.html.")
#Copy CSS files # Finishing index gen
if not os.path.isdir("raw/css") or list_directory("raw/css") == []: articles_index += "</ul>"
print("[INFO] (CSS) No CSS files in raw/css folder") index = header.replace("@title", params["BLOG_TITLE"], 1) + articles_index + footer
else:
try:
shutil.copytree("raw/css", "blog/css")
except IOError:
sys.exit("[ERROR] An error occured while copying css files.")
#Regenerate index file
last_articles_index = latest_articles("gen/", int(params["NB_ARTICLES_INDEX"]))
try: try:
auto_dir("blog/index.html")
with open("blog/index.html", "w") as index_fh: with open("blog/index.html", "w") as index_fh:
try:
with open("gen/header.gen", "r") as header_gen_fh:
index = header_gen_fh.read()
for article in last_articles_index:
with open(article, "r") as article_fh:
index += replace_tags(article_fh.read(), search_list, replace_list)
with open("gen/footer.gen") as footer_gen_fh:
index += footer_gen_fh.read()
index = index.replace("@titre", params["BLOG_TITLE"], 1)
index_fh.write(index) index_fh.write(index)
print("[INFO] (INDEX) Index page has been generated successfully.") print("[INFO] (INDEX) Index page has been generated successfully.")
except IOError: except IOError:
sys.exit("[ERROR] Error while creating index.html file") sys.exit("[ERROR] Error while creating index.html file")
except IOError: except IOError:
sys.exit("[ERROR] Unable to open index.html file for writing.") sys.exit("[ERROR] Unable to open index.html file for writing.")
#Regenerate tags pages # Regenerate tags pages
for tag in list_directory("gen/tags"): for tag in tags_full_list:
tag_content = header.replace("@title", params["BLOG_TITLE"]+" - "+tag[4:-4], 1)
with open(tag, "r") as tag_gen_fh:
for line in tag_gen_fh.readlines():
line = line.replace(".html", ".gen")
with open("gen/"+line.strip(), "r") as article_fh:
tag_content += article_fh.read()
tag_content += footer
try: try:
auto_dir(tag.replace("gen/", "blog/")) auto_dir(tag.replace("gen/", "blog/"))
with open(tag.replace("gen/", "blog/")[:-4]+".html", "w") as tag_fh: with open(tag.replace("gen/", "blog/")[:-4]+".html", "w") as tag_fh:
with open(tag, "r") as tag_gen_fh:
with open("gen/header.gen", "r") as header_fh:
tag_content = header_fh.read()
tag_content = tag_content.replace("@titre", params["BLOG_TITLE"]+" - "+tag[4:-4], 1)
tag_gen_fh_lines = tag_gen_fh.readlines()
for line in tag_gen_fh_lines:
line = line.replace(".html", ".gen")
with open("gen/"+line.strip(), "r") as article_handler:
tag_content += replace_tags(article_handler.read(), search_list, replace_list)
with open("gen/footer.gen", "r") as footer_handler:
tag_content += footer_handler.read()
tag_fh.write(tag_content) tag_fh.write(tag_content)
print("[INFO] (TAGS) Tag page for "+tag[9:-4]+" has been generated successfully.") print("[INFO] (TAGS) Tag page for "+tag[9:-4]+" has been generated successfully.")
except IOError: except IOError:
sys.exit("[ERROR] An error occured while generating tag page \""+tag[9:-4]+"\"") sys.exit("[ERROR] An error occured while generating tag page \""+tag[9:-4]+"\"")
#Finish articles pages generation # Finish articles pages generation
for filename in added_files+modified_files: for filename in added_files+modified_files:
try: try:
auto_dir("blog/"+filename[4:]) auto_dir("blog/"+filename[4:])
with open("blog/"+filename[4:], "w") as article_fh: with open("blog/"+filename[4:], "w") as article_fh:
@ -543,7 +522,7 @@ for filename in added_files+modified_files:
title = line[title_pos+7:] title = line[title_pos+7:]
article_gen_fh.seek(0) article_gen_fh.seek(0)
article = article.replace("@titre", params["BLOG_TITLE"]+" - "+title, 1) article = article.replace("@title", params["BLOG_TITLE"]+" - "+title, 1)
article += replace_tags(article_gen_fh.read(), search_list, replace_list) article += replace_tags(article_gen_fh.read(), search_list, replace_list)
with open("gen/footer.gen", "r") as footer_gen_fh: with open("gen/footer.gen", "r") as footer_gen_fh:
article += footer_gen_fh.read() article += footer_gen_fh.read()
@ -552,7 +531,8 @@ for filename in added_files+modified_files:
except IOError: except IOError:
sys.exit("[ERROR] An error occured while generating article "+filename[4:]+" page.") sys.exit("[ERROR] An error occured while generating article "+filename[4:]+" page.")
#Generate pages for each year and month #======================================
# Generate pages for each year and month
with open("gen/header.gen", "r") as header_gen_fh: with open("gen/header.gen", "r") as header_gen_fh:
header_gen = header_gen_fh.read() header_gen = header_gen_fh.read()
@ -567,8 +547,8 @@ for i in years_list:
except ValueError: except ValueError:
continue continue
#Generate page per year # Generate page per year
page_year = header_gen.replace("@titre", params["BLOG_TITLE"]+" - "+i, 1) page_year = header_gen.replace("@title", params["BLOG_TITLE"]+" - "+i, 1)
months_list = os.listdir("blog/"+i) months_list = os.listdir("blog/"+i)
months_list.sort(reverse=True) months_list.sort(reverse=True)
@ -576,8 +556,8 @@ for i in years_list:
if not os.path.isdir("blog/"+i+"/"+j): if not os.path.isdir("blog/"+i+"/"+j):
continue continue
#Generate pages per month # Generate pages per month
page_month = header_gen.replace("@titre", params["BLOG_TITLE"]+" - "+i+"/"+j, 1) page_month = header_gen.replace("@title", params["BLOG_TITLE"]+" - "+i+"/"+j, 1)
articles_list = list_directory("gen/"+i+"/"+j) articles_list = list_directory("gen/"+i+"/"+j)
articles_list.sort(key=lambda x: os.stat(x).st_mtime, reverse=True) articles_list.sort(key=lambda x: os.stat(x).st_mtime, reverse=True)
@ -605,13 +585,13 @@ for i in years_list:
sys.exit("[ERROR] Unable to write index file for "+i+".") sys.exit("[ERROR] Unable to write index file for "+i+".")
#Generate RSS # Generate RSS
rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">" rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">"
rss += "<channel><atom:link href=\""+params["BLOG_URL"]+"rss.xml\" rel=\"self\" type=\"application/rss+xml\"/><title>"+params["BLOG_TITLE"]+"</title><link>"+params["BLOG_URL"]+"</link>" rss += "<channel><atom:link href=\""+params["BLOG_URL"]+"rss.xml\" rel=\"self\" type=\"application/rss+xml\"/><title>"+params["BLOG_TITLE"]+"</title><link>"+params["BLOG_URL"]+"</link>"
rss += "<description>"+params["DESCRIPTION"]+"</description><language>"+params["LANGUAGE"]+"</language><copyright>"+params["COPYRIGHT"]+"</copyright>" rss += "<description>"+params["DESCRIPTION"]+"</description><language>"+params["LANGUAGE"]+"</language><copyright>"+params["COPYRIGHT"]+"</copyright>"
rss += "<webMaster>"+params["WEBMASTER"]+"</webMaster><lastBuildDate>"+strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())+"</lastBuildDate>" rss += "<webMaster>"+params["WEBMASTER"]+"</webMaster><lastBuildDate>"+strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())+"</lastBuildDate>"
for article in last_articles_index: for article in last_articles:
del date, title del date, title
try: try:
with open(article, "r") as article_fh: with open(article, "r") as article_fh: