💄 Created basic editor template
This commit is contained in:
parent
7c09e8f8f8
commit
b0553ab6cf
77
web/template/baseof.qtpl
Normal file
77
web/template/baseof.qtpl
Normal file
|
@ -0,0 +1,77 @@
|
|||
{% import (
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
) %}
|
||||
|
||||
{% interface Page {
|
||||
body()
|
||||
dir()
|
||||
head()
|
||||
lang()
|
||||
title()
|
||||
t(format message.Reference, a ...any)
|
||||
} %}
|
||||
|
||||
{% code
|
||||
type BaseOf struct {
|
||||
language language.Tag
|
||||
printer *message.Printer
|
||||
}
|
||||
|
||||
func NewBaseOf(lang language.Tag) *BaseOf {
|
||||
return &BaseOf{
|
||||
language: lang,
|
||||
printer: message.NewPrinter(lang),
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
{% func (b *BaseOf) lang() %}
|
||||
{%s b.language.String() %}
|
||||
{% endfunc %}
|
||||
|
||||
{% func (b *BaseOf) dir() %}
|
||||
{% for _, tag := range []language.Tag{
|
||||
language.Arabic,
|
||||
language.Hebrew,
|
||||
language.Persian,
|
||||
language.Urdu,
|
||||
} %}
|
||||
{% if b.language != tag %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
rtl
|
||||
{% return %}
|
||||
{% endfor %}
|
||||
ltr
|
||||
{% endfunc %}
|
||||
|
||||
{% func (b *BaseOf) title() %}
|
||||
Micropub
|
||||
{% endfunc %}
|
||||
|
||||
{% func (b *BaseOf) head() %}{% endfunc %}
|
||||
{% func (b *BaseOf) body() %}{% endfunc %}
|
||||
|
||||
{% func (b *BaseOf) t(format message.Reference, a ...any) %}
|
||||
{%s b.printer.Sprintf(format, a...) %}
|
||||
{% endfunc %}
|
||||
|
||||
{% func Template(p Page) %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="{%= p.lang() %}"
|
||||
dir="{%= p.dir() %}">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0">
|
||||
{%= p.head() %}
|
||||
<title>{%= p.title() %}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{%= p.body() %}
|
||||
</body>
|
||||
</html>
|
||||
{% endfunc %}
|
84
web/template/editor.qtpl
Normal file
84
web/template/editor.qtpl
Normal file
|
@ -0,0 +1,84 @@
|
|||
{% import (
|
||||
"time"
|
||||
) %}
|
||||
|
||||
{% code
|
||||
type PageEditor struct {
|
||||
*BaseOf
|
||||
now time.Time
|
||||
}
|
||||
|
||||
func NewPageEditor(base *BaseOf) *PageEditor {
|
||||
return &PageEditor{
|
||||
BaseOf: base,
|
||||
now: time.Now().UTC(),
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
{% func (pe *PageEditor) title() %}
|
||||
Editor — Micropub
|
||||
{% endfunc %}
|
||||
|
||||
{% func (pe *PageEditor) head() %}{% endfunc %}
|
||||
|
||||
{% func (pe *PageEditor) body() %}
|
||||
<form method="post"
|
||||
action="/api"
|
||||
target="_self"
|
||||
accept-charset="utf-8"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
autocomplete="off">
|
||||
|
||||
<input type="hidden"
|
||||
name="h"
|
||||
value="entry" />
|
||||
|
||||
<div>
|
||||
<label>
|
||||
{%= pe.t(`Name`) %}
|
||||
<input type="text"
|
||||
name="name"
|
||||
placeholder="Hello, World!" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
{%= pe.t(`Content`) %}
|
||||
<textarea name="content"
|
||||
cols="30"
|
||||
rows="10"
|
||||
placeholder="Lorem ipsum dolor sit amet...">
|
||||
</textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
{%= pe.t(`Published at`) %}
|
||||
<input type="datetime-local"
|
||||
name="published"
|
||||
min="1970-01-01T00:00:00"
|
||||
value="{%s pe.now.Format(`2006-01-02T15:04:05`) %}"
|
||||
step="1" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
{%= pe.t(`Tags`) %}
|
||||
<input type="text"
|
||||
name="category"
|
||||
pattern="[a-zA-Z0-9-, ]"
|
||||
placeholder="note, 100DaysOfIndieWeb...">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit">
|
||||
{%= pe.t(`Send`) %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endfunc %}
|
Loading…
Reference in New Issue
Block a user