implement user pages + ui
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2025-01-12 03:58:16 +01:00
parent 67c31725c1
commit 3fabc91438
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
11 changed files with 1021 additions and 264 deletions

View file

@ -1,40 +1,9 @@
// TODO :
// - Base
// - API
// - UI
// - PkgDB Abstraction
// - Pkg Abstraction
use based::auth::User;
use based::get_pg;
use based::page::{Shell, render_page};
use based::request::{RequestContext, StringResponse};
use maud::html;
use pacco::pkg::Repository;
use rocket::get;
use rocket::routes;
pub mod routes;
#[get("/")]
pub async fn index_page(ctx: RequestContext) -> StringResponse {
let repos: Vec<String> = Repository::list();
let content = html!(
h1 { "Repositories" };
@for repo in repos {
p { (repo) };
};
);
render_page(
content,
"Repositories",
ctx,
&Shell::new(html! {}, html! {}, Some(String::new())),
)
.await
}
#[rocket::launch]
async fn launch() -> _ {
env_logger::init();
@ -42,9 +11,21 @@ async fn launch() -> _ {
let pg = get_pg!();
sqlx::migrate!("./migrations").run(pg).await.unwrap();
let _ = User::create("admin".to_string(), "admin", based::auth::UserRole::Admin).await;
rocket::build().mount("/", routes![
index_page,
based::htmx::htmx_script_route,
routes::index_page,
routes::pkg_route,
routes::upload_pkg
routes::push::upload_pkg,
routes::user::login,
routes::user::login_post,
routes::user::account_page,
routes::ui::pkg_ui,
routes::ui::repo_ui,
routes::user::new_api_key,
routes::user::end_session,
routes::user::change_password,
routes::user::change_password_post
])
}