Bump ructe

This commit is contained in:
asonix 2023-01-29 13:51:04 -06:00
parent e83f98dbe2
commit 2e7ea3052c
13 changed files with 147 additions and 151 deletions

23
Cargo.lock generated
View file

@ -1239,17 +1239,6 @@ dependencies = [
"minimal-lexical", "minimal-lexical",
] ]
[[package]]
name = "nom_locate"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1e299bf5ea7b212e811e71174c5d1a5d065c4c0ad0c8691ecb1f97e3e66025e"
dependencies = [
"bytecount",
"memchr",
"nom",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.46.0"
@ -1288,6 +1277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"num-bigint",
"num-integer", "num-integer",
"num-traits", "num-traits",
] ]
@ -1751,15 +1741,14 @@ dependencies = [
[[package]] [[package]]
name = "rsass" name = "rsass"
version = "0.26.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "665387d3be91521de331a04cc7118c8c129ffe43c5f4e8a61e78990850046b5a" checksum = "a43695dd28122f6c684273de89796a56a98e02e9694b8ab57b160fdc6e6d69af"
dependencies = [ dependencies = [
"arc-swap", "arc-swap",
"fastrand", "fastrand",
"lazy_static", "lazy_static",
"nom", "nom",
"nom_locate",
"num-bigint", "num-bigint",
"num-integer", "num-integer",
"num-rational", "num-rational",
@ -1769,11 +1758,11 @@ dependencies = [
[[package]] [[package]]
name = "ructe" name = "ructe"
version = "0.15.0" version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85517cd381cf0c34694881d8aaf173107c6af7670e66cec18d7a1a8bfce3b758" checksum = "79c86c1631418815c5947a34be5872806586c65398754ec91cc2df35a8e26ba8"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.0",
"bytecount", "bytecount",
"itertools", "itertools",
"md5", "md5",

View file

@ -56,8 +56,8 @@ default-features = false
features = ["emit_event_on_error", "opentelemetry_0_18"] features = ["emit_event_on_error", "opentelemetry_0_18"]
[dev-dependencies] [dev-dependencies]
ructe = "0.15.0" ructe = "0.16.0"
[build-dependencies] [build-dependencies]
dotenv = "0.15.0" dotenv = "0.15.0"
ructe = { version = "0.15.0", features = ["sass", "mime03"] } ructe = { version = "0.16.0", features = ["sass", "mime03"] }

View file

@ -375,7 +375,7 @@ async fn static_files(filename: web::Path<String>, state: web::Data<State>) -> H
#[tracing::instrument(name = "Not found")] #[tracing::instrument(name = "Not found")]
async fn not_found(state: web::Data<State>) -> Result<HttpResponse, StateError> { async fn not_found(state: web::Data<State>) -> Result<HttpResponse, StateError> {
rendered( rendered(
|cursor| self::templates::not_found(cursor, &state), |cursor| self::templates::not_found_html(cursor, &state),
HttpResponse::NotFound(), HttpResponse::NotFound(),
) )
.stateful(&state) .stateful(&state)
@ -407,7 +407,7 @@ impl ResponseError for StateError {
fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
match rendered( match rendered(
|cursor| self::templates::error(cursor, &self.error.kind.to_string(), &self.state), |cursor| self::templates::error_html(cursor, &self.error.kind.to_string(), &self.state),
HttpResponse::build(self.status_code()), HttpResponse::build(self.status_code()),
) { ) {
Ok(res) => res, Ok(res) => res,
@ -738,7 +738,7 @@ async fn thumbnail(
#[tracing::instrument(name = "Index")] #[tracing::instrument(name = "Index")]
async fn index(state: web::Data<State>) -> Result<HttpResponse, StateError> { async fn index(state: web::Data<State>) -> Result<HttpResponse, StateError> {
rendered( rendered(
|cursor| self::templates::index(cursor, &state), |cursor| self::templates::index_html(cursor, &state),
HttpResponse::Ok(), HttpResponse::Ok(),
) )
.stateful(&state) .stateful(&state)
@ -775,7 +775,13 @@ async fn view_collection(
rendered( rendered(
|cursor| { |cursor| {
self::templates::view_collection(cursor, path.collection, &collection, &entries, &state) self::templates::view_collection_html(
cursor,
path.collection,
&collection,
&entries,
&state,
)
}, },
HttpResponse::Ok(), HttpResponse::Ok(),
) )
@ -801,7 +807,7 @@ async fn edit_collection(
rendered( rendered(
|cursor| { |cursor| {
self::templates::edit_collection( self::templates::edit_collection_html(
cursor, cursor,
&collection, &collection,
path.collection, path.collection,
@ -918,7 +924,7 @@ async fn delete_entry(
if !query.confirmed.unwrap_or(false) { if !query.confirmed.unwrap_or(false) {
return rendered( return rendered(
|cursor| { |cursor| {
self::templates::confirm_entry_delete( self::templates::confirm_entry_delete_html(
cursor, cursor,
entry_path.collection, entry_path.collection,
entry_path.entry, entry_path.entry,
@ -1010,7 +1016,7 @@ async fn delete_collection(
return rendered( return rendered(
|cursor| { |cursor| {
self::templates::confirm_delete( self::templates::confirm_delete_html(
cursor, cursor,
path.collection, path.collection,
&collection, &collection,

View file

@ -3,22 +3,22 @@
@(text: &str, kind: ButtonKind) @(text: &str, kind: ButtonKind)
@match kind { @match kind {
ButtonKind::Submit => { ButtonKind::Submit => {
<div class="button submit"> <div class="button submit">
<span>@text</span> <span>@text</span>
<button class="action" type="submit">@text</button> <button class="action" type="submit">@text</button>
</div> </div>
} }
ButtonKind::Plain => { ButtonKind::Plain => {
<div class="button plain"> <div class="button plain">
<span>@text</span> <span>@text</span>
<button class="action">@text</button> <button class="action">@text</button>
</div> </div>
} }
ButtonKind::Outline => { ButtonKind::Outline => {
<div class="button outline"> <div class="button outline">
<span>@text</span> <span>@text</span>
<button class="action">@text</button> <button class="action">@text</button>
</div> </div>
} }
} }

View file

@ -3,23 +3,22 @@
@(text: &str, href: &str, kind: ButtonKind) @(text: &str, href: &str, kind: ButtonKind)
@match kind { @match kind {
ButtonKind::Submit => { ButtonKind::Submit => {
<div class="button submit"> <div class="button submit">
<span>@text</span> <span>@text</span>
<a class="action" href="@href">@text</a> <a class="action" href="@href">@text</a>
</div> </div>
} }
ButtonKind::Plain => { ButtonKind::Plain => {
<div class="button plain"> <div class="button plain">
<span>@text</span> <span>@text</span>
<a class="action" href="@href">@text</a> <a class="action" href="@href">@text</a>
</div> </div>
} }
ButtonKind::Outline => { ButtonKind::Outline => {
<div class="button outline"> <div class="button outline">
<span>@text</span> <span>@text</span>
<a class="action" href="@href">@text</a> <a class="action" href="@href">@text</a>
</div> </div>
} }
} }

View file

@ -1,27 +1,28 @@
@use crate::{ui::ButtonKind, Collection, State, ValidToken}; @use crate::{ui::ButtonKind, Collection, State, ValidToken};
@use super::{layout, button_link, return_home}; @use super::{layout_html, button_link_html, return_home_html};
@use uuid::Uuid; @use uuid::Uuid;
@(id: Uuid, collection: &Collection, token: &ValidToken, state: &State) @(id: Uuid, collection: &Collection, token: &ValidToken, state: &State)
@:layout(state, &format!("Delete: {}", collection.title), Some(&format!("Are you sure you want to delete {}", collection.title)), { @:layout_html(state, &format!("Delete: {}", collection.title), Some(&format!("Are you sure you want to delete {}",
<meta property="og:url" content="@state.delete_collection_path(id, token, false)" /> collection.title)), {
<meta property="og:url" content="@state.delete_collection_path(id, token, false)" />
}, { }, {
<section> <section>
<article> <article>
<div class="content-group"> <div class="content-group">
<h3>Delete @collection.title</h3> <h3>Delete @collection.title</h3>
</div> </div>
<div class="content-group"> <div class="content-group">
<p class="subtitle">Are you sure you want to delete @collection.title</p> <p class="subtitle">Are you sure you want to delete @collection.title</p>
</div> </div>
<div class="content-group"> <div class="content-group">
<div class="button-group"> <div class="button-group">
@:button_link("Delete Collection", &state.delete_collection_path(id, token, true), ButtonKind::Submit) @:button_link_html("Delete Collection", &state.delete_collection_path(id, token, true), ButtonKind::Submit)
@:button_link("Cancel", &state.edit_collection_path(id, token), ButtonKind::Outline) @:button_link_html("Cancel", &state.edit_collection_path(id, token), ButtonKind::Outline)
</div> </div>
</div> </div>
</article> </article>
</section> </section>
@:return_home(state) @:return_home_html(state)
}) })

View file

@ -1,33 +1,33 @@
@use crate::{ui::ButtonKind, Entry, State, ValidToken}; @use crate::{ui::ButtonKind, Entry, State, ValidToken};
@use super::{layout, button_link, image, return_home}; @use super::{layout_html, button_link_html, image_html, return_home_html};
@use uuid::Uuid; @use uuid::Uuid;
@(collection_id: Uuid, id: Uuid, entry: &Entry, token: &ValidToken, state: &State) @(collection_id: Uuid, id: Uuid, entry: &Entry, token: &ValidToken, state: &State)
@:layout(state, "Delete Image", Some("Are you sure you want to delete this image?"), { @:layout_html(state, "Delete Image", Some("Are you sure you want to delete this image?"), {
<meta property="og:url" content="@state.delete_entry_path(collection_id, id, token, false)" /> <meta property="og:url" content="@state.delete_entry_path(collection_id, id, token, false)" />
}, { }, {
<section> <section>
<article> <article>
<div class="content-group"> <div class="content-group">
<h3>Delete Image</h3> <h3>Delete Image</h3>
</div>
<div class="content-group">
<div class="edit-row">
<div class="edit-item">
@:image_html(entry, state)
</div> </div>
<div class="content-group"> <div class="edit-item">
<div class="edit-row"> <p class="delete-confirmation">Are you sure you want to delete this image?</p>
<div class="edit-item"> <div class="button-group button-space">
@:image(entry, state) @:button_link_html("Delete Image", &state.delete_entry_path(collection_id, id, token, true),
</div> ButtonKind::Submit)
<div class="edit-item"> @:button_link_html("Cancel", &state.edit_collection_path(collection_id, token), ButtonKind::Outline)
<p class="delete-confirmation">Are you sure you want to delete this image?</p> </div>
<div class="button-group button-space">
@:button_link("Delete Image", &state.delete_entry_path(collection_id, id, token, true), ButtonKind::Submit)
@:button_link("Cancel", &state.edit_collection_path(collection_id, token), ButtonKind::Outline)
</div>
</div>
</div>
</div> </div>
</article> </div>
</div>
</article>
</section> </section>
@:return_home(state) @:return_home_html(state)
}) })

View file

@ -1,11 +1,12 @@
@use crate::{ui::ButtonKind, Collection, Direction, Entry, State, ValidToken}; @use crate::{ui::ButtonKind, Collection, Direction, Entry, State, ValidToken};
@use super::{button, button_link, image, file_input, layout, return_home, text_area, text_input, @use super::{button_html, button_link_html, image_html, file_input_html, layout_html, return_home_html, text_area_html,
text_input_html,
statics::file_upload_js}; statics::file_upload_js};
@use uuid::Uuid; @use uuid::Uuid;
@(collection: &Collection, collection_id: Uuid, entries: &[(Uuid, Entry)], token: &ValidToken, state: &State, qr: &str) @(collection: &Collection, collection_id: Uuid, entries: &[(Uuid, Entry)], token: &ValidToken, state: &State, qr: &str)
@:layout(state, "Edit Collection", None, { @:layout_html(state, "Edit Collection", None, {
<script src="@state.statics_path(file_upload_js.name)" type="text/javascript"> <script src="@state.statics_path(file_upload_js.name)" type="text/javascript">
</script> </script>
}, { }, {
@ -33,11 +34,11 @@ statics::file_upload_js};
</article> </article>
<article class="content-group"> <article class="content-group">
<form method="POST" action="@state.update_collection_path(collection_id, token)"> <form method="POST" action="@state.update_collection_path(collection_id, token)">
@:text_input("title", Some("Collection Title"), Some(&collection.title), false) @:text_input_html("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area("description", Some("Collection Description"), Some(&collection.description), false) @:text_area_html("description", Some("Collection Description"), Some(&collection.description), false)
<div class="button-group button-space"> <div class="button-group button-space">
@:button("Update Collection", ButtonKind::Submit) @:button_html("Update Collection", ButtonKind::Submit)
@:button_link("Delete Collection", &state.delete_collection_path(collection_id, token, false), @:button_link_html("Delete Collection", &state.delete_collection_path(collection_id, token, false),
ButtonKind::Outline) ButtonKind::Outline)
</div> </div>
</form> </form>
@ -48,37 +49,37 @@ statics::file_upload_js};
<article> <article>
<div class="edit-row"> <div class="edit-row">
<div class="edit-item"> <div class="edit-item">
@:image(entry, state) @:image_html(entry, state)
</div> </div>
<div class="edit-item"> <div class="edit-item">
<form method="POST" action="@state.update_entry_path(collection_id, *id, token)"> <form method="POST" action="@state.update_entry_path(collection_id, *id, token)">
@:text_input("title", Some("Image Title"), entry.title.as_deref(), entry.file_parts().is_none()) @:text_input_html("title", Some("Image Title"), entry.title.as_deref(), entry.file_parts().is_none())
@:text_area("description", Some("Image Description"), entry.description.as_deref(), @:text_area_html("description", Some("Image Description"), entry.description.as_deref(),
entry.file_parts().is_none()) entry.file_parts().is_none())
@:text_input("link", Some("Image Link"), entry.link.as_ref().map(|l| l.as_str()), @:text_input_html("link", Some("Image Link"), entry.link.as_ref().map(|l| l.as_str()),
entry.file_parts().is_none()) entry.file_parts().is_none())
<div class="button-group button-space"> <div class="button-group button-space">
@if let Some(upload_id) = entry.upload_id() { @if let Some(upload_id) = entry.upload_id() {
<input type="hidden" name="upload_id" value="@upload_id" /> <input type="hidden" name="upload_id" value="@upload_id" />
@:button_link("Refresh", &state.edit_collection_path(collection_id, token), ButtonKind::Submit) @:button_link_html("Refresh", &state.edit_collection_path(collection_id, token), ButtonKind::Submit)
} }
@if let Some((filename, delete_token)) = entry.file_parts() { @if let Some((filename, delete_token)) = entry.file_parts() {
<input type="hidden" name="filename" value="@filename" /> <input type="hidden" name="filename" value="@filename" />
<input type="hidden" name="delete_token" value="@delete_token" /> <input type="hidden" name="delete_token" value="@delete_token" />
@:button("Update Image", ButtonKind::Submit) @:button_html("Update Image", ButtonKind::Submit)
@:button_link("Delete Image", &state.delete_entry_path(collection_id, *id, token, false), @:button_link_html("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
ButtonKind::Outline) ButtonKind::Outline)
} }
</div> </div>
<div class="button-group button-space"> <div class="button-group button-space">
@if i != 0 { @if i != 0 {
@:button_link("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up), @:button_link_html("Move Up", &state.move_entry_path(collection_id, *id, token, Direction::Up),
ButtonKind::Outline) ButtonKind::Outline)
} }
@if (i + 1) != entries.len() { @if (i + 1) != entries.len() {
@:button_link("Move Down", &state.move_entry_path(collection_id, *id, token, Direction::Down), @:button_link_html("Move Down", &state.move_entry_path(collection_id, *id, token, Direction::Down),
ButtonKind::Outline) ButtonKind::Outline)
} }
</div> </div>
@ -100,14 +101,14 @@ statics::file_upload_js};
</div> </div>
<div class="content-group" id="file-input-container"> <div class="content-group" id="file-input-container">
<div class="button-group"> <div class="button-group">
@:file_input("images[]", Some("Select Image"), Some(crate::accept()), false) @:file_input_html("images[]", Some("Select Image"), Some(crate::accept()), false)
</div> </div>
<div class="button-group button-space"> <div class="button-group button-space">
@:button("Upload", ButtonKind::Submit) @:button_html("Upload", ButtonKind::Submit)
</div> </div>
</div> </div>
</form> </form>
</article> </article>
</section> </section>
@:return_home(state) @:return_home_html(state)
}) })

View file

@ -1,18 +1,18 @@
@use crate::State; @use crate::State;
@use super::{layout, return_home}; @use super::{layout_html, return_home_html};
@(error: &str, state: &State) @(error: &str, state: &State)
@:layout(state, "Error", Some(error), {}, { @:layout_html(state, "Error", Some(error), {}, {
<section> <section>
<article> <article>
<div class="content-group"> <div class="content-group">
<h3>Error</h3> <h3>Error</h3>
</div> </div>
<div class="content-group"> <div class="content-group">
<p class="subtitle">@error</p> <p class="subtitle">@error</p>
</div> </div>
</article> </article>
</section> </section>
@:return_home(state) @:return_home_html(state)
}) })

View file

@ -1,9 +1,9 @@
@use crate::{Entry, State}; @use crate::{Entry, State};
@use super::image_preview; @use super::image_preview_html;
@(entry: &Entry, state: &State) @(entry: &Entry, state: &State)
@:image_preview(entry, state) @:image_preview_html(entry, state)
<div class="image-meta"> <div class="image-meta">
@if let Some(title) = entry.title.as_ref() { @if let Some(title) = entry.title.as_ref() {
<div class="image-title">@title</div> <div class="image-title">@title</div>

View file

@ -1,9 +1,9 @@
@use crate::{ui::ButtonKind, State}; @use crate::{ui::ButtonKind, State};
@use super::{layout, text_area, text_input, button}; @use super::{layout_html, text_area_html, text_input_html, button_html};
@(state: &State) @(state: &State)
@:layout(state, "Collection", None, {}, { @:layout_html(state, "Collection", None, {}, {
<section> <section>
<article> <article>
<form method="POST" action="@state.create_collection_path()"> <form method="POST" action="@state.create_collection_path()">
@ -13,12 +13,12 @@
</h3> </h3>
</div> </div>
<div class="content-group"> <div class="content-group">
@:text_input("title", Some("Title"), None, false) @:text_input_html("title", Some("Title"), None, false)
@:text_area("description", Some("Description"), None, false) @:text_area_html("description", Some("Description"), None, false)
</div> </div>
<div class="content-group"> <div class="content-group">
<div class="button-group"> <div class="button-group">
@:button("Create Collection", ButtonKind::Submit) @:button_html("Create Collection", ButtonKind::Submit)
</div> </div>
</div> </div>
</form> </form>

View file

@ -1,15 +1,15 @@
@use crate::State; @use crate::State;
@use super::layout; @use super::layout_html;
@(state: &State) @(state: &State)
@:layout(state, "Not Found", None, {}, { @:layout_html(state, "Not Found", None, {}, {
<section> <section>
<article class="content-group"> <article class="content-group">
<h3>Not Found</h3> <h3>Not Found</h3>
</article> </article>
<article class="content-group"> <article class="content-group">
<p><a href="@state.create_collection_path()">Return Home</a></p> <p><a href="@state.create_collection_path()">Return Home</a></p>
</article> </article>
</section> </section>
}) })

View file

@ -1,10 +1,10 @@
@use crate::{Collection, Entry, State}; @use crate::{Collection, Entry, State};
@use super::{layout, image, return_home}; @use super::{layout_html, image_html, return_home_html};
@use uuid::Uuid; @use uuid::Uuid;
@(id: Uuid, collection: &Collection, entries: &[(Uuid, Entry)], state: &State) @(id: Uuid, collection: &Collection, entries: &[(Uuid, Entry)], state: &State)
@:layout(state, &collection.title, Some(&collection.description), { @:layout_html(state, &collection.title, Some(&collection.description), {
<meta property="twitter:card" content="summary_large_image" /> <meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="@state.public_collection_path(id)" /> <meta property="twitter:url" content="@state.public_collection_path(id)" />
<meta property="og:url" content="@state.public_collection_path(id)" /> <meta property="og:url" content="@state.public_collection_path(id)" />
@ -31,11 +31,11 @@
@for (_, entry) in entries { @for (_, entry) in entries {
<li class="content-group even"> <li class="content-group even">
<article> <article>
@:image(entry, state) @:image_html(entry, state)
</article> </article>
</li> </li>
} }
</ul> </ul>
</section> </section>
@:return_home(state) @:return_home_html(state)
}) })