From 7fe997acff192791a856d9f0138577d3ec022257 Mon Sep 17 00:00:00 2001
From: mtrx
Date: Sat, 10 Aug 2024 09:41:01 +0200
Subject: [PATCH] remove cookie token garbage
---
README.md | 20 +++---
site/content/static/css/blog.css | 22 ++++---
site/content/static/css/index.css | 24 -------
site/content/static/js/blog.js | 35 -----------
site/content/templates/about.html | 90 +++++++++++++++------------
site/content/templates/edit-form.html | 75 +++++++++++-----------
site/content/templates/submit.html | 59 +++++++++---------
site/src/api.rs | 10 +--
site/src/config.rs | 4 +-
site/src/models.rs | 13 ----
site/src/routes.rs | 36 +++++------
site/src/schema.rs | 11 ----
12 files changed, 164 insertions(+), 235 deletions(-)
delete mode 100644 site/content/static/css/index.css
delete mode 100644 site/content/static/js/blog.js
delete mode 100644 site/src/models.rs
delete mode 100644 site/src/schema.rs
diff --git a/README.md b/README.md
index b486350..ee6f4fc 100644
--- a/README.md
+++ b/README.md
@@ -29,18 +29,18 @@ All configuration options are defined in .env which should be placed in the path
`.env`
```
-USERNAME=yourusername
-EMAIL=me@mydomain.tld # optional
-BIND_PORT=8000 # optional
-SUBMIT_TOKEN=Submit!123 # required, token needed for submitting
-GITHUB_ACCOUNT=yourusername # optional
-TWITTER_ACCOUNT=yourusername # optional
-MASTODON_ACCOUNT=yourusername@mastodon.social # optional
-REDDIT_ACCOUNT=yourusername # optional
-DISCORD_ACCOUNT=yourusername # optional
+CL_USERNAME=yourusername
+CL_EMAIL=me@mydomain.tld # optional
+CL_BIND_PORT=8000 # optional
+CL_SUBMIT_TOKEN=Submit!123 # required, token needed for submitting
+CL_GITHUB_ACCOUNT=yourusername # optional
+CL_TWITTER_ACCOUNT=yourusername # optional
+CL_MASTODON_ACCOUNT=yourusername@mastodon.social # optional
+CL_REDDIT_ACCOUNT=yourusername # optional
+CL_DISCORD_ACCOUNT=yourusername # optional
# only needed when not using a docker container
-ROOT_PATH=/path/to/template/directory/and/sqliteDB
+CL_ROOT_PATH=/path/to/template/directory/and/sqliteDB
```
## Routes
diff --git a/site/content/static/css/blog.css b/site/content/static/css/blog.css
index 090eab9..d3502ce 100644
--- a/site/content/static/css/blog.css
+++ b/site/content/static/css/blog.css
@@ -10,13 +10,18 @@ html {
padding-left: 20%;
}
-img {
+.social-icon {
+ height: 1rem;
+ width: 1rem;
+}
+
+.post-img {
width: 50%;
padding: 20px 0px 20px 0px;
}
article {
- padding-top: 2em;
+ padding-top: 2rem;
display: flex;
}
@@ -29,20 +34,21 @@ article {
}
.post-publish-date {
- font-size: 0.7em;
+ font-size: 0.7rem;
}
.post-body {
- padding-top: 1em;
+ padding-top: 1rem;
}
#submit-form {
- padding-top: 2em;
+ padding-top: 2rem;
}
-#submit-body, #submit-title {
+#submit-body,
+#submit-title {
width: 100%;
- margin-bottom: 2em;
+ margin-bottom: 2rem;
resize: none;
}
@@ -60,4 +66,4 @@ article {
width: 90%;
padding-left: 5%;
}
-}
+}
\ No newline at end of file
diff --git a/site/content/static/css/index.css b/site/content/static/css/index.css
deleted file mode 100644
index beb14fc..0000000
--- a/site/content/static/css/index.css
+++ /dev/null
@@ -1,24 +0,0 @@
-* {
- 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%;
-}
diff --git a/site/content/static/js/blog.js b/site/content/static/js/blog.js
deleted file mode 100644
index 1d01900..0000000
--- a/site/content/static/js/blog.js
+++ /dev/null
@@ -1,35 +0,0 @@
-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;
-}
diff --git a/site/content/templates/about.html b/site/content/templates/about.html
index b52bc53..7d4d5cf 100644
--- a/site/content/templates/about.html
+++ b/site/content/templates/about.html
@@ -1,43 +1,55 @@
-
-
-
-
-
- {{ username }}' site
-
-
-
+
+
+
+
+
-
- Hi, I'm {{ username }}
-
- Back to the blog
-
-
- This is my blog. If you have questions or input for me please send me an E-Mail to {{ email }}
-
-
-
-
-
-
-
+ {{ username }}' site
+
+
+
+
+
+ Hi, I'm {{ username }}
+
+ Back to the blog
+
+
+ This is my blog.
+
+ {% if email %}
+ If you have questions or input for me please send me an E-Mail to {{ email }}
+ {% endif %}
+
+
+
+
+
+
+
+