Compare commits

..

2 commits

Author SHA1 Message Date
88e1cd98f2 feat: use rinja instead of axum 2024-11-20 07:30:16 -08:00
4f6c7422f5 feat: sqlx offline mode 2024-11-20 06:01:33 -08:00
9 changed files with 83 additions and 63 deletions

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT INTO records (cache_name, max_downloads)\nVALUES (?, ?);\n",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "dcad7587b9bd5d84025db4e22c90d2ba0210edeaff5235a877e92235384f2c57"
}

112
Cargo.lock generated
View file

@ -65,56 +65,6 @@ dependencies = [
"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]]
name = "async-bincode"
version = "0.7.2"
@ -1344,8 +1294,6 @@ dependencies = [
name = "nyazoom"
version = "0.1.0"
dependencies = [
"askama",
"askama_axum",
"async-bincode",
"async-trait",
"async_zip",
@ -1358,6 +1306,8 @@ dependencies = [
"http-body-util",
"rand",
"reqwest",
"rinja",
"rinja_axum",
"sanitize-filename-reader-friendly",
"serde",
"serde_derive",
@ -1713,6 +1663,58 @@ dependencies = [
"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]]
name = "rsa"
version = "0.9.6"
@ -1739,6 +1741,12 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
name = "rustix"
version = "0.38.35"

View file

@ -47,9 +47,10 @@ features = ["runtime-tokio", "chrono", "sqlite"]
[profile.dev.package.sqlx-macros]
opt-level = 3
[dependencies.askama]
git = "https://github.com/djc/askama.git"
[dependencies.rinja]
version = "0.3.5"
features = ["with-axum"]
[dependencies.askama_axum]
git = "https://github.com/djc/askama.git"
[dependencies.rinja_axum]
version = "0.3.5"

View file

@ -7,7 +7,7 @@ use axum::{
};
use axum_extra::TypedHeader;
use tower_http::{services::ServeDir, trace::TraceLayer};
use views::askama::WelcomeTemplate;
use views::templates::WelcomeTemplate;
use std::{io, net::SocketAddr};

View file

@ -6,7 +6,7 @@ use axum::{
};
use reqwest::StatusCode;
use crate::{askama::DownloadLinkTemplate, AppState, AsyncRemoveRecord};
use crate::{templates::DownloadLinkTemplate, AppState, AsyncRemoveRecord};
pub fn get_link_router() -> Router<AppState> {
// Link pages

View file

@ -1,6 +1,6 @@
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> {
// Records views

View file

@ -14,7 +14,7 @@ use tokio::io;
use tokio_util::{compat::FuturesAsyncWriteCompatExt, io::StreamReader};
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> {
// Upload needs a subrouter to increase the body limit

View file

@ -1,7 +1,7 @@
use futures::TryFutureExt;
use serde::Deserialize;
pub mod askama;
pub mod templates;
#[derive(Debug, Deserialize)]
pub struct CatFact {

View file

@ -1,4 +1,4 @@
use askama_axum::Template;
use rinja_axum::Template;
use crate::{link::get_remaining_text, UploadRecord};
@ -47,4 +47,3 @@ impl DownloadLinkFragment {
pub struct LinkListTemplate {
pub record_keys: Vec<String>,
}