mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Update askama
This commit is contained in:
89
Cargo.lock
generated
89
Cargo.lock
generated
@@ -385,59 +385,44 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.12.1"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
|
||||
checksum = "9a4e46abb203e00ef226442d452769233142bbfdd79c3941e84c8e61c4112543"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"askama_escape",
|
||||
"humansize",
|
||||
"num-traits",
|
||||
"itoa",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_actix"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4b0dd17cfe203b00ba3853a89fba459ecf24c759b738b244133330607c78e55"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"askama",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.12.5"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
|
||||
checksum = "54398906821fd32c728135f7b351f0c7494ab95ae421d41b6f5a020e158f28a6"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"memchr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_escape"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.2.1"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
|
||||
checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1396,15 +1381,6 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
||||
dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.6.0"
|
||||
@@ -1844,12 +1820,6 @@ dependencies = [
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.7"
|
||||
@@ -1877,16 +1847,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e94e1e6445d314f972ff7395df2de295fe51b71821694f0b0e1e79c4f12c8577"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
@@ -2868,7 +2828,6 @@ dependencies = [
|
||||
"actix-session",
|
||||
"actix-web",
|
||||
"askama",
|
||||
"askama_actix",
|
||||
"futures-core",
|
||||
"hex",
|
||||
"mime_guess",
|
||||
@@ -2886,7 +2845,6 @@ dependencies = [
|
||||
"actix-session",
|
||||
"actix-web",
|
||||
"askama",
|
||||
"askama_actix",
|
||||
"chrono",
|
||||
"futures-core",
|
||||
"hex",
|
||||
@@ -3096,19 +3054,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.34+deprecated"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
"unsafe-libyaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
@@ -3901,12 +3846,6 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
|
||||
@@ -73,13 +73,7 @@ derive_more = { version = "2.0", features = [
|
||||
"deref",
|
||||
"constructor",
|
||||
] }
|
||||
askama = { version = "0.12", features = [
|
||||
"serde",
|
||||
"with-actix-web",
|
||||
"serde-json",
|
||||
"serde-yaml",
|
||||
] }
|
||||
askama_actix = "0.14"
|
||||
askama = { version = "0.13", features = ["serde_json"] }
|
||||
sqlx = { version = "0.8", default-features = false, features = [
|
||||
"sqlx-sqlite",
|
||||
"uuid",
|
||||
|
||||
@@ -8,7 +8,6 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
askama.workspace = true
|
||||
askama_actix = { workspace = true }
|
||||
actix-session = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<h1>{{ name }}</h1>
|
||||
{% if let Some(description) = addressbook.description %}<p>{{ description }}</p>{% endif%}
|
||||
|
||||
<pre>{{ addressbook|yaml }}</pre>
|
||||
<pre>{{ addressbook|json }}</pre>
|
||||
|
||||
<a href="/frontend/user/{{ addressbook.principal }}">Back</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<h1>{{ name }}</h1>
|
||||
{% if let Some(description) = calendar.description %}<p>{{ description }}</p>{% endif%}
|
||||
|
||||
<pre>{{ calendar|yaml }}</pre>
|
||||
<pre>{{ calendar|json }}</pre>
|
||||
|
||||
<a href="/frontend/user/{{ calendar.principal }}">Back</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -6,11 +6,10 @@ use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
http::{Method, StatusCode},
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||
web::{self, Data, Path},
|
||||
web::{self, Data, Html, Path},
|
||||
HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use askama::Template;
|
||||
use askama_actix::TemplateToResponse;
|
||||
use assets::{Assets, EmbedService};
|
||||
use routes::{
|
||||
addressbook::{route_addressbook, route_addressbook_restore},
|
||||
@@ -44,6 +43,7 @@ async fn route_user<CS: CalendarStore, AS: AddressbookStore>(
|
||||
cal_store: Data<CS>,
|
||||
addr_store: Data<AS>,
|
||||
user: User,
|
||||
req: HttpRequest,
|
||||
) -> impl Responder {
|
||||
// TODO: Check for authorization
|
||||
let user_id = path.into_inner();
|
||||
@@ -51,14 +51,19 @@ async fn route_user<CS: CalendarStore, AS: AddressbookStore>(
|
||||
return actix_web::HttpResponse::Unauthorized().body("Unauthorized");
|
||||
}
|
||||
|
||||
UserPage {
|
||||
calendars: cal_store.get_calendars(&user.id).await.unwrap(),
|
||||
deleted_calendars: cal_store.get_deleted_calendars(&user.id).await.unwrap(),
|
||||
addressbooks: addr_store.get_addressbooks(&user.id).await.unwrap(),
|
||||
deleted_addressbooks: addr_store.get_deleted_addressbooks(&user.id).await.unwrap(),
|
||||
user_id: user.id,
|
||||
}
|
||||
.to_response()
|
||||
Html::new(
|
||||
UserPage {
|
||||
calendars: cal_store.get_calendars(&user.id).await.unwrap(),
|
||||
deleted_calendars: cal_store.get_deleted_calendars(&user.id).await.unwrap(),
|
||||
addressbooks: addr_store.get_addressbooks(&user.id).await.unwrap(),
|
||||
deleted_addressbooks: addr_store.get_deleted_addressbooks(&user.id).await.unwrap(),
|
||||
user_id: user.id,
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
)
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body()
|
||||
}
|
||||
|
||||
async fn route_root(user: Option<User>, req: HttpRequest) -> impl Responder {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use actix_web::{
|
||||
http::{header, StatusCode},
|
||||
web::{self, Data, Path},
|
||||
web::{self, Data, Html, Path},
|
||||
HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use askama::Template;
|
||||
use askama_actix::TemplateToResponse;
|
||||
use rustical_store::{auth::User, Addressbook, AddressbookStore};
|
||||
|
||||
#[derive(Template)]
|
||||
@@ -17,15 +16,21 @@ pub async fn route_addressbook<AS: AddressbookStore>(
|
||||
path: Path<(String, String)>,
|
||||
store: Data<AS>,
|
||||
user: User,
|
||||
req: HttpRequest,
|
||||
) -> Result<impl Responder, rustical_store::Error> {
|
||||
let (owner, addrbook_id) = path.into_inner();
|
||||
if !user.is_principal(&owner) {
|
||||
return Ok(HttpResponse::Unauthorized().body("Unauthorized"));
|
||||
}
|
||||
Ok(AddressbookPage {
|
||||
addressbook: store.get_addressbook(&owner, &addrbook_id).await?,
|
||||
}
|
||||
.to_response())
|
||||
Ok(Html::new(
|
||||
AddressbookPage {
|
||||
addressbook: store.get_addressbook(&owner, &addrbook_id).await?,
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
)
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body())
|
||||
}
|
||||
|
||||
pub async fn route_addressbook_restore<AS: AddressbookStore>(
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use actix_web::{
|
||||
http::{header, StatusCode},
|
||||
web::{self, Data, Path},
|
||||
web::{self, Data, Html, Path},
|
||||
HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use askama::Template;
|
||||
use askama_actix::TemplateToResponse;
|
||||
use rustical_store::{auth::User, Calendar, CalendarStore};
|
||||
|
||||
#[derive(Template)]
|
||||
@@ -17,15 +16,21 @@ pub async fn route_calendar<C: CalendarStore>(
|
||||
path: Path<(String, String)>,
|
||||
store: Data<C>,
|
||||
user: User,
|
||||
req: HttpRequest,
|
||||
) -> Result<impl Responder, rustical_store::Error> {
|
||||
let (owner, cal_id) = path.into_inner();
|
||||
if !user.is_principal(&owner) {
|
||||
return Ok(HttpResponse::Unauthorized().body("Unauthorized"));
|
||||
}
|
||||
Ok(CalendarPage {
|
||||
calendar: store.get_calendar(&owner, &cal_id).await?,
|
||||
}
|
||||
.to_response())
|
||||
Ok(Html::new(
|
||||
CalendarPage {
|
||||
calendar: store.get_calendar(&owner, &cal_id).await?,
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
)
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body())
|
||||
}
|
||||
|
||||
pub async fn route_calendar_restore<CS: CalendarStore>(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use actix_session::Session;
|
||||
use actix_web::{
|
||||
error::ErrorUnauthorized,
|
||||
web::{Data, Form, Redirect},
|
||||
web::{Data, Form, Html, Redirect},
|
||||
HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use askama::Template;
|
||||
@@ -12,8 +12,10 @@ use serde::Deserialize;
|
||||
#[template(path = "pages/login.html")]
|
||||
struct LoginPage;
|
||||
|
||||
pub async fn route_get_login() -> impl Responder {
|
||||
LoginPage
|
||||
pub async fn route_get_login(req: HttpRequest) -> impl Responder {
|
||||
Html::new(LoginPage.render().unwrap())
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body()
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
||||
@@ -8,7 +8,6 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
askama.workspace = true
|
||||
askama_actix = { workspace = true }
|
||||
actix-session = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use actix_web::{
|
||||
http::header::{self},
|
||||
web::{self, Data, Form, Json, Path, ServiceConfig},
|
||||
web::{self, Data, Form, Html, Json, Path, ServiceConfig},
|
||||
HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use askama::Template;
|
||||
@@ -155,11 +155,16 @@ async fn get_nextcloud_flow(
|
||||
) -> Result<impl Responder, rustical_store::Error> {
|
||||
let flow_id = path.into_inner();
|
||||
if let Some(flow) = state.flows.read().await.get(&flow_id) {
|
||||
Ok(NextcloudLoginPage {
|
||||
username: user.displayname.unwrap_or(user.id),
|
||||
app_name: flow.app_name.to_owned(),
|
||||
}
|
||||
.respond_to(&req))
|
||||
Ok(Html::new(
|
||||
NextcloudLoginPage {
|
||||
username: user.displayname.unwrap_or(user.id),
|
||||
app_name: flow.app_name.to_owned(),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
)
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body())
|
||||
} else {
|
||||
Ok(HttpResponse::NotFound().body("Login flow not found"))
|
||||
}
|
||||
@@ -191,10 +196,15 @@ async fn post_nextcloud_flow(
|
||||
login_name: user.id.to_owned(),
|
||||
app_password: generate_app_token(),
|
||||
});
|
||||
Ok(NextcloudLoginSuccessPage {
|
||||
app_name: flow.app_name.to_owned(),
|
||||
}
|
||||
.respond_to(&req))
|
||||
Ok(Html::new(
|
||||
NextcloudLoginSuccessPage {
|
||||
app_name: flow.app_name.to_owned(),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
)
|
||||
.respond_to(&req)
|
||||
.map_into_boxed_body())
|
||||
} else {
|
||||
Ok(HttpResponse::NotFound().body("Login flow not found"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user