2024-06-19 01:08:05 +04:00
|
|
|
package web
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
import "strings"
|
|
|
|
import "time"
|
|
|
|
|
2024-09-14 18:36:08 +04:00
|
|
|
import "github.com/invopop/ctxi18n/i18n"
|
|
|
|
|
2024-06-19 01:08:05 +04:00
|
|
|
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) {
|
2024-09-15 15:40:14 +04:00
|
|
|
@base(i18n.T(ctx, "base.section.mindflow"), i18n.T(ctx, "base.mindflow.description"), "updates, thoughts, opinions, blog, diary", "/mindflow", r, mindflowHead()) {
|
|
|
|
<p class="center">{ i18n.T(ctx, "mindflow.text") }</p>
|
2024-06-27 03:02:52 +04:00
|
|
|
<section>
|
|
|
|
<menu id="filter" class="hidden">
|
2024-09-15 15:40:14 +04:00
|
|
|
<button name="all">{ i18n.T(ctx, "mindflow.all") }</button>
|
2024-06-19 01:08:05 +04:00
|
|
|
for _, category := range categories {
|
|
|
|
<button name={ strings.ToLower(category.Name) }>{ category.Name }</button>
|
|
|
|
}
|
2024-06-27 03:02:52 +04:00
|
|
|
</menu>
|
2024-06-19 01:08:05 +04:00
|
|
|
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") {
|
2024-06-21 01:01:48 +04:00
|
|
|
<p
|
2024-06-19 01:08:05 +04:00
|
|
|
if len(line) > 0 && line[0] == '>' {
|
2024-06-21 01:01:48 +04:00
|
|
|
class="quote"
|
|
|
|
}>@templ.Raw(line)</p>
|
2024-06-19 01:08:05 +04:00
|
|
|
}
|
|
|
|
<footer>
|
|
|
|
if post.URL != "" {
|
|
|
|
<a href={ templ.SafeURL(post.PostURL(r.Host, false)) }>{ post.PostURL(r.Host, false) }</a>
|
|
|
|
} else {
|
|
|
|
<span></span>
|
|
|
|
}
|
2024-07-02 17:28:38 +04:00
|
|
|
{{ ctz := util.ToClientTimezone(post.Date, r) }}
|
2024-09-15 15:52:54 +04:00
|
|
|
<time datetime={ ctz.Format(time.RFC3339) }>{ ctz.Format("02.01.2006 15:04:05 -07:00") }</time>
|
2024-06-19 01:08:05 +04:00
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
}
|
|
|
|
if len(posts) == 0 {
|
2024-09-15 15:40:14 +04:00
|
|
|
<p class="center">{ i18n.T(ctx, "mindflow.no-posts") }</p>
|
2024-06-19 01:08:05 +04:00
|
|
|
}
|
|
|
|
</section>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
templ mindflowHead() {
|
|
|
|
<link rel="stylesheet" href="/assets/css/mindflow.css"/>
|
|
|
|
<script src="/assets/js/mindflow.js" defer></script>
|
|
|
|
}
|