1
0
dwelling-home/web/mindflow.templ

57 lines
1.9 KiB
Plaintext

package web
import "net/http"
import "strings"
import "time"
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("Mindflow", "Updates on my infrastructure, my very important opinions and thoughts.", "updates, thoughts, opinions, blog, diary", "/mindflow", mindflowHead()) {
<p class="center">Here I post updates on websites and infrastructure, my very important opinions and thoughts no one asked for. If you'd like to subscribe to this bullshittery then <a href="/rss.xml">RSS feed</a> at your service. :)</p>
<section id="filter" class="hidden">
<p class="center">
<button name="all">All</button>
for _, category := range categories {
<button name={ strings.ToLower(category.Name) }>{ category.Name }</button>
}
</p>
</section>
<section>
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") {
if len(line) > 0 && line[0] == '>' {
<p class="quote">@templ.Raw(line)</p>
} else {
<p>@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>
}
<time datetime={ util.ToClientTimezone(post.Date, r).Format(time.RFC1123) }>{ util.ToClientTimezone(post.Date, r).Format(time.RFC1123) }</time>
</footer>
</article>
}
if len(posts) == 0 {
<p class="center">Nothing? There must be some... Looks like database went down.</p>
}
</section>
}
}
templ mindflowHead() {
<link rel="stylesheet" href="/assets/css/mindflow.css"/>
<script src="/assets/js/mindflow.js" defer></script>
}