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 %} +

+
+

+

+

+ + + \ No newline at end of file diff --git a/site/content/templates/edit-form.html b/site/content/templates/edit-form.html index 5215c94..34c5c1e 100644 --- a/site/content/templates/edit-form.html +++ b/site/content/templates/edit-form.html @@ -1,42 +1,43 @@ - - - - - - Edit '{{ title }}' - - - - - - + + + + + -
- - - -
- - -
- -
+ Edit '{{ title }}' + + + -
- - -
-
- - -
- - - + + + +
+ + + +
+ + +
+ +
+ +
+ + +
+
+ + +
+ + + \ No newline at end of file diff --git a/site/content/templates/submit.html b/site/content/templates/submit.html index 449c02e..869350a 100644 --- a/site/content/templates/submit.html +++ b/site/content/templates/submit.html @@ -1,33 +1,34 @@ - - - - - - Submit post - - - - - - + + + + + -
- - - -
- - -
- -
- - - + Submit post + + + + + + + +
+ + + +
+ + +
+ +
+ + + \ No newline at end of file diff --git a/site/src/api.rs b/site/src/api.rs index d255582..73d200b 100644 --- a/site/src/api.rs +++ b/site/src/api.rs @@ -31,10 +31,7 @@ async fn blog_create_post(form: Form) -> impl Responder { } #[post("/api/blog/posts/edit/{post_id}")] -async fn blog_edit_post( - post_id: web::Path, - form: Form, -) -> impl Responder { +async fn blog_edit_post(post_id: web::Path, form: Form) -> impl Responder { let (valid, id) = id_valid(post_id.into_inner()); if valid && CONFIG.submit_token == form.token { edit_post_by_id( @@ -73,10 +70,7 @@ async fn blog_delete_post( } #[post("/api/blog/posts/hide/{post_id}")] -async fn blog_hide_post( - post_id: web::Path, - form: Form, -) -> impl Responder { +async fn blog_hide_post(post_id: web::Path, form: Form) -> impl Responder { let (valid, id) = id_valid(post_id.into_inner()); if valid && CONFIG.submit_token == form.token { println!("Hid post: {}", id); diff --git a/site/src/config.rs b/site/src/config.rs index 153b75c..fcdd2b8 100644 --- a/site/src/config.rs +++ b/site/src/config.rs @@ -7,12 +7,12 @@ pub struct Config { pub submit_token: String, pub root_path: String, pub username: String, - pub email: String, pub bind_port: String, pub accounts: Accounts, } pub struct Accounts { + pub email: Option, pub github: Option, pub twitter: Option, pub mastodon: Option, @@ -68,9 +68,9 @@ fn load_config() -> Config { submit_token: eval_conf_var("SUBMIT_TOKEN", true, None).unwrap(), root_path: eval_conf_var("ROOT_PATH", false, Some("./content")).unwrap(), username: eval_conf_var("USERNAME", true, None).unwrap(), - email: eval_conf_var("EMAIL", false, None).unwrap(), bind_port: eval_conf_var("BIND_PORT", false, Some("8000")).unwrap(), accounts: Accounts { + email: eval_conf_var("EMAIL", false, None), github: eval_conf_var("GITHUB_ACCOUNT", false, None), discord: eval_conf_var("DISCORD_ACCOUNT", false, None), twitter: eval_conf_var("TWITTER_ACCOUNT", false, None), diff --git a/site/src/models.rs b/site/src/models.rs deleted file mode 100644 index 507df1f..0000000 --- a/site/src/models.rs +++ /dev/null @@ -1,13 +0,0 @@ -use diesel::prelude::*; -use chrono; - -#[derive(Queryable, Selectable)] -#[diesel(table_name = crate::schema::posts)] -#[diesel(check_for_backend(diesel::pg::Pg))] -pub struct Post { - pub id: i32, - pub title: String, - pub body: String, - pub published: bool, - pub publish_date: chrono::Timestamp -} \ No newline at end of file diff --git a/site/src/routes.rs b/site/src/routes.rs index 0ab7420..8d116fc 100644 --- a/site/src/routes.rs +++ b/site/src/routes.rs @@ -36,31 +36,30 @@ pub fn replace_br_tags(x: &str) -> String { #[get("/about")] async fn about(tmpl: web::Data) -> Result { let mut context = Context::new(); - context.insert( - "username", - &CONFIG.username - ); - context.insert("email", &CONFIG.email); - - match &CONFIG.accounts.github { + context.insert("username", &CONFIG.username); + match &CONFIG.accounts.email { + Some(acc) => context.insert("email", &acc.replace("@", " (at) ")), + None => (), + } + match &CONFIG.accounts.github { Some(acc) => context.insert("github_account", &acc), - None => () + None => (), }; - match &CONFIG.accounts.twitter { + match &CONFIG.accounts.twitter { Some(acc) => context.insert("twitter_account", &acc), - None => () + None => (), }; - match &CONFIG.accounts.mastodon { + match &CONFIG.accounts.mastodon { Some(acc) => context.insert("mastodon_account", &acc), - None => () + None => (), }; - match &CONFIG.accounts.reddit { + match &CONFIG.accounts.reddit { Some(acc) => context.insert("reddit_account", &acc), - None => () + None => (), }; - match &CONFIG.accounts.discord { + match &CONFIG.accounts.discord { Some(acc) => context.insert("discord_account", &acc), - None => () + None => (), }; let result = tmpl @@ -103,8 +102,7 @@ async fn blog_all(tmpl: web::Data) -> Result { #[get("/id/{post_id}")] async fn blog_by_id( tmpl: web::Data, - post_id: web::Path - // web::Path(post_id): web::Path, + post_id: web::Path, // web::Path(post_id): web::Path, ) -> Result { let (valid, id) = id_valid(post_id.into_inner()); if valid { @@ -157,7 +155,7 @@ async fn blog_edit(tmpl: web::Data) -> Result { #[get("/edit/{post_id}")] async fn blog_edit_by_id( tmpl: web::Data, - post_id: web::Path + post_id: web::Path, ) -> Result { let (valid, id) = id_valid(post_id.into_inner()); if valid { diff --git a/site/src/schema.rs b/site/src/schema.rs deleted file mode 100644 index e43c05a..0000000 --- a/site/src/schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -// @generated automatically by Diesel CLI. - -diesel::table! { - posts (id) { - id -> Nullable, - title -> Text, - body -> Text, - published -> Bool, - publish_date -> Timestamp, - } -}