posts and stuff
This commit is contained in:
parent
01d6c3d3cb
commit
774d466dc0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -452,6 +452,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-identity",
|
"actix-identity",
|
||||||
|
"actix-session",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
@ -6,6 +6,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-files = "0.6.6"
|
actix-files = "0.6.6"
|
||||||
actix-identity = "0.8.0"
|
actix-identity = "0.8.0"
|
||||||
|
actix-session = {version = "0.10.1", features = ["cookie-session"]}
|
||||||
actix-web = "4.9.0"
|
actix-web = "4.9.0"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
@ -17,3 +18,5 @@ serde = {version = "1.0.210", features = ["derive"]}
|
|||||||
serde_json = "1.0.128"
|
serde_json = "1.0.128"
|
||||||
tera = "1.20.0"
|
tera = "1.20.0"
|
||||||
toml = "0.8.19"
|
toml = "0.8.19"
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
|
11
posts/newstuff/post.md
Normal file
11
posts/newstuff/post.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
## hey...
|
||||||
|
|
||||||
|
I had like school stuff so I couldn't really work on the website sowwy
|
||||||
|
|
||||||
|
but I did some backend code for a login page so that's exciting and stuff
|
||||||
|
|
||||||
|
thak you
|
||||||
|
|
||||||
|
and also I made some music but I'll show that off in a later post when I figure out an efficient way toinclude something like webamp in posts
|
||||||
|
|
||||||
|
thats alll bah bie :3
|
9
posts/newstuff/post_frontmatter.toml
Normal file
9
posts/newstuff/post_frontmatter.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
title = 'BACK FROM THE DEAD YEAHH'
|
||||||
|
file_name = 'newstuff'
|
||||||
|
description = 'NO UPDATES FOR 3 DAYS??? UNSATISFACTORY'
|
||||||
|
tags = ["Rant"]
|
||||||
|
posted = '2024. oct. 08.'
|
||||||
|
estimated_reading_time = 1
|
||||||
|
author = 'IMK' # feel free to swap with your own name
|
||||||
|
order = 1
|
||||||
|
pinned = false
|
@ -1,7 +1,8 @@
|
|||||||
mod home_handler;
|
mod home_handler;
|
||||||
mod post_handler;
|
mod post_handler;
|
||||||
|
mod user_handler;
|
||||||
|
|
||||||
|
|
||||||
pub use home_handler::index;
|
pub use home_handler::index;
|
||||||
pub use post_handler::post;
|
pub use post_handler::post;
|
||||||
|
pub use user_handler::login;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use std::{fs, io::Error};
|
use std::{fs, io::Error};
|
||||||
use actix_web::{get, web, HttpResponse, Responder, HttpMessage};
|
use actix_web::{get, web, HttpResponse, HttpMessage, Responder, HttpRequest, http::StatusCode};
|
||||||
use actix_identity::{Identity, IdentityMiddleware};
|
use actix_identity::{Identity, IdentityMiddleware};
|
||||||
use actix_session::{config::PresistentSession, storage::CookieSessionStore, SessionMiddleware};
|
|
||||||
|
|
||||||
async fn login(req: HttpRequest) -> impl Responder{
|
pub async fn login(req: HttpRequest) -> impl Responder{
|
||||||
Identity::login(&req.extension(),"user1".to_owned()).unwrap();
|
Identity::login(&req.extensions(),"user1".to_owned()).unwrap();
|
||||||
|
|
||||||
web::Redirect::to("/").using_status_code(StatusCode::FOUND)
|
web::Redirect::to("/").using_status_code(StatusCode::FOUND)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use dotenv::dotenv;
|
|||||||
use actix_files::Files;
|
use actix_files::Files;
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
use actix_identity::{Identity, IdentityMiddleware};
|
use actix_identity::{Identity, IdentityMiddleware};
|
||||||
use actix_session::{config::PresistentSession, storage::CookieSessionStore, SessionMiddleware}
|
use actix_session::{config::PersistentSession, storage::CookieSessionStore, SessionMiddleware};
|
||||||
use actix_web::{dev::Server, web, http::StatusCode, HttpRequest, App, HttpResponse, HttpServer, middleware, cookie::{time::Duration, Key}};
|
use actix_web::{dev::Server, web, http::StatusCode, HttpRequest, App, HttpResponse, HttpServer, middleware, cookie::{time::Duration, Key}};
|
||||||
use tera::Tera;
|
use tera::Tera;
|
||||||
use base64::prelude::*;
|
use base64::prelude::*;
|
||||||
@ -38,15 +38,15 @@ pub fn start_blog(listener: TcpListener) -> Result<Server, std::io::Error>{
|
|||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
.wrap(IdentityMiddleware::default())
|
.wrap(IdentityMiddleware::default())
|
||||||
.wrap(
|
.wrap(
|
||||||
SessionMiddleware::builder(CookieSessionStore::default(), secret_key.clone)
|
SessionMiddleware::builder(CookieSessionStore::default(), secret_key.clone())
|
||||||
.cookie_name("auth".to_owned())
|
.cookie_name("auth".to_owned())
|
||||||
.cookie_secure(false)
|
.cookie_secure(false)
|
||||||
.session_lifecycle(PresistentSession::default().session_ttl(SES_TIME))
|
.session_lifecycle(PersistentSession::default().session_ttl(SES_TIME))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.service(Files::new("/static","static/").use_last_modified(true))
|
.service(Files::new("/static","static/").use_last_modified(true))
|
||||||
.route("/health", web::get().to(HttpResponse::Ok))
|
.route("/health", web::get().to(HttpResponse::Ok))
|
||||||
.route("/login", web::post().to(login))
|
.route("/login", web::post().to(handlers::login))
|
||||||
.service(handlers::index)
|
.service(handlers::index)
|
||||||
.service(handlers::post)
|
.service(handlers::post)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user