|
|
|
@ -1,12 +1,20 @@
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
import markdown
|
|
|
|
|
import locale
|
|
|
|
|
import os
|
|
|
|
|
from os import path
|
|
|
|
|
import pathlib
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
import config
|
|
|
|
|
import markdown
|
|
|
|
|
|
|
|
|
|
ENTRY_DIR = "templates/entry"
|
|
|
|
|
LANGUAGE = config.LANGUAGE
|
|
|
|
|
LOCAL = "de_DE.UTF-8" if LANGUAGE == "de-de" else "en_US.UTF-8"
|
|
|
|
|
|
|
|
|
|
locale.setlocale(locale.LC_TIME, LOCAL)
|
|
|
|
|
|
|
|
|
|
standalone_str = "Artikel" if LANGUAGE == "de-de" else "standalone"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_arch_string():
|
|
|
|
|
"""
|
|
|
|
@ -23,10 +31,8 @@ def gen_arch_string():
|
|
|
|
|
content_string = ""
|
|
|
|
|
last_month = ""
|
|
|
|
|
for file in reversed(contents):
|
|
|
|
|
curr_date = datetime.fromtimestamp(
|
|
|
|
|
os.path.getctime(file)).strftime("%Y-%m-%d")
|
|
|
|
|
curr_month = datetime.fromtimestamp(
|
|
|
|
|
os.path.getctime(file)).strftime("%b %Y")
|
|
|
|
|
curr_date = datetime.fromtimestamp(os.path.getctime(file)).strftime("%Y-%m-%d")
|
|
|
|
|
curr_month = datetime.fromtimestamp(os.path.getctime(file)).strftime("%B %Y")
|
|
|
|
|
if curr_month != last_month:
|
|
|
|
|
if last_month != "":
|
|
|
|
|
content_string += "</ul>\n"
|
|
|
|
@ -39,13 +45,11 @@ def gen_arch_string():
|
|
|
|
|
if filename[0] != ".":
|
|
|
|
|
filename = filename.split(".", 1)[0]
|
|
|
|
|
content_string += "<li>"
|
|
|
|
|
content_string += curr_date + " - "
|
|
|
|
|
content_string += title + " ["
|
|
|
|
|
content_string += "<a href=\"" + "/index.html#" + \
|
|
|
|
|
filename + "\">" + "link" + "</a> - "
|
|
|
|
|
filename + "\">" + curr_date + "</a> - "
|
|
|
|
|
content_string += "<a href=\"" + "/entry/" + \
|
|
|
|
|
pathlib.PurePath(file).name + "\">" + "standalone" + "</a>"
|
|
|
|
|
content_string += "] <br>"
|
|
|
|
|
pathlib.PurePath(file).name + "\"><b>" + title + "</b></a>"
|
|
|
|
|
content_string += "<br>"
|
|
|
|
|
content_string += "</li>\n"
|
|
|
|
|
content_string += "</ul>\n"
|
|
|
|
|
return content_string
|
|
|
|
@ -73,19 +77,19 @@ def gen_index_string():
|
|
|
|
|
if filename[0] != ".":
|
|
|
|
|
filename = filename.split(".", 1)[0]
|
|
|
|
|
content_string += "<div class=\"entry\">\n"
|
|
|
|
|
content_string += "<h2 id=\"" + filename + "\">" + title + "</h2>\n"
|
|
|
|
|
content_string += "[<a href=\"" + "/entry/" + \
|
|
|
|
|
content_string += "<h2 id=\"" + filename + "\">"
|
|
|
|
|
content_string += "<a href=\"" + "/entry/" + \
|
|
|
|
|
pathlib.PurePath(file).name + "\">" + \
|
|
|
|
|
"standalone" + "</a>]<br>\n"
|
|
|
|
|
title + "</a>" +"</h2>\n"
|
|
|
|
|
content_string += "<small>" + \
|
|
|
|
|
datetime.fromtimestamp(os.path.getctime(
|
|
|
|
|
file)).strftime("%Y-%m-%d") + "</small><br><br>"
|
|
|
|
|
if file.endswith(".html"):
|
|
|
|
|
for line in text:
|
|
|
|
|
content_string += line
|
|
|
|
|
content_string += "<br>"
|
|
|
|
|
if file.endswith(".md"):
|
|
|
|
|
content_string += gen_md_content(file, 2)
|
|
|
|
|
content_string += "<small>" + \
|
|
|
|
|
datetime.fromtimestamp(os.path.getctime(
|
|
|
|
|
file)).strftime("%Y-%m-%d") + "</small>"
|
|
|
|
|
content_string += "</div>"
|
|
|
|
|
return content_string
|
|
|
|
|
|
|
|
|
@ -107,13 +111,13 @@ def gen_stand_string(path_ex):
|
|
|
|
|
if path.exists(filename):
|
|
|
|
|
title = open(filename).readline().rstrip("\n")
|
|
|
|
|
text = open(filename).readlines()[1:]
|
|
|
|
|
curr_date = datetime.fromtimestamp(os.path.getctime(filename)).strftime("%Y-%m-%d")
|
|
|
|
|
filename_no_end = filename.split(".", 1)[0]
|
|
|
|
|
filename_no_end = filename_no_end.split("/")[-1]
|
|
|
|
|
content_string += "<h1>" + title + "</h1>\n"
|
|
|
|
|
content_string += "["
|
|
|
|
|
content_string += "<a href=\"" + "/index.html#" + \
|
|
|
|
|
filename_no_end + "\">" + "link" + "</a>"
|
|
|
|
|
content_string += "]<br>\n"
|
|
|
|
|
filename_no_end + "\">" + curr_date + "</a>"
|
|
|
|
|
content_string += "<br>\n"
|
|
|
|
|
if filename.endswith(".html"):
|
|
|
|
|
for line in text:
|
|
|
|
|
content_string += line
|
|
|
|
@ -146,9 +150,7 @@ def gen_md_content(path_ex, depth):
|
|
|
|
|
markdown_text = ""
|
|
|
|
|
for line in markdown_lines:
|
|
|
|
|
markdown_text += line.replace("# ", header)
|
|
|
|
|
content_string = markdown.markdown(
|
|
|
|
|
markdown_text, extensions=["fenced_code", "tables"]
|
|
|
|
|
)
|
|
|
|
|
content_string = markdown.markdown(markdown_text, extensions=["fenced_code", "tables"])
|
|
|
|
|
return content_string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|