From 6f5c5a98affeeee3a5cd51ff0eba1265f8e272f9 Mon Sep 17 00:00:00 2001 From: tiyn Date: Fri, 29 Jul 2022 23:03:37 +0200 Subject: [PATCH] src: fixed quote-signs --- src/app.py | 4 +- src/content.py | 136 ++++++++++++++++++------------------ src/templates/template.html | 4 +- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/app.py b/src/app.py index 0b236e7..8d947bf 100644 --- a/src/app.py +++ b/src/app.py @@ -1,4 +1,4 @@ -from flask import Flask, flash, make_response, render_template, request, redirect, abort +from flask import Flask, make_response, render_template, abort import content as con_gen import config @@ -25,7 +25,7 @@ def index(): @app.route("/archive") @app.route("/archive.html") -def blog_archive(): +def archive(): content = con_gen.gen_arch_string() return render_template("archive.html", title=TITLE, content_string=content, style=STYLE) diff --git a/src/content.py b/src/content.py index ffd16c9..3024b4e 100644 --- a/src/content.py +++ b/src/content.py @@ -6,7 +6,7 @@ import pathlib import config -ENTRY_DIR = 'templates/entry' +ENTRY_DIR = "templates/entry" def gen_arch_string(): """ @@ -20,34 +20,34 @@ def gen_arch_string(): name_list = os.listdir(path_ex) full_list = [os.path.join(path_ex, i) for i in name_list] contents = sorted(full_list, key=os.path.getctime) - content_string = '' - last_month = '' + content_string = "" + last_month = "" for file in reversed(contents): curr_date = datetime.fromtimestamp( - os.path.getctime(file)).strftime('%Y-%m-%d') + os.path.getctime(file)).strftime("%Y-%m-%d") curr_month = datetime.fromtimestamp( - os.path.getctime(file)).strftime('%b %Y') + os.path.getctime(file)).strftime("%b %Y") if curr_month != last_month: - if last_month != '': - content_string += '\n' - content_string += '

' + curr_month + '

\n' - content_string += '\n" + content_string += "

" + curr_month + "

\n" + content_string += "\n' + if filename[0] != ".": + filename = filename.split(".", 1)[0] + content_string += "
  • " + content_string += curr_date + " - " + content_string += title + " [" + content_string += "" + "link" + " - " + content_string += "" + "standalone" + "" + content_string += "]
    " + content_string += "
  • \n" + content_string += "\n" return content_string @@ -59,7 +59,7 @@ def gen_index_string(): string: html-formatted index string """ path_ex = ENTRY_DIR - content_string = '' + content_string = "" if path.exists(path_ex): name_list = os.listdir(path_ex) full_list = [os.path.join(path_ex, i) for i in name_list] @@ -67,26 +67,26 @@ def gen_index_string(): for file in reversed(contents): filename = pathlib.PurePath(file) purefile = filename - title = open(filename).readline().rstrip('\n') + title = open(filename).readline().rstrip("\n") text = open(filename).readlines()[1:] filename = filename.name - if filename[0] != '.': - filename = filename.split('.', 1)[0] - content_string += '
    \n' - content_string += '

    ' + title + '

    \n' - content_string += '[' + \ - 'standalone' + ']
    \n' - if file.endswith('.html'): + if filename[0] != ".": + filename = filename.split(".", 1)[0] + content_string += "
    \n" + content_string += "

    " + title + "

    \n" + content_string += "[" + \ + "standalone" + "]
    \n" + if file.endswith(".html"): for line in text: content_string += line - content_string += '
    ' - if file.endswith('.md'): + content_string += "
    " + if file.endswith(".md"): content_string += gen_md_content(file, 2) - content_string += '' + \ + content_string += "" + \ datetime.fromtimestamp(os.path.getctime( - file)).strftime('%Y-%m-%d') + '' - content_string += '
    ' + file)).strftime("%Y-%m-%d") + "" + content_string += "
    " return content_string @@ -103,21 +103,21 @@ def gen_stand_string(path_ex): string: html-formatted string string equivalent to the file """ filename = os.path.join(ENTRY_DIR, path_ex) - content_string = '' + content_string = "" if path.exists(filename): - title = open(filename).readline().rstrip('\n') + title = open(filename).readline().rstrip("\n") text = open(filename).readlines()[1:] - filename_no_end = filename.split('.', 1)[0] - content_string += '

    ' + title + '

    \n' - content_string += '[' - content_string += '' + 'link' + '' - content_string += ']
    \n' - if filename.endswith('.html'): + filename_no_end = filename.split(".", 1)[0] + content_string += "

    " + title + "

    \n" + content_string += "[" + content_string += "" + "link" + "" + content_string += "]
    \n" + if filename.endswith(".html"): for line in text: content_string += line - content_string += '
    ' - if filename.endswith('.md'): + content_string += "
    " + if filename.endswith(".md"): content_string += gen_md_content(filename, 1) return content_string @@ -133,18 +133,18 @@ def gen_md_content(path_ex, depth): Returns: string: html-formatted string string equivalent to the markdown file """ - content_string = '' + content_string = "" if path.exists(path_ex): - filename = path_ex.split('.', 1) + filename = path_ex.split(".", 1) fileend = filename[len(filename) - 1] - header = '#' + header = "#" for i in range(depth): - header += '#' - header += ' ' + header += "#" + header += " " markdown_lines = open(path_ex, "r").readlines()[1:] - markdown_text = '' + markdown_text = "" for line in markdown_lines: - markdown_text += line.replace('# ', header) + markdown_text += line.replace("# ", header) content_string = markdown.markdown( markdown_text, extensions=["fenced_code", "tables"] ) @@ -163,24 +163,24 @@ def get_rss_string(): name_list = os.listdir(path_ex) full_list = [os.path.join(path_ex, i) for i in name_list] contents = sorted(full_list, key=os.path.getctime) - content_string = '' + content_string = "" for file in reversed(contents): filename = pathlib.PurePath(file) - title = open(filename).readline().rstrip('\n') + title = open(filename).readline().rstrip("\n") text = open(filename).readlines()[1:] filename = filename.name - if filename[0] != '.': - filename = filename.split('.', 1)[0] - content_string += '\n' - content_string += '' + title + '\n' - content_string += '' + config.WEBSITE + \ - '/index.html#' + filename + '\n' - content_string += '' + \ + if filename[0] != ".": + filename = filename.split(".", 1)[0] + content_string += "\n" + content_string += "" + title + "\n" + content_string += "" + config.WEBSITE + \ + "/index.html#" + filename + "\n" + content_string += "" + \ datetime.fromtimestamp(os.path.getctime(file)).strftime( - '%Y-%m-%d') + '\n' - content_string += '' + "%Y-%m-%d") + "\n" + content_string += "" for line in text: content_string += line - content_string += '\n' - content_string += '\n' + content_string += "\n" + content_string += "\n" return content_string diff --git a/src/templates/template.html b/src/templates/template.html index 683dad3..c696a91 100644 --- a/src/templates/template.html +++ b/src/templates/template.html @@ -13,8 +13,8 @@