catbase/plugins/meme/meme.templ

89 lines
2.5 KiB
Plaintext
Raw Normal View History

2024-02-27 22:16:45 +00:00
package meme
templ (p *MemePlugin) index(all webResps) {
2024-02-28 15:09:25 +00:00
<div class="grid-container">
<h2>Meme</h2>
2024-02-27 22:16:45 +00:00
<form>
2024-02-28 15:09:25 +00:00
<div class="grid-x grid-margin-x">
<div class="cell auto">
2024-02-27 22:16:45 +00:00
<input type="text" name="name" placeholder="Name..." />
</div>
2024-02-28 15:09:25 +00:00
<div class="cell auto">
2024-02-27 22:16:45 +00:00
<input type="text" name="url" placeholder="URL..." />
</div>
2024-02-28 15:09:25 +00:00
<div class="cell auto">
2024-02-27 22:16:45 +00:00
<textarea name="config">
</textarea>
</div>
2024-02-28 15:09:25 +00:00
<div class="cell small-2">
<button class="button"
2024-02-27 22:16:45 +00:00
hx-post="/meme/add"
hx-target="#newMemes"
>Save</button>
</div>
</div>
</form>
<div id="newMemes">
</div>
for _, meme := range all {
@p.Show(meme)
}
</div>
}
templ (p *MemePlugin) Show(meme webResp) {
2024-02-28 15:09:25 +00:00
<div class="grid-x grid-margin-x" id={ meme.Name }>
<div class="cell small-3">
2024-02-27 22:16:45 +00:00
<img
2024-02-28 15:09:25 +00:00
class="thumbnail"
style="max-height: 150px"
2024-02-27 22:16:45 +00:00
alt={ meme.Name }
src={ meme.URL } />
2024-02-28 15:09:25 +00:00
<p>{ meme.Name }</p>
2024-02-27 22:16:45 +00:00
</div>
2024-02-28 15:09:25 +00:00
<div class="cell small-7">
2024-02-27 22:16:45 +00:00
<pre>
{ meme.Config }
</pre>
</div>
2024-02-28 15:09:25 +00:00
<div class="cell small-2">
<button class="button"
2024-02-27 22:16:45 +00:00
hx-get={ "/meme/edit/"+meme.Name }
hx-target={ "#"+meme.Name }
2024-02-28 15:09:25 +00:00
hx-swap="outerHTML"
2024-02-27 22:16:45 +00:00
>Edit</button>
</div>
</div>
}
templ (p *MemePlugin) Edit(meme webResp) {
<form>
2024-02-28 15:09:25 +00:00
<div class="grid-x grid-margin-x" id={ meme.Name }>
<div class="cell-small-3">
2024-02-27 22:16:45 +00:00
<img
2024-02-28 15:09:25 +00:00
class="thumbnail"
style="max-height: 150px"
2024-02-27 22:16:45 +00:00
alt={ meme.Name }
src={ meme.URL } />
</div>
2024-02-28 15:09:25 +00:00
<div class="cell small-7">
<textarea name="config" rows="10">
2024-02-27 22:16:45 +00:00
{ meme.Config }
</textarea>
<input type="text" name="url" value={ meme.URL } />
</div>
2024-02-28 15:09:25 +00:00
<div class="cell small-2">
<button class="button"
2024-02-27 22:16:45 +00:00
hx-put={ "/meme/save/"+meme.Name }
hx-target={ "#"+meme.Name }
2024-02-28 15:09:25 +00:00
hx-swap="outerHTML"
2024-02-27 22:16:45 +00:00
>Save</button>
2024-02-28 15:09:25 +00:00
<button class="button alert"
2024-02-27 22:16:45 +00:00
hx-delete={ "/meme/rm/"+meme.Name }
hx-target={ "#"+meme.Name }
2024-02-28 15:09:25 +00:00
hx-swap="outerHTML"
2024-02-27 22:16:45 +00:00
>Delete</button>
</div>
</div>
</form>
}