From b0553ab6cfab2d35d3ec6e075acd23b8aa95035f Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Wed, 11 Oct 2023 20:31:48 +0600 Subject: [PATCH] :lipstick: Created basic editor template --- web/template/baseof.qtpl | 77 ++++++++++++++++++++++++++++++++++++ web/template/editor.qtpl | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 web/template/baseof.qtpl create mode 100644 web/template/editor.qtpl diff --git a/web/template/baseof.qtpl b/web/template/baseof.qtpl new file mode 100644 index 0000000..e698eab --- /dev/null +++ b/web/template/baseof.qtpl @@ -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) %} + + + + + + + {%= p.head() %} + {%= p.title() %} + + + + {%= p.body() %} + + +{% endfunc %} diff --git a/web/template/editor.qtpl b/web/template/editor.qtpl new file mode 100644 index 0000000..3fcdf88 --- /dev/null +++ b/web/template/editor.qtpl @@ -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() %} +
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+{% endfunc %}