bin/views/pages/bin.templ

64 lines
2.3 KiB
Plaintext

package pages
import (
"fmt"
"git.myrkvi.com/myrkvi/bin/config"
"git.myrkvi.com/myrkvi/bin/models"
"git.myrkvi.com/myrkvi/bin/views/components"
)
templ BinFull(file models.File) {
@page(
BinPartial(file),
models.DefaultMenu,
-1,
file.Filename,
)
}
templ BinPartial(file models.File) {
<div>
<h1 class="text-xl my-2 inline-block">{ file.Filename }
if file.Language != "" {
<sup class="text-base mx-4">({ file.Language })</sup>
}
</h1>
<p class="italic mx-1 my-2">{ file.Description }</p>
<pre class="my-4">{ file.Data }</pre>
<div class="relative h-full">
<div class="absolute -bottom-32">
<form
hx-post={ "/b/" + file.PageKey + "/delete" }
hx-confirm="Are you sure you want to delete this?"
hx-target="#main-content"
>
<input
name="adminKey"
id="adminKey"
type="text"
class="mr-4 w-24 bg-amber-50
hover:outline-slate-400 hover:outline-dotted
focus:outline-slate-600 focus:outline-dashed
active:outline-green-600"
placeholder="deletion key"
value={ file.AdminKey }
/>
@components.SubmitFormButton("delete")
if file.AdminKey != "" {
<a class="text-blue-500 mx-4" href={ templ.URL(fmt.Sprintf("/b/%s?delcode=%s", file.PageKey, file.AdminKey))}><sup>permalink with deletion key</sup></a>
}
<p class="opacity-0 my-1 max-w-md" _="init if #adminKey's value is not '' log then show me with *opacity">
this is your deletion key! <br /> you will need to store it if you want to delete the file.
</p>
</form>
if file.AdminKey != "" && file.Email == "" && config.SMTP.Enabled {
<form hx-post={ "/b/" + file.PageKey + "/email" } id="emailForm">
<input type="text" name="adminKey" id="adminKey" hidden value={ file.AdminKey } />
@components.GetButton("email me this!", "/partial/email", "this", "outerHTML")
</form>
}
</div>
</div>
</div>
}