Update 2024 #1
11 changed files with 206 additions and 230 deletions
|
@ -26,7 +26,8 @@ article {
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-link {
|
.post-link {
|
||||||
padding-right: 20px;
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-title {
|
.post-title {
|
||||||
|
@ -39,6 +40,12 @@ article {
|
||||||
|
|
||||||
.post-body {
|
.post-body {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
|
margin-left: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-box {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
#submit-form {
|
#submit-form {
|
||||||
|
|
|
@ -1,36 +1,30 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
{% block head %}
|
||||||
<meta charset="UTF-8">
|
{{ super() }}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>Submit post</title>
|
||||||
<meta property="og:title" content="{{ username }}' site'" />
|
<meta property="og:title" content="{{ username }} site" />
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
{% endblock head %}
|
||||||
|
|
||||||
<title>{{ username }}' site</title>
|
{% block content %}
|
||||||
<link rel="stylesheet" href="/static/css/blog.css">
|
<h1>Hi, I'm {{ username }}</h1>
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico" />
|
<p style="text-align: right">
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Hi, I'm {{ username }}</h1>
|
|
||||||
<p style="text-align: right">
|
|
||||||
<a href="/">Back to the blog</a>
|
<a href="/">Back to the blog</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This is my blog.
|
This is my blog.
|
||||||
|
|
||||||
{% if email %}
|
{% if email %}
|
||||||
If you have questions or input for me please send me an E-Mail to <img class="social-icon"
|
If you have questions or input for me please send me an E-Mail to <img class="social-icon"
|
||||||
src="/static/social-icons/mail.png" /> {{ email }}
|
src="/static/social-icons/mail.png" /> {{ email }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
<ul style="list-style: none;">
|
<ul style="list-style: none;">
|
||||||
{% if github_account %}
|
{% if github_account %}
|
||||||
<li><img class="social-icon" src="/static/social-icons/github.ico"><a
|
<li><img class="social-icon" src="/static/social-icons/github.ico"><a href="https://github.com/{{ github_account }}">
|
||||||
href="https://github.com/{{ github_account }}"> {{ github_account }}</a></li>
|
{{ github_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if twitter_account %}
|
{% if twitter_account %}
|
||||||
<li><img class="social-icon" src="/static/social-icons/twitter.ico"><a
|
<li><img class="social-icon" src="/static/social-icons/twitter.ico"><a
|
||||||
|
@ -48,8 +42,6 @@
|
||||||
<li><img class="social-icon" src="/static/social-icons/discord.ico"><a href="https://discord.com/"> {{
|
<li><img class="social-icon" src="/static/social-icons/discord.ico"><a href="https://discord.com/"> {{
|
||||||
discord_account }}</a></li>
|
discord_account }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
{% endblock content %}
|
||||||
|
|
||||||
</html>
|
|
11
site/content/templates/article.html.macro
Normal file
11
site/content/templates/article.html.macro
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% macro article(id, title, body, publish_date) %}
|
||||||
|
<article>
|
||||||
|
<div class="post-content">
|
||||||
|
<a href="/id/{{ id }}" class="post-link">
|
||||||
|
<h2 class="post-title">{{ title }}</h2>
|
||||||
|
</a>
|
||||||
|
<sub class="post-publish-date"> {{ publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
||||||
|
<p class="post-body">{{ body }}</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{% endmacro article %}
|
18
site/content/templates/base.html
Normal file
18
site/content/templates/base.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
{% block head %}
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="/static/css/blog.css">
|
||||||
|
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico" />
|
||||||
|
<meta property="og:image" content="/static/site-image.png" />
|
||||||
|
{% endblock head %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="content">{% block content %}{% endblock content %}</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1,35 +1,25 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
{% import "article.html.macro" as article_macro %}
|
||||||
<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>
|
{% block head %}
|
||||||
<link rel="stylesheet" href="/static/css/blog.css">
|
{{ super() }}
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
<meta property="og:title" content="{{ username }}' blog" />
|
||||||
</head>
|
<meta property="og:description" content="List of all posts" />
|
||||||
|
<meta property="og:image" content="/static/site-image.png" />
|
||||||
|
<title> All posts </title>
|
||||||
|
{% endblock head %}
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }}' blog</a></h1>
|
{% block content %}
|
||||||
<p style="text-align: right">
|
<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="/about">About</a>
|
||||||
<a href="/">Last 5 posts</a>
|
<a href="/">Last 5 posts</a>
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<article>
|
{{ article_macro::article(id=post.id,title=post.title,body=post.body,publish_date=post.publish_date) }}
|
||||||
<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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
|
||||||
</html>
|
{% endblock content %}
|
|
@ -1,35 +1,28 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.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>
|
{% block head %}
|
||||||
<link rel="stylesheet" href="/static/css/blog.css">
|
{{ super() }}
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico"/>
|
<meta property="og:title" content=" {{ post.title }} | {{ username }}' blog" />
|
||||||
</head>
|
<meta property="og:description" content="{{ post.body | striptags }}" />
|
||||||
|
<title> {{ post.title }} | {{ username }}' blog </title>
|
||||||
|
{% endblock head %}
|
||||||
|
|
||||||
<body>
|
{% block content %}
|
||||||
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }}' blog</a></h1>
|
<h1><a href="/" class="post-link" style="text-decoration:none;color:black;">{{ username }} blog</a></h1>
|
||||||
<p style="text-align: right">
|
<p style="text-align: right">
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
<a href="/about">About</a>
|
<a href="/about">About</a>
|
||||||
<a href="/all">All Posts</a>
|
<a href="/all">All Posts</a>
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<article>
|
<article>
|
||||||
<div>
|
|
||||||
<a href="/id/{{ post.id }}" class="post-link">[link]</a>
|
|
||||||
</div>
|
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
|
<a href="/id/{{ post.id }}" class="post-link">
|
||||||
<h2 class="post-title">{{ post.title }}</h2>
|
<h2 class="post-title">{{ post.title }}</h2>
|
||||||
|
</a>
|
||||||
<sub class="post-publish-date"> {{ post.publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
<sub class="post-publish-date"> {{ post.publish_date | date(format="%Y-%m-%d at %H:%M") }}</sub>
|
||||||
<p class="post-body">{{ post.body }}</p>
|
<p class="post-body">{{ post.body }}</p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
{% endblock content %}
|
||||||
</html>
|
|
|
@ -1,38 +1,22 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
{% import "article.html.macro" as article_macro %}
|
||||||
|
|
||||||
<head>
|
{% block head %}
|
||||||
<meta charset="UTF-8">
|
{{ super() }}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta property="og:title" content="{{ username }}' blog" />
|
||||||
<meta property="og:title" content="{{ username }}' blog" />
|
<meta property="og:description" content="Last 5 posts" />
|
||||||
<meta property="og:description" content="Last 5 posts" />
|
<title> {{ username }} blog </title>
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
{% endblock head %}
|
||||||
|
|
||||||
<title> {{ username }}' blog </title>
|
{% block content %}
|
||||||
<link rel="stylesheet" href="/static/css/blog.css">
|
<h1><a href="/" class="post-link">{{ username }} blog</a></h1>
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico" />
|
<p style="text-align: right">
|
||||||
</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="/about">About</a>
|
||||||
<a href="/all">All Posts</a>
|
<a href="/all">All Posts</a>
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<article>
|
{{ article_macro::article(id=post.id,title=post.title,body=post.body,publish_date=post.publish_date) }}
|
||||||
<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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
{% endblock content %}
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,43 +1,32 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
{% block head %}
|
||||||
<meta charset="UTF-8">
|
{{ super() }}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>Edit '{{ title }}'</title>
|
||||||
<meta property="og:title" content="Edit '{{ title }}'" />
|
<meta property="og:title" content="Edit '{{ title }}'" />
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
{% endblock head %}
|
||||||
|
|
||||||
<title>Edit '{{ title }}'</title>
|
{% block content %}
|
||||||
<link rel="stylesheet" href="/static/css/blog.css">
|
<form id="submit-form" action="/api/blog/posts/edit/{{ id }}" method=POST>
|
||||||
<link rel="shortcut icon" type="image/jpg" href="/static/favicon.ico" />
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="cookie-block" hidden>
|
|
||||||
<label for="token">Password</label>
|
<label for="token">Password</label>
|
||||||
</br>
|
<br />
|
||||||
<input id="token" type="password" name="token">
|
<input id="token" type="password" name="token">
|
||||||
</div>
|
<br />
|
||||||
|
|
||||||
<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>
|
<label for="title">Title</label>
|
||||||
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
||||||
<br>
|
<br />
|
||||||
<label for="submit-body">Content</label>
|
<label for="submit-body">Content</label>
|
||||||
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
||||||
<br>
|
<br />
|
||||||
<button id="submit-button" type="submit">Edit post</button>
|
<button id="submit-button" type="submit">Edit post</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="/api/blog/posts/hide/{{ id }}" method="POST">
|
<form action="/api/blog/posts/hide/{{ id }}" method="POST">
|
||||||
<input class="token" type="text" name="token" hidden>
|
<input class="token" type="text" name="token" hidden>
|
||||||
<button type="submit">Hide post</button>
|
<button type="submit">Hide post</button>
|
||||||
</form>
|
</form>
|
||||||
<form action="/api/blog/posts/delete/{{ id }}" method="POST">
|
<form action="/api/blog/posts/delete/{{ id }}" method="POST">
|
||||||
<input class="token" type="text" name="token" hidden>
|
<input class="token" type="text" name="token" hidden>
|
||||||
<button type="submit">Delete post</button>
|
<button type="submit">Delete post</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
{% endblock content %}
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,34 +1,26 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
{% block head %}
|
||||||
<meta charset="UTF-8">
|
{{ super() }}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>Submit post</title>
|
||||||
<meta property="og:title" content="Submit post" />
|
<meta property="og:title" content="Submit post" />
|
||||||
<meta property="og:image" content="/static/site-image.png" />
|
{% endblock head %}
|
||||||
|
|
||||||
<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>
|
{% block content %}
|
||||||
<div id="cookie-block" hidden>
|
<form id="submit-form" action="/api/blog/create" method=POST>
|
||||||
<label for="token">Password</label>
|
|
||||||
<br />
|
|
||||||
<input id="token" type="password" name="token">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form id="submit-form" action="/api/blog/create" method=POST>
|
|
||||||
<input class="token" type="text" name="token" hidden>
|
|
||||||
<label for="title">Title</label>
|
<label for="title">Title</label>
|
||||||
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
<textarea id="submit-title" type="text" name="title">{{ title }}</textarea>
|
||||||
<br>
|
<br />
|
||||||
<label for="submit-body">Content</label>
|
<label for="submit-body">Content</label>
|
||||||
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
<textarea id="submit-body" type="text" name="body">{{ body }}</textarea>
|
||||||
<br>
|
<br />
|
||||||
|
<div class="submit-box">
|
||||||
|
<div>
|
||||||
|
<label for="token">Password</label>
|
||||||
|
<input id="token" type="password" name="token">
|
||||||
|
</div>
|
||||||
<button id="submit-button" type="submit">Submit</button>
|
<button id="submit-button" type="submit">Submit</button>
|
||||||
</form>
|
</div>
|
||||||
</body>
|
</form>
|
||||||
|
{% endblock content %}
|
||||||
</html>
|
|
|
@ -26,7 +26,7 @@ async fn blog_create_post(form: Form<NewPostForm>) -> impl Responder {
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponse::MovedPermanently()
|
HttpResponse::MovedPermanently()
|
||||||
.insert_header(("LOCATION", "/blog"))
|
.insert_header(("LOCATION", "/"))
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ async fn blog_edit_post(post_id: web::Path<String>, form: Form<NewPostForm>) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpResponse::MovedPermanently()
|
return HttpResponse::MovedPermanently()
|
||||||
.insert_header(("LOCATION", "/blog"))
|
.insert_header(("LOCATION", "/"))
|
||||||
.finish();
|
.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ async fn blog_delete_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpResponse::MovedPermanently()
|
return HttpResponse::MovedPermanently()
|
||||||
.insert_header(("LOCATION", "/blog"))
|
.insert_header(("LOCATION", "/"))
|
||||||
.finish();
|
.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ async fn blog_hide_post(post_id: web::Path<String>, form: Form<BlogActionForm>)
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpResponse::MovedPermanently()
|
return HttpResponse::MovedPermanently()
|
||||||
.insert_header(("LOCATION", "/blog"))
|
.insert_header(("LOCATION", "/"))
|
||||||
.finish();
|
.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
Tera::new(format!("{}{}", CONFIG.root_path, "/templates/*").as_str()).unwrap();
|
Tera::new(format!("{}{}", CONFIG.root_path, "/templates/*").as_str()).unwrap();
|
||||||
tera.autoescape_on(vec![".sql"]);
|
tera.autoescape_on(vec![".sql"]);
|
||||||
|
|
||||||
env_logger::Builder::from_env(Env::default().default_filter_or("info"));
|
env_logger::Builder::from_env(Env::default().default_filter_or("debug"));
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(Data::new(tera))
|
.app_data(Data::new(tera))
|
||||||
|
|
Loading…
Reference in a new issue