This commit is contained in:
Sebastian Hugentobler 2024-05-06 10:55:18 +02:00
parent 5e9f49311e
commit 352d4e0a7a
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
22 changed files with 69 additions and 22 deletions

38
Cargo.lock generated
View File

@ -286,25 +286,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "cops-web"
version = "0.1.0"
dependencies = [
"calibre-db",
"clap",
"once_cell",
"poem",
"rust-embed",
"serde",
"serde_json",
"tera",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"uuid",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
@ -1266,6 +1247,25 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rusty-library"
version = "0.1.0"
dependencies = [
"calibre-db",
"clap",
"once_cell",
"poem",
"rust-embed",
"serde",
"serde_json",
"tera",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"uuid",
]
[[package]]
name = "ryu"
version = "1.0.17"

View File

@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"calibre-db", "cops-web",
"calibre-db", "rusty-library",
]
[workspace.dependencies]

View File

@ -1,5 +1,5 @@
[package]
name = "cops-web"
name = "rusty-library"
version = "0.1.0"
edition = "2021"

View File

@ -0,0 +1,10 @@
use std::sync::Arc;
use poem::{handler, web::Data};
use crate::app_state::AppState;
#[handler]
pub async fn handler(state: Data<&Arc<AppState>>) -> Result<String, poem::Error> {
Ok("authors".to_string())
}

View File

@ -0,0 +1,10 @@
use std::sync::Arc;
use poem::{handler, web::Data};
use crate::app_state::AppState;
#[handler]
pub async fn handler(state: Data<&Arc<AppState>>) -> Result<String, poem::Error> {
Ok("books".to_string())
}

View File

@ -0,0 +1,10 @@
use std::sync::Arc;
use poem::{handler, web::Data};
use crate::app_state::AppState;
#[handler]
pub async fn handler(state: Data<&Arc<AppState>>) -> Result<String, poem::Error> {
Ok("series".to_string())
}

View File

@ -18,10 +18,13 @@ mod data {
pub mod book;
}
mod handlers {
pub mod authors;
pub mod books;
pub mod cover;
pub mod download;
pub mod error;
pub mod recents;
pub mod series;
}
mod templates;
@ -44,6 +47,9 @@ async fn main() -> Result<(), std::io::Error> {
let app = Route::new()
.at("/", get(handlers::recents::handler))
.at("/books", get(handlers::books::handler))
.at("/authors", get(handlers::authors::handler))
.at("/series", get(handlers::series::handler))
.at("/cover/:id", get(handlers::cover::handler))
.at("/book/:id/:format", get(handlers::download::handler))
.nest("/static", EmbeddedFilesEndpoint::<Files>::new())

View File

@ -6,10 +6,21 @@
<meta name="color-scheme" content="light dark" />
<link rel="stylesheet" href="/static/pico.min.css" />
<link rel="stylesheet" href="/static/style.css" />
<title>Hello world!</title>
<title>Rusty Library</title>
</head>
<body>
<main class="container">
<nav>
<ul>
<li><strong>Library</strong></li>
</ul>
<ul>
<li><a href="/">Recent</a></li>
<li><a href="/authors">Authors</a></li>
<li><a href="/books">Books</a></li>
<li><a href="/series">Series</a></li>
</ul>
</nav>
{% block content %}{% endblock content %}
</main>
</body>