mirror of https://github.com/velour/catbase.git
89 lines
2.5 KiB
Plaintext
89 lines
2.5 KiB
Plaintext
package meme
|
|
|
|
templ (p *MemePlugin) index(all webResps) {
|
|
<div class="grid-container">
|
|
<h2>Meme</h2>
|
|
<form>
|
|
<div class="grid-x grid-margin-x">
|
|
<div class="cell auto">
|
|
<input type="text" name="name" placeholder="Name..." />
|
|
</div>
|
|
<div class="cell auto">
|
|
<input type="text" name="url" placeholder="URL..." />
|
|
</div>
|
|
<div class="cell auto">
|
|
<textarea name="config">
|
|
</textarea>
|
|
</div>
|
|
<div class="cell small-2">
|
|
<button class="button"
|
|
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) {
|
|
<div class="grid-x grid-margin-x" id={ meme.Name }>
|
|
<div class="cell small-3">
|
|
<img
|
|
class="thumbnail"
|
|
style="max-height: 150px"
|
|
alt={ meme.Name }
|
|
src={ meme.URL } />
|
|
<p>{ meme.Name }</p>
|
|
</div>
|
|
<div class="cell small-7">
|
|
<pre>
|
|
{ meme.Config }
|
|
</pre>
|
|
</div>
|
|
<div class="cell small-2">
|
|
<button class="button"
|
|
hx-get={ "/meme/edit/"+meme.Name }
|
|
hx-target={ "#"+meme.Name }
|
|
hx-swap="outerHTML"
|
|
>Edit</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
templ (p *MemePlugin) Edit(meme webResp) {
|
|
<form>
|
|
<div class="grid-x grid-margin-x" id={ meme.Name }>
|
|
<div class="cell-small-3">
|
|
<img
|
|
class="thumbnail"
|
|
style="max-height: 150px"
|
|
alt={ meme.Name }
|
|
src={ meme.URL } />
|
|
</div>
|
|
<div class="cell small-7">
|
|
<textarea name="config" rows="10">
|
|
{ meme.Config }
|
|
</textarea>
|
|
<input type="text" name="url" value={ meme.URL } />
|
|
</div>
|
|
<div class="cell small-2">
|
|
<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>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
} |