major config rebuild using once cell. added ability to use .env.
This commit is contained in:
parent
35cd018152
commit
c30976f2d7
26 changed files with 207 additions and 186 deletions
63
site/content/static/css/blog.css
Normal file
63
site/content/static/css/blog.css
Normal file
|
@ -0,0 +1,63 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
padding: 20px;
|
||||
width: 60%;
|
||||
padding-left: 20%;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 50%;
|
||||
padding: 20px 0px 20px 0px;
|
||||
}
|
||||
|
||||
article {
|
||||
padding-top: 2em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.post-link {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.post-title {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.post-publish-date {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
.post-body {
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
#submit-form {
|
||||
padding-top: 2em;
|
||||
}
|
||||
|
||||
#submit-body, #submit-title {
|
||||
width: 100%;
|
||||
margin-bottom: 2em;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
#submit-body {
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
#submit-form {
|
||||
display: block
|
||||
}
|
||||
|
||||
@media (max-width:1080px) {
|
||||
html {
|
||||
padding: 20px;
|
||||
width: 90%;
|
||||
padding-left: 5%;
|
||||
}
|
||||
}
|
24
site/content/static/css/index.css
Normal file
24
site/content/static/css/index.css
Normal file
|
@ -0,0 +1,24 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
padding: 20px;
|
||||
width: 60%;
|
||||
padding-left: 20%;
|
||||
}
|
||||
|
||||
.social-icon {
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
}
|
||||
|
||||
@media (max-width:1080px) {
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
padding: 20px;
|
||||
width: 90%;
|
||||
padding-left: 5%;
|
||||
}
|
BIN
site/content/static/favicon.ico
Executable file
BIN
site/content/static/favicon.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 318 B |
35
site/content/static/js/blog.js
Normal file
35
site/content/static/js/blog.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
function setTokenCookie() {
|
||||
let token = document.getElementById('set-token').value;
|
||||
let tokenCookie = 'token=' + token + "; SameSite=None; secure";
|
||||
document.cookie = tokenCookie;
|
||||
setFormTokens(token);
|
||||
document.getElementById("cookie-block").hidden = true;
|
||||
}
|
||||
|
||||
function clearTokenCookie() {
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; SameSite=None; secure";
|
||||
document.getElementById("cookie-block").hidden = false;
|
||||
}
|
||||
|
||||
function setFormTokens(token) {
|
||||
let tokenFields = document.querySelectorAll(".token");
|
||||
for (t of tokenFields) {
|
||||
t.value = token;
|
||||
}
|
||||
}
|
||||
|
||||
// if cookie is set, use it to pass the token
|
||||
let c_pairs = document.cookie.split(";");
|
||||
let cookie_set = false;
|
||||
for (c of c_pairs) {
|
||||
if (c.trim().split("=")[0].startsWith("token")){
|
||||
// stick token into all the form input fields
|
||||
let token = c.split("=")[1];
|
||||
setFormTokens(token);
|
||||
cookie_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cookie_set) {
|
||||
document.getElementById("cookie-block").hidden = false;
|
||||
}
|
BIN
site/content/static/social-icons/discord.ico
Normal file
BIN
site/content/static/social-icons/discord.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 614 B |
BIN
site/content/static/social-icons/github.ico
Normal file
BIN
site/content/static/social-icons/github.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
BIN
site/content/static/social-icons/mastodon.ico
Normal file
BIN
site/content/static/social-icons/mastodon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
BIN
site/content/static/social-icons/reddit.ico
Normal file
BIN
site/content/static/social-icons/reddit.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
site/content/static/social-icons/twitter.ico
Normal file
BIN
site/content/static/social-icons/twitter.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
43
site/content/templates/about.html
Normal file
43
site/content/templates/about.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="{{ username }}' site'" />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title>{{ username }}' site</title>
|
||||
<link rel="stylesheet" href="/static/css/index.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hi, I'm {{ username }}</h1>
|
||||
<p style="text-align: right">
|
||||
<a href="/">Back to the blog</a>
|
||||
</p>
|
||||
<p>
|
||||
This is my blog. If you have questions or input for me please send me an E-Mail to {{ email }}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
<ul style="list-style: none;">
|
||||
{% if github_account %}
|
||||
<li><img class="social-icon" src="/static/social-icons/github.ico"><a href="https://github.com/{{ github_account }}"> {{ github_account }}</a></li>
|
||||
{% endif %}
|
||||
{% if twitter_account %}
|
||||
<li><img class="social-icon" src="/static/social-icons/twitter.ico"><a href="https://twitter.com/{{ twitter_account }}"> {{ twitter_account }}</a></li>
|
||||
{% endif %}
|
||||
{% if reddit_account %}
|
||||
<li><img class="social-icon" src="/static/social-icons/reddit.ico"><a href="https://reddit.com/u/{{ reddit_account }}"> {{ reddit_account }}</a></li>
|
||||
{% endif %}
|
||||
{% if mastodon_account %}
|
||||
<li><img class="social-icon" src="/static/social-icons/mastodon.ico"><a href="https://mastodon.social/"> {{ mastodon_account }}</a></li>
|
||||
{% endif %}
|
||||
{% if discord_account %}
|
||||
<li><img class="social-icon" src="/static/social-icons/discord.ico"><a href="https://discord.com/"> {{ discord_account }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
35
site/content/templates/blog-all-posts.html
Normal file
35
site/content/templates/blog-all-posts.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="{{ username }}' blog" />
|
||||
<meta property="og:description" content="List of all posts" />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title> All posts </title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }}' blog</a></h1>
|
||||
<p style="text-align: right">
|
||||
<a href="/about">About</a>
|
||||
<a href="/">Last 5 posts</a>
|
||||
</p>
|
||||
<ul>
|
||||
{% for post in posts %}
|
||||
<article>
|
||||
<div>
|
||||
<a href="/id/{{ post.id }}" class="post-link">[link]</a>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
<h2 class="post-title">{{ post.title }}</h2>
|
||||
<sub class="post-publish-date"> {{ post.publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
35
site/content/templates/blog-by-id.html
Normal file
35
site/content/templates/blog-by-id.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content=" {{ post.title }} | {{ username }}' blog" />
|
||||
<meta property="og:description" content="{{ post.body | striptags }}" />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title> {{ post.title }} | {{ username }}' blog </title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }}' blog</a></h1>
|
||||
<p style="text-align: right">
|
||||
<a href="/">Home</a>
|
||||
<a href="/about">About</a>
|
||||
<a href="/all">All Posts</a>
|
||||
</p>
|
||||
<ul>
|
||||
<article>
|
||||
<div>
|
||||
<a href="/id/{{ post.id }}" class="post-link">[link]</a>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
<h2 class="post-title">{{ post.title }}</h2>
|
||||
<sub class="post-publish-date"> {{ post.publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
||||
<p class="post-body">{{ post.body }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
38
site/content/templates/blog.html
Normal file
38
site/content/templates/blog.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="{{ username }}' blog" />
|
||||
<meta property="og:description" content="Last 5 posts" />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title> {{ username }}' blog </title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }} blog</a></h1>
|
||||
<p style="text-align: right">
|
||||
<a href="/about">About</a>
|
||||
<a href="/all">All Posts</a>
|
||||
</p>
|
||||
<ul>
|
||||
{% for post in posts %}
|
||||
<article>
|
||||
<div>
|
||||
<a href="/id/{{ post.id }}" class="post-link">[link]</a>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
<h2 class="post-title">{{ post.title }}</h2>
|
||||
<sub class="post-publish-date"> {{ post.publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
||||
<p class="post-body">{{ post.body }}</p>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
</html>
|
42
site/content/templates/edit-form.html
Normal file
42
site/content/templates/edit-form.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="Edit '{{ title }}'"/>
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title>Edit '{{ title }}'</title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="cookie-block" hidden>
|
||||
<p>Please set your token cookie first.</p>
|
||||
<input id="set-token" type="text" name="set-token">
|
||||
<button onclick="setTokenCookie()">Set Token Cookie</button>
|
||||
</div>
|
||||
<button onclick="clearTokenCookie()">Clear Token Cookie</button>
|
||||
|
||||
<form id="submit-form" action="/api/blog/posts/edit/{{ id }}" method=POST>
|
||||
<input class="token" type="text" name="token" hidden>
|
||||
<label for="title">Title</label>
|
||||
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
||||
<br>
|
||||
<label for="submit-body">Content</label>
|
||||
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
||||
<br>
|
||||
<button id="submit-button" type="submit">Edit post</button>
|
||||
</form>
|
||||
|
||||
<form action="/api/blog/posts/hide/{{ id }}" method="POST">
|
||||
<input class="token" type="text" name="token" hidden>
|
||||
<button type="submit">Hide post</button>
|
||||
</form>
|
||||
<form action="/api/blog/posts/delete/{{ id }}" method="POST">
|
||||
<input class="token" type="text" name="token" hidden>
|
||||
<button type="submit">Delete post</button>
|
||||
</form>
|
||||
<script src="/static/js/blog.js"></script>
|
||||
</body>
|
||||
</html>
|
22
site/content/templates/edit.html
Normal file
22
site/content/templates/edit.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="Edit posts..." />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title>Edit posts...</title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }}' blog</a></h1>
|
||||
<h2>Edit posts</h2>
|
||||
<ul style="list-style: none;">
|
||||
{% for post in posts %}
|
||||
<li><a href="/edit/{{ post.id }}">{{ post.title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
33
site/content/templates/submit.html
Normal file
33
site/content/templates/submit.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="Submit post" />
|
||||
<meta property="og:image" content="/static/site-image.png" />
|
||||
|
||||
<title>Submit post</title>
|
||||
<link rel="stylesheet" href="/static/css/blog.css">
|
||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="cookie-block" hidden>
|
||||
<p>Please set your token cookie first.</p>
|
||||
<input id="set-token" type="text" name="set-token">
|
||||
<button onclick="setTokenCookie()">Set Token Cookie</button>
|
||||
</div>
|
||||
<button onclick="clearTokenCookie()">Clear Token Cookie</button>
|
||||
|
||||
<form id="submit-form" action="/api/blog/create" method=POST>
|
||||
<input class="token" type="text" name="token" hidden>
|
||||
<label for="title">Title</label>
|
||||
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
||||
<br>
|
||||
<label for="submit-body">Content</label>
|
||||
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
||||
<br>
|
||||
<button id="submit-button" type="submit">Submit</button>
|
||||
</form>
|
||||
<script src="/static/js/blog.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue