src: cleanup

master
tiyn 2 years ago
parent b4609b88c6
commit b693bcdabc

@ -32,34 +32,38 @@ REGISTER = config.REGISTER
@app.errorhandler(404)
def page_not_found(e):
return render_template("error.html", title=TITLE, errorcode="404", style=STYLE), 404
return render_template("error.html", title=TITLE, errorcode="404",
style=STYLE), 404
@app.route("/")
@app.route("/index.html")
def index():
content = con_gen.gen_index_string()
return render_template("index.html", title=TITLE, content_string=content, style=STYLE)
return render_template("index.html", title=TITLE, content_string=content,
style=STYLE)
@app.route("/archive")
@app.route("/archive.html")
def archive():
content = con_gen.gen_arch_string()
return render_template("archive.html", title=TITLE, content_string=content, style=STYLE)
return render_template("archive.html", title=TITLE, content_string=content,
style=STYLE)
@app.route("/entry/<ident>")
def entry(ident):
content = con_gen.gen_stand_string(ident)
if content != "":
return render_template("standalone.html", title=TITLE, content_string=content, style=STYLE)
return render_template("standalone.html", title=TITLE,
content_string=content, style=STYLE)
abort(404)
@app.route("/feed")
@app.route("/rss")
@app.route("/feed.xml")
@app.route("/rss")
@app.route("/rss.xml")
def feed():
content = con_gen.get_rss_string()

@ -35,6 +35,7 @@ def gen_arch_string():
if entries is None:
return ""
entries.sort(key=lambda y: y[2])
entries.reverse()
for entry in entries:
ident = entry[0]
title = entry[1]
@ -47,9 +48,9 @@ def gen_arch_string():
content_string += "<ul>\n"
last_year = year
content_string += "<li>"
content_string += "[<a href=\"" + url_for("index", _anchor=str(ident)) + \
"\">link</a> - <a href=\"" + url_for("entry", ident=str(ident)) + \
"\">standalone</a>] "
content_string += "[<a href=\"" + \
url_for("index", _anchor=str(ident)) + "\">link</a> - <a href=\"" \
+ url_for("entry", ident=str(ident)) + "\">standalone</a>] "
content_string += title + " " + rating_to_star(rating)
content_string += "<br></li>\n"

@ -69,7 +69,8 @@ class Database:
if self.check_user_name(user.name) and user.pass_hash is not None:
db = self.connect()
crs = db.cursor()
query = "INSERT INTO " + self.USER_TABLE_FILE + "(`name`,`password`)" + \
query = "INSERT INTO " + self.USER_TABLE_FILE + \
"(`name`,`password`)" + \
"VALUES (?, ?) ON CONFLICT DO NOTHING"
crs.execute(query, (user.name, user.pass_hash))
db.commit()
@ -82,7 +83,8 @@ class Database:
db = self.connect()
crs = db.cursor()
reviewed = dt.today().strftime('%Y-%m-%d')
query = "INSERT INTO " + self.ENTRY_TABLE_FILE + "(`name`,`date`, `text`, `rating`, `user_id`, `reviewed`)" + \
query = "INSERT INTO " + self.ENTRY_TABLE_FILE + \
"(`name`,`date`, `text`, `rating`, `user_id`, `reviewed`)" + \
"VALUES (?, ?, ?, ?, ?, ?)"
crs.execute(query, (name, date, text, rating, user_id, reviewed))
db.commit()
@ -125,9 +127,3 @@ class Database:
user = User(name, pass_hash)
user.set_id(ident)
return user
#db = Database()
#db.insert_entry("name", "2020", "text", 50, 1)
#res = db.get_entries()
# print(res)

@ -38,6 +38,21 @@ footer .center {
text-align: center;
}
li:not(:last-child) {
margin-bottom: 5px;
}
ol {
margin: 10px 0;
padding-left: 20;
}
ul {
margin: 10px 0;
padding-left: 20;
}
.container {
min-height: 100%;
padding-bottom: 50px;
@ -162,8 +177,3 @@ footer .center {
.entry h2 {
margin: 5px auto 2px auto;
}
.entry ul {
padding-left: 20;
}

@ -1,4 +1,5 @@
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="blogarchive">

@ -1,4 +1,5 @@
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="important">

@ -1,4 +1,5 @@
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="blog">

@ -1,4 +1,5 @@
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="standalone">

@ -1,3 +1,8 @@
{% set navigation_bar = [
(url_for("index"), 'index', 'Blog'),
(url_for("archive"), 'archive', 'Archive')
] -%}
<html>
<head>
<title>{{ title }}</title>
@ -13,8 +18,9 @@
<input type="checkbox" id="main-menu-check">
<label for="main-menu-check" class="show-menu">&#9776;</label>
<div class="main-menu">
<a href="{{ url_for('index') }}">Blog</a>
<a href="{{ url_for('archive') }}">Archive</a>
{% for href, id, caption in navigation_bar %}
<a href="{{ href|e }}">{{ caption|e }}</a>
{% endfor %}
<label for="main-menu-check" class="hide-menu">X</label>
</div>
</div>

Loading…
Cancel
Save