57 lines
1.7 KiB
Plaintext
57 lines
1.7 KiB
Plaintext
package web
|
|
|
|
import "net/http"
|
|
import "strings"
|
|
import "time"
|
|
|
|
import "github.com/invopop/ctxi18n/i18n"
|
|
|
|
import "git.arav.su/Arav/dwelling-home/pkg/mindflow"
|
|
import "git.arav.su/Arav/dwelling-home/pkg/util"
|
|
|
|
templ Mindflow(posts []mindflow.Post, categories []mindflow.Category, r *http.Request) {
|
|
@base(i18n.T(ctx, "base.section.mindflow"), i18n.T(ctx, "mindflow.description"), i18n.T(ctx, "mindflow.keywords"), "/mindflow", r, mindflowHead()) {
|
|
<p class="center">{ i18n.T(ctx, "mindflow.text") }</p>
|
|
<section>
|
|
<menu id="filter" class="hidden">
|
|
<button name="all">{ i18n.T(ctx, "mindflow.all") }</button>
|
|
for _, category := range categories {
|
|
<button name={ strings.ToLower(category.Name) }>{ category.Name }</button>
|
|
}
|
|
</menu>
|
|
for _, post := range posts {
|
|
<article id={ post.PostID() }>
|
|
<header>
|
|
<a href={ templ.SafeURL("#" + post.PostID()) }>
|
|
<h3>{ post.Category.Name }: { post.Title }</h3>
|
|
</a>
|
|
</header>
|
|
for _, line := range strings.Split(post.Body, "\n") {
|
|
<p
|
|
if len(line) > 0 && line[0] == '>' {
|
|
class="quote"
|
|
}>@templ.Raw(line)</p>
|
|
}
|
|
<footer>
|
|
if post.URL != "" {
|
|
<a href={ templ.SafeURL(post.PostURL(r.Host, false)) }>{ post.PostURL(r.Host, false) }</a>
|
|
} else {
|
|
<span></span>
|
|
}
|
|
{{ ctz := util.ToClientTimezone(post.Date, r) }}
|
|
<time datetime={ ctz.Format(time.RFC3339) }>{ ctz.Format("02.01.2006 15:04:05 -07:00") }</time>
|
|
</footer>
|
|
</article>
|
|
}
|
|
if len(posts) == 0 {
|
|
<p class="center">{ i18n.T(ctx, "mindflow.no-posts") }</p>
|
|
}
|
|
</section>
|
|
}
|
|
}
|
|
|
|
templ mindflowHead() {
|
|
<link rel="stylesheet" href="/assets/css/mindflow.css"/>
|
|
<script src="/assets/js/mindflow.js" defer></script>
|
|
}
|