feat: use rinja instead of axum
This commit is contained in:
parent
4f6c7422f5
commit
88e1cd98f2
8 changed files with 71 additions and 63 deletions
112
Cargo.lock
generated
112
Cargo.lock
generated
|
@ -65,56 +65,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "askama"
|
|
||||||
version = "0.13.0"
|
|
||||||
source = "git+https://github.com/djc/askama.git#a7e108cd76a2a89dfdf0dfb87b1286ec3a523f08"
|
|
||||||
dependencies = [
|
|
||||||
"askama_derive",
|
|
||||||
"askama_escape",
|
|
||||||
"humansize",
|
|
||||||
"num-traits",
|
|
||||||
"percent-encoding",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "askama_axum"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "git+https://github.com/djc/askama.git#a7e108cd76a2a89dfdf0dfb87b1286ec3a523f08"
|
|
||||||
dependencies = [
|
|
||||||
"askama",
|
|
||||||
"axum-core",
|
|
||||||
"http",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "askama_derive"
|
|
||||||
version = "0.13.0"
|
|
||||||
source = "git+https://github.com/djc/askama.git#a7e108cd76a2a89dfdf0dfb87b1286ec3a523f08"
|
|
||||||
dependencies = [
|
|
||||||
"askama_parser",
|
|
||||||
"basic-toml",
|
|
||||||
"mime",
|
|
||||||
"mime_guess",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "askama_escape"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "git+https://github.com/djc/askama.git#a7e108cd76a2a89dfdf0dfb87b1286ec3a523f08"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "askama_parser"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "git+https://github.com/djc/askama.git#a7e108cd76a2a89dfdf0dfb87b1286ec3a523f08"
|
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-bincode"
|
name = "async-bincode"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
|
@ -1344,8 +1294,6 @@ dependencies = [
|
||||||
name = "nyazoom"
|
name = "nyazoom"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
|
||||||
"askama_axum",
|
|
||||||
"async-bincode",
|
"async-bincode",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"async_zip",
|
"async_zip",
|
||||||
|
@ -1358,6 +1306,8 @@ dependencies = [
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"rinja",
|
||||||
|
"rinja_axum",
|
||||||
"sanitize-filename-reader-friendly",
|
"sanitize-filename-reader-friendly",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
@ -1713,6 +1663,58 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rinja"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3dc4940d00595430b3d7d5a01f6222b5e5b51395d1120bdb28d854bb8abb17a5"
|
||||||
|
dependencies = [
|
||||||
|
"humansize",
|
||||||
|
"itoa",
|
||||||
|
"percent-encoding",
|
||||||
|
"rinja_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rinja_axum"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc64d77bb950f6498d0fc64b028d168fcb4e56ac31b66a8ae05f64d3b0c218b6"
|
||||||
|
dependencies = [
|
||||||
|
"axum-core",
|
||||||
|
"http",
|
||||||
|
"rinja",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rinja_derive"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08d9ed0146aef6e2825f1b1515f074510549efba38d71f4554eec32eb36ba18b"
|
||||||
|
dependencies = [
|
||||||
|
"basic-toml",
|
||||||
|
"memchr",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rinja_parser",
|
||||||
|
"rustc-hash",
|
||||||
|
"serde",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rinja_parser"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93f9a866e2e00a7a1fb27e46e9e324a6f7c0e7edc4543cae1d38f4e4a100c610"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"nom",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rsa"
|
name = "rsa"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
|
@ -1739,6 +1741,12 @@ version = "0.1.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.35"
|
version = "0.38.35"
|
||||||
|
|
|
@ -47,9 +47,10 @@ features = ["runtime-tokio", "chrono", "sqlite"]
|
||||||
[profile.dev.package.sqlx-macros]
|
[profile.dev.package.sqlx-macros]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[dependencies.askama]
|
[dependencies.rinja]
|
||||||
git = "https://github.com/djc/askama.git"
|
version = "0.3.5"
|
||||||
features = ["with-axum"]
|
features = ["with-axum"]
|
||||||
|
|
||||||
[dependencies.askama_axum]
|
|
||||||
git = "https://github.com/djc/askama.git"
|
[dependencies.rinja_axum]
|
||||||
|
version = "0.3.5"
|
||||||
|
|
|
@ -7,7 +7,7 @@ use axum::{
|
||||||
};
|
};
|
||||||
use axum_extra::TypedHeader;
|
use axum_extra::TypedHeader;
|
||||||
use tower_http::{services::ServeDir, trace::TraceLayer};
|
use tower_http::{services::ServeDir, trace::TraceLayer};
|
||||||
use views::askama::WelcomeTemplate;
|
use views::templates::WelcomeTemplate;
|
||||||
|
|
||||||
use std::{io, net::SocketAddr};
|
use std::{io, net::SocketAddr};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use axum::{
|
||||||
};
|
};
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
use crate::{askama::DownloadLinkTemplate, AppState, AsyncRemoveRecord};
|
use crate::{templates::DownloadLinkTemplate, AppState, AsyncRemoveRecord};
|
||||||
|
|
||||||
pub fn get_link_router() -> Router<AppState> {
|
pub fn get_link_router() -> Router<AppState> {
|
||||||
// Link pages
|
// Link pages
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use axum::{extract::State, response::IntoResponse, routing::get, Json, Router};
|
use axum::{extract::State, response::IntoResponse, routing::get, Json, Router};
|
||||||
|
|
||||||
use crate::{askama::LinkListTemplate, AppState};
|
use crate::{templates::LinkListTemplate, AppState};
|
||||||
|
|
||||||
pub fn get_records_router() -> Router<AppState> {
|
pub fn get_records_router() -> Router<AppState> {
|
||||||
// Records views
|
// Records views
|
||||||
|
|
|
@ -14,7 +14,7 @@ use tokio::io;
|
||||||
use tokio_util::{compat::FuturesAsyncWriteCompatExt, io::StreamReader};
|
use tokio_util::{compat::FuturesAsyncWriteCompatExt, io::StreamReader};
|
||||||
use tower_http::limit::RequestBodyLimitLayer;
|
use tower_http::limit::RequestBodyLimitLayer;
|
||||||
|
|
||||||
use crate::{askama::DownloadLinkFragment, cache, util, AppState, UploadRecord};
|
use crate::{cache, templates::DownloadLinkFragment, util, AppState, UploadRecord};
|
||||||
|
|
||||||
pub fn get_upload_router() -> Router<AppState> {
|
pub fn get_upload_router() -> Router<AppState> {
|
||||||
// Upload needs a subrouter to increase the body limit
|
// Upload needs a subrouter to increase the body limit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use futures::TryFutureExt;
|
use futures::TryFutureExt;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
pub mod askama;
|
pub mod templates;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct CatFact {
|
pub struct CatFact {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use askama_axum::Template;
|
use rinja_axum::Template;
|
||||||
|
|
||||||
use crate::{link::get_remaining_text, UploadRecord};
|
use crate::{link::get_remaining_text, UploadRecord};
|
||||||
|
|
||||||
|
@ -47,4 +47,3 @@ impl DownloadLinkFragment {
|
||||||
pub struct LinkListTemplate {
|
pub struct LinkListTemplate {
|
||||||
pub record_keys: Vec<String>,
|
pub record_keys: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue