catbase/plugins/meme/meme.templ

81 lines
2.1 KiB
Plaintext
Raw Normal View History

2024-02-27 22:16:45 +00:00
package meme
templ (p *MemePlugin) index(all webResps) {
<h2>New Meme</h2>
2024-02-27 22:16:45 +00:00
<form>
<input type="text" name="name" placeholder="Name..." />
<input type="text" name="url" placeholder="URL..." />
<textarea name="config">
</textarea>
<button class="button"
hx-post="/meme/add"
hx-target="#newMemes"
>Save</button>
2024-02-27 22:16:45 +00:00
</form>
<h2>Current Memes</h2>
2024-02-27 22:16:45 +00:00
<div id="newMemes">
</div>
2024-05-21 16:28:25 +00:00
<div class="row">
2024-02-27 22:16:45 +00:00
for _, meme := range all {
2024-05-21 16:28:25 +00:00
<div class="col-xs">
<div class="box">@p.Show(meme)</div>
</div>
2024-02-27 22:16:45 +00:00
}
</div>
}
templ (p *MemePlugin) Show(meme webResp) {
2024-05-21 16:28:25 +00:00
<article id={ meme.Name } style="width: 300px">
<header>
<img
class="thumbnail"
2024-05-21 16:28:25 +00:00
style="max-height: 300px; max-width: 300px;"
alt={ meme.Name }
src={ meme.URL } />
<p>{ meme.Name }</p>
</header>
2024-05-21 16:28:25 +00:00
<pre style="max-width: 300px; overflow: auto">
{ meme.Config }
</pre>
<footer>
<button class="button"
hx-get={ "/meme/edit/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Edit</button>
</footer>
</article>
2024-02-27 22:16:45 +00:00
}
templ (p *MemePlugin) Edit(meme webResp) {
2024-05-21 16:28:25 +00:00
<form style="width: 300px">
<article id={ meme.Name }>
<header>
<img
class="thumbnail"
2024-05-21 16:28:25 +00:00
style="max-height: 250px"
alt={ meme.Name }
src={ meme.URL } />
</header>
<textarea name="config" rows="10">
{ meme.Config }
</textarea>
<input type="text" name="url" value={ meme.URL } />
<footer>
<button class="button"
hx-put={ "/meme/save/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Save</button>
<button class="button alert"
hx-delete={ "/meme/rm/"+meme.Name }
hx-target={ "#"+meme.Name }
hx-swap="outerHTML"
>Delete</button>
</footer>
</article>
2024-02-27 22:16:45 +00:00
</form>
}