fix
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2024-12-18 20:09:07 +01:00
parent 58a661d0ed
commit 77c54e215c
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 45 additions and 57 deletions

40
Cargo.lock generated
View file

@ -152,7 +152,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]] [[package]]
name = "based" name = "based"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.hydrar.de/jmarya/based#98048ce522db134fe3e863538db6793068085b80" source = "git+https://git.hydrar.de/jmarya/based#86c97cb9770e2290cf47f432c92f87352dc19e1b"
dependencies = [ dependencies = [
"bcrypt", "bcrypt",
"chrono", "chrono",
@ -250,9 +250,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.3" version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -356,9 +356,9 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-deque"
version = "0.8.5" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
dependencies = [ dependencies = [
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
@ -375,18 +375,18 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.3.11" version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.20" version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
@ -864,11 +864,11 @@ dependencies = [
[[package]] [[package]]
name = "home" name = "home"
version = "0.5.9" version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf"
dependencies = [ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -924,9 +924,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.31" version = "0.14.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
@ -1297,9 +1297,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.0" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
dependencies = [ dependencies = [
"adler2", "adler2",
] ]
@ -2013,9 +2013,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.12.1" version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -2771,9 +2771,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.17" version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"

View file

@ -1,14 +1,10 @@
use based::{ use based::{
auth::User, auth::MaybeUser,
page::htmx_link, page::htmx_link,
request::{api::vec_to_api, RequestContext, StringResponse}, request::{api::vec_to_api, RequestContext, StringResponse},
}; };
use maud::html; use maud::html;
use rocket::{ use rocket::{get, State};
get,
http::{ContentType, Status},
State,
};
use serde_json::json; use serde_json::json;
use crate::{library::Library, pages::components::video_element}; use crate::{library::Library, pages::components::video_element};
@ -39,7 +35,7 @@ pub async fn channel_page(
ctx: RequestContext, ctx: RequestContext,
dir: &str, dir: &str,
library: &State<Library>, library: &State<Library>,
user: User, user: MaybeUser,
) -> StringResponse { ) -> StringResponse {
if dir.ends_with(".json") { if dir.ends_with(".json") {
let dir_videos = library let dir_videos = library
@ -59,15 +55,15 @@ pub async fn channel_page(
}; };
); );
render_page(ctx, content, dir, Some(user)).await render_page(ctx, content, dir, user.into()).await
} }
#[get("/")] #[get("/")]
pub async fn index_page( pub async fn index_page(
ctx: RequestContext, ctx: RequestContext,
library: &State<Library>, library: &State<Library>,
user: User, user: MaybeUser,
) -> (Status, (ContentType, String)) { ) -> StringResponse {
let content = html!( let content = html!(
h1 class="text-center text-4xl font-extrabold leading-tight mt-4" { "Random Videos" }; h1 class="text-center text-4xl font-extrabold leading-tight mt-4" { "Random Videos" };
div class="lg:grid grid-cols-3 gap-6 p-6" { div class="lg:grid grid-cols-3 gap-6 p-6" {
@ -84,5 +80,5 @@ pub async fn index_page(
}; };
); );
render_page(ctx, content, "WatchDogs", Some(user)).await render_page(ctx, content, "WatchDogs", user.into()).await
} }

View file

@ -1,3 +1,4 @@
use based::request::StringResponse;
use rocket::http::{ContentType, Status}; use rocket::http::{ContentType, Status};
pub mod assets; pub mod assets;
@ -7,7 +8,7 @@ pub mod user;
pub mod watch; pub mod watch;
pub mod yt; pub mod yt;
pub fn api_response(json: &serde_json::Value) -> (Status, (ContentType, String)) { pub fn api_response(json: &serde_json::Value) -> StringResponse {
( (
Status::Ok, Status::Ok,
(ContentType::JSON, serde_json::to_string(json).unwrap()), (ContentType::JSON, serde_json::to_string(json).unwrap()),

View file

@ -1,19 +1,14 @@
use based::{auth::User, request::RequestContext}; use based::auth::User;
use based::request::StringResponse;
use based::{auth::MaybeUser, request::RequestContext};
use maud::html; use maud::html;
use rocket::http::CookieJar; use rocket::http::CookieJar;
use rocket::{ use rocket::{form::Form, get, http::Cookie, post, response::Redirect, FromForm};
form::Form,
get,
http::{ContentType, Cookie, Status},
post,
response::Redirect,
FromForm,
};
use super::components::render_page; use super::components::render_page;
#[get("/login")] #[get("/login")]
pub async fn login(ctx: RequestContext, user: User) -> (Status, (ContentType, String)) { pub async fn login(ctx: RequestContext, user: MaybeUser) -> StringResponse {
let content = html!( let content = html!(
h2 { "Login" }; h2 { "Login" };
form action="/login" method="POST" { form action="/login" method="POST" {
@ -23,7 +18,7 @@ pub async fn login(ctx: RequestContext, user: User) -> (Status, (ContentType, St
} }
); );
render_page(ctx, content, "Login", Some(user)).await render_page(ctx, content, "Login", user.into()).await
} }
#[derive(FromForm)] #[derive(FromForm)]
@ -33,11 +28,7 @@ pub struct LoginForm {
} }
#[post("/login", data = "<login_form>")] #[post("/login", data = "<login_form>")]
pub async fn login_post( pub async fn login_post(login_form: Form<LoginForm>, cookies: &CookieJar<'_>) -> Option<Redirect> {
login_form: Form<LoginForm>,
user: User,
cookies: &CookieJar<'_>,
) -> Option<Redirect> {
let login_data = login_form.into_inner(); let login_data = login_form.into_inner();
let (session, _) = User::login(&login_data.username, &login_data.password).await?; let (session, _) = User::login(&login_data.username, &login_data.password).await?;

View file

@ -1,10 +1,10 @@
use based::{auth::User, format::format_date, request::RequestContext}; use based::{
use maud::html; auth::MaybeUser,
use rocket::{ format::format_date,
get, request::{RequestContext, StringResponse},
http::{ContentType, Status},
State,
}; };
use maud::html;
use rocket::{get, State};
use crate::{library::Library, pages::components::video_element_wide}; use crate::{library::Library, pages::components::video_element_wide};
@ -15,8 +15,8 @@ pub async fn watch_page(
ctx: RequestContext, ctx: RequestContext,
library: &State<Library>, library: &State<Library>,
v: String, v: String,
user: User, user: MaybeUser,
) -> (Status, (ContentType, String)) { ) -> StringResponse {
let video = if let Some(video) = library.get_video_by_id(&v).await { let video = if let Some(video) = library.get_video_by_id(&v).await {
video video
} else { } else {
@ -66,7 +66,7 @@ pub async fn watch_page(
ctx, ctx,
content, content,
&format!("{} - WatchDogs", video.title), &format!("{} - WatchDogs", video.title),
Some(user), user.into(),
) )
.await .await
} }