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

View file

@ -56,8 +56,8 @@ default-features = false
features = ["emit_event_on_error", "opentelemetry_0_18"]
[dev-dependencies]
ructe = "0.15.0"
ructe = "0.16.0"
[build-dependencies]
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")]
async fn not_found(state: web::Data<State>) -> Result<HttpResponse, StateError> {
rendered(
|cursor| self::templates::not_found(cursor, &state),
|cursor| self::templates::not_found_html(cursor, &state),
HttpResponse::NotFound(),
)
.stateful(&state)
@ -407,7 +407,7 @@ impl ResponseError for StateError {
fn error_response(&self) -> HttpResponse {
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()),
) {
Ok(res) => res,
@ -738,7 +738,7 @@ async fn thumbnail(
#[tracing::instrument(name = "Index")]
async fn index(state: web::Data<State>) -> Result<HttpResponse, StateError> {
rendered(
|cursor| self::templates::index(cursor, &state),
|cursor| self::templates::index_html(cursor, &state),
HttpResponse::Ok(),
)
.stateful(&state)
@ -775,7 +775,13 @@ async fn view_collection(
rendered(
|cursor| {
self::templates::view_collection(cursor, path.collection, &collection, &entries, &state)
self::templates::view_collection_html(
cursor,
path.collection,
&collection,
&entries,
&state,
)
},
HttpResponse::Ok(),
)
@ -801,7 +807,7 @@ async fn edit_collection(
rendered(
|cursor| {
self::templates::edit_collection(
self::templates::edit_collection_html(
cursor,
&collection,
path.collection,
@ -918,7 +924,7 @@ async fn delete_entry(
if !query.confirmed.unwrap_or(false) {
return rendered(
|cursor| {
self::templates::confirm_entry_delete(
self::templates::confirm_entry_delete_html(
cursor,
entry_path.collection,
entry_path.entry,
@ -1010,7 +1016,7 @@ async fn delete_collection(
return rendered(
|cursor| {
self::templates::confirm_delete(
self::templates::confirm_delete_html(
cursor,
path.collection,
&collection,

View file

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

View file

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

View file

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

View file

@ -1,33 +1,33 @@
@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;
@(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?"), {
<meta property="og:url" content="@state.delete_entry_path(collection_id, id, token, false)" />
@: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)" />
}, {
<section>
<article>
<div class="content-group">
<h3>Delete Image</h3>
<article>
<div class="content-group">
<h3>Delete Image</h3>
</div>
<div class="content-group">
<div class="edit-row">
<div class="edit-item">
@:image_html(entry, state)
</div>
<div class="content-group">
<div class="edit-row">
<div class="edit-item">
@:image(entry, state)
</div>
<div class="edit-item">
<p class="delete-confirmation">Are you sure you want to delete this image?</p>
<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 class="edit-item">
<p class="delete-confirmation">Are you sure you want to delete this image?</p>
<div class="button-group button-space">
@:button_link_html("Delete Image", &state.delete_entry_path(collection_id, id, token, true),
ButtonKind::Submit)
@:button_link_html("Cancel", &state.edit_collection_path(collection_id, token), ButtonKind::Outline)
</div>
</div>
</article>
</div>
</div>
</article>
</section>
@:return_home(state)
@:return_home_html(state)
})

View file

@ -1,11 +1,12 @@
@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};
@use uuid::Uuid;
@(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>
}, {
@ -33,11 +34,11 @@ statics::file_upload_js};
</article>
<article class="content-group">
<form method="POST" action="@state.update_collection_path(collection_id, token)">
@:text_input("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area("description", Some("Collection Description"), Some(&collection.description), false)
@:text_input_html("title", Some("Collection Title"), Some(&collection.title), false)
@:text_area_html("description", Some("Collection Description"), Some(&collection.description), false)
<div class="button-group button-space">
@:button("Update Collection", ButtonKind::Submit)
@:button_link("Delete Collection", &state.delete_collection_path(collection_id, token, false),
@:button_html("Update Collection", ButtonKind::Submit)
@:button_link_html("Delete Collection", &state.delete_collection_path(collection_id, token, false),
ButtonKind::Outline)
</div>
</form>
@ -48,37 +49,37 @@ statics::file_upload_js};
<article>
<div class="edit-row">
<div class="edit-item">
@:image(entry, state)
@:image_html(entry, state)
</div>
<div class="edit-item">
<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_area("description", Some("Image Description"), entry.description.as_deref(),
@:text_input_html("title", Some("Image Title"), entry.title.as_deref(), entry.file_parts().is_none())
@:text_area_html("description", Some("Image Description"), entry.description.as_deref(),
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())
<div class="button-group button-space">
@if let Some(upload_id) = entry.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() {
<input type="hidden" name="filename" value="@filename" />
<input type="hidden" name="delete_token" value="@delete_token" />
@:button("Update Image", ButtonKind::Submit)
@:button_link("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
@:button_html("Update Image", ButtonKind::Submit)
@:button_link_html("Delete Image", &state.delete_entry_path(collection_id, *id, token, false),
ButtonKind::Outline)
}
</div>
<div class="button-group button-space">
@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)
}
@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)
}
</div>
@ -100,14 +101,14 @@ statics::file_upload_js};
</div>
<div class="content-group" id="file-input-container">
<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 class="button-group button-space">
@:button("Upload", ButtonKind::Submit)
@:button_html("Upload", ButtonKind::Submit)
</div>
</div>
</form>
</article>
</section>
@:return_home(state)
@:return_home_html(state)
})

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,10 @@
@use crate::{Collection, Entry, State};
@use super::{layout, image, return_home};
@use super::{layout_html, image_html, return_home_html};
@use uuid::Uuid;
@(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: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 {
<li class="content-group even">
<article>
@:image(entry, state)
@:image_html(entry, state)
</article>
</li>
}
</ul>
</section>
@:return_home(state)
@:return_home_html(state)
})