Compare commits

...

2 Commits

Author SHA1 Message Date
tiyn 93767e6c8b removing empty logo
2 years ago
tiyn 6f5c5a98af src: fixed quote-signs
2 years ago

@ -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)

@ -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 += '</ul>\n'
content_string += '<h2>' + curr_month + '</h2>\n'
content_string += '<ul>\n'
if last_month != "":
content_string += "</ul>\n"
content_string += "<h2>" + curr_month + "</h2>\n"
content_string += "<ul>\n"
last_month = curr_month
filename = pathlib.PurePath(file)
title = open(filename).readline().rstrip('\n')
title = open(filename).readline().rstrip("\n")
filename = filename.name
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> - '
content_string += '<a href="' + '/entry/' + \
pathlib.PurePath(file).name + '">' + 'standalone' + '</a>'
content_string += '] <br>'
content_string += '</li>\n'
content_string += '</ul>\n'
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> - "
content_string += "<a href=\"" + "/entry/" + \
pathlib.PurePath(file).name + "\">" + "standalone" + "</a>"
content_string += "] <br>"
content_string += "</li>\n"
content_string += "</ul>\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 += '<div class=\'entry\'>\n'
content_string += '<h2 id=\'' + filename + '\'>' + title + '</h2>\n'
content_string += '[<a href="' + '/entry/' + \
pathlib.PurePath(file).name + '">' + \
'standalone' + '</a>]<br>\n'
if file.endswith('.html'):
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/" + \
pathlib.PurePath(file).name + "\">" + \
"standalone" + "</a>]<br>\n"
if file.endswith(".html"):
for line in text:
content_string += line
content_string += '<br>'
if file.endswith('.md'):
content_string += "<br>"
if file.endswith(".md"):
content_string += gen_md_content(file, 2)
content_string += '<small>' + \
content_string += "<small>" + \
datetime.fromtimestamp(os.path.getctime(
file)).strftime('%Y-%m-%d') + '</small>'
content_string += '</div>'
file)).strftime("%Y-%m-%d") + "</small>"
content_string += "</div>"
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 += '<h1>' + title + '</h1>\n'
content_string += '['
content_string += '<a href="' + '/index.html#' + \
filename_no_end + '">' + 'link' + '</a>'
content_string += ']<br>\n'
if filename.endswith('.html'):
filename_no_end = filename.split(".", 1)[0]
content_string += "<h1>" + title + "</h1>\n"
content_string += "["
content_string += "<a href=\"" + "/index.html#" + \
filename_no_end + "\">" + "link" + "</a>"
content_string += "]<br>\n"
if filename.endswith(".html"):
for line in text:
content_string += line
content_string += '<br>'
if filename.endswith('.md'):
content_string += "<br>"
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 += '<item>\n'
content_string += '<title>' + title + '</title>\n'
content_string += '<guid>' + config.WEBSITE + \
'/index.html#' + filename + '</guid>\n'
content_string += '<pubDate>' + \
if filename[0] != ".":
filename = filename.split(".", 1)[0]
content_string += "<item>\n"
content_string += "<title>" + title + "</title>\n"
content_string += "<guid>" + config.WEBSITE + \
"/index.html#" + filename + "</guid>\n"
content_string += "<pubDate>" + \
datetime.fromtimestamp(os.path.getctime(file)).strftime(
'%Y-%m-%d') + '</pubDate>\n'
content_string += '<description>'
"%Y-%m-%d") + "</pubDate>\n"
content_string += "<description>"
for line in text:
content_string += line
content_string += '</description>\n'
content_string += '</item>\n'
content_string += "</description>\n"
content_string += "</item>\n"
return content_string

@ -13,8 +13,8 @@
<input type="checkbox" id="main-menu-check">
<label for="main-menu-check" class="show-menu">&#9776;</label>
<div class="main-menu">
<a href="/">Blog</a>
<a href="/archive">Archive</a>
<a href="{{ url_for('index') }}">Blog</a>
<a href="{{ url_for('archive') }}">Archive</a>
<label for="main-menu-check" class="hide-menu">X</label>
</div>
</div>

Loading…
Cancel
Save