formatting
This commit is contained in:
parent
391f9cfa01
commit
31bfd4d126
5 changed files with 61 additions and 18 deletions
1
.rustfmt.toml
Normal file
1
.rustfmt.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
edition = "2021"
|
2
leptosfmt.toml
Normal file
2
leptosfmt.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[attr_values]
|
||||||
|
class = "Tailwind" # "Tailwind" is the only attribute value formatter available for now
|
2
rust-analyzer.toml
Normal file
2
rust-analyzer.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[rustfmt]
|
||||||
|
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]
|
22
src/main.rs
22
src/main.rs
|
@ -137,9 +137,7 @@ async fn remaining(
|
||||||
async fn welcome() -> impl IntoResponse {
|
async fn welcome() -> impl IntoResponse {
|
||||||
let cat_fact = views::get_cat_fact().await;
|
let cat_fact = views::get_cat_fact().await;
|
||||||
Html(ssr::render(move || {
|
Html(ssr::render(move || {
|
||||||
leptos::view! {
|
leptos::view! { <Welcome fact=cat_fact /> }
|
||||||
<Welcome fact=cat_fact />
|
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,15 +155,23 @@ async fn records_links(State(state): State<AppState>) -> impl IntoResponse {
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<div class="column-container">
|
<div class="column-container">
|
||||||
<ul>
|
<ul>
|
||||||
{records.keys().map(|key| leptos::view! {
|
{records
|
||||||
|
.keys()
|
||||||
|
.map(|key| {
|
||||||
|
leptos::view! {
|
||||||
<li class="link-wrapper">
|
<li class="link-wrapper">
|
||||||
<a href="/link/{key}">{key}</a>
|
<a href="/link/{key}">{key}</a>
|
||||||
<button style="margin-left: 1em;"
|
<button
|
||||||
|
style="margin-left: 1em;"
|
||||||
hx-target="closest .link-wrapper"
|
hx-target="closest .link-wrapper"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-delete="/link/{key}">X</button>
|
hx-delete="/link/{key}"
|
||||||
|
>
|
||||||
|
X
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
})
|
}
|
||||||
|
})
|
||||||
.collect::<Vec<_>>()}
|
.collect::<Vec<_>>()}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -190,7 +196,7 @@ async fn link(
|
||||||
return Ok(Html(ssr::render({
|
return Ok(Html(ssr::render({
|
||||||
let record = record.clone();
|
let record = record.clone();
|
||||||
|| {
|
|| {
|
||||||
leptos::view! { <DownloadLinkPage id=id record=record /> }
|
leptos::view! { <DownloadLinkPage id=id record=record /> }
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
52
src/views.rs
52
src/views.rs
|
@ -33,11 +33,26 @@ pub fn Welcome(fact: String) -> impl IntoView {
|
||||||
#[component]
|
#[component]
|
||||||
pub fn WelcomeView(fact: String) -> impl IntoView {
|
pub fn WelcomeView(fact: String) -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<form id="form" hx-swap="outerHTML" hx-post="/upload" hx-encoding="multipart/form-data" class="column-container">
|
<form
|
||||||
|
id="form"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-post="/upload"
|
||||||
|
hx-encoding="multipart/form-data"
|
||||||
|
class="column-container"
|
||||||
|
>
|
||||||
<div class="cat-img-wrapper">
|
<div class="cat-img-wrapper">
|
||||||
<img class="cat-img" src="https://api.thecatapi.com/v1/images/search?size=small&format=src" />
|
<img
|
||||||
|
class="cat-img"
|
||||||
|
src="https://api.thecatapi.com/v1/images/search?size=small&format=src"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<input type="file" id="file" name="file" data-multiple-caption="{{count}} files selected" multiple />
|
<input
|
||||||
|
type="file"
|
||||||
|
id="file"
|
||||||
|
name="file"
|
||||||
|
data-multiple-caption="{{count}} files selected"
|
||||||
|
multiple
|
||||||
|
/>
|
||||||
<label for="file">Select Files</label>
|
<label for="file">Select Files</label>
|
||||||
|
|
||||||
<input type="submit" value="Get Link~" />
|
<input type="submit" value="Get Link~" />
|
||||||
|
@ -72,7 +87,11 @@ pub fn HtmxPage(children: Children) -> impl IntoView {
|
||||||
<link href="/css/link.css" rel="stylesheet" />
|
<link href="/css/link.css" rel="stylesheet" />
|
||||||
<script src="/scripts/file_label.js" />
|
<script src="/scripts/file_label.js" />
|
||||||
<script src="/scripts/link.js" />
|
<script src="/scripts/link.js" />
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.4" integrity="sha384-zUfuhFKKZCbHTY6aRR46gxiqszMk5tcHjsVFxnUo8VMus4kHGVdIYVbOYYNlKmHV" crossorigin="anonymous"></script>
|
<script
|
||||||
|
src="https://unpkg.com/htmx.org@1.9.4"
|
||||||
|
integrity="sha384-zUfuhFKKZCbHTY6aRR46gxiqszMk5tcHjsVFxnUo8VMus4kHGVdIYVbOYYNlKmHV"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -89,16 +108,29 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<div class="column-container">
|
<div class="column-container">
|
||||||
<div class="link-wrapper">
|
<div class="link-wrapper">
|
||||||
<a id="link" href="/download/{id}">Download Now!</a>
|
<a id="link" href="/download/{id}">
|
||||||
|
Download Now!
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="link-wrapper" hx-get="/link/{id}/remaining" hx-trigger="click from:#link delay:0.2s, every 10s" >
|
<div
|
||||||
You have {record.downloads_remaining()} download{plural} remaining!
|
class="link-wrapper"
|
||||||
|
hx-get="/link/{id}/remaining"
|
||||||
|
hx-trigger="click from:#link delay:0.2s, every 10s"
|
||||||
|
>
|
||||||
|
You have
|
||||||
|
{record.downloads_remaining()}
|
||||||
|
download
|
||||||
|
{plural}
|
||||||
|
remaining!
|
||||||
</div>
|
</div>
|
||||||
<button class="return-button" onclick="clipboard()">Copy to Clipboard</button>
|
<button class="return-button" onclick="clipboard()">
|
||||||
|
Copy to Clipboard
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a href="/" class="return-button">
|
||||||
<a href="/" class="return-button">Return to home</a>
|
Return to home
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue