ShOrgRu/pkg/tpl/quote.templ
Alexander Neonxp Kiryukhin e849e705c3
Добавил рейтинг
Добавил страницу топа
Добавил rss/xml/json feed
2024-10-08 03:50:53 +03:00

43 lines
1.5 KiB
Text

package tpl
import (
"fmt"
"sh.org.ru/pkg/config"
"sh.org.ru/pkg/middleware"
"sh.org.ru/pkg/model"
"strconv"
)
templ Quote(quote *model.Quote) {
{{ host := ctx.Value(middleware.ContextKey("config")).(*config.Config).Host }}
<article>
<header>
<a href={ templ.URL(fmt.Sprintf("/quote/%d", quote.ID)) }>#{ strconv.Itoa(int(quote.ID)) }</a>
<span><abbr title="Добавлено на сайт">{ quote.CreatedAt.Format("02.01.06") }</abbr></span>
</header>
@templ.Raw(quote.Text())
<footer>
@Rate(quote, 0)
<span>
if quote.Archive {
<abbr title="Цитата из старого цитатника">Архив</abbr>
}
<a target="_blank" href={ templ.URL(fmt.Sprintf("https://t.me/share/url?url=%s/quote/%d", host, quote.ID)) }><i class="fa fa-telegram" aria-hidden="true"></i></a>&nbsp;&middot;&nbsp
<a target="_blank" href={ templ.URL(fmt.Sprintf("https://vk.com/share.php?url=%s/quote/%d", host, quote.ID)) }><i class="fa fa-vk" aria-hidden="true"></i></a>&nbsp;&middot;&nbsp
<a target="_blank" href={ templ.URL(fmt.Sprintf("https://connect.ok.ru/offer?url=%s/quote/%d", host, quote.ID)) }><i class="fa fa-odnoklassniki-square" aria-hidden="true"></i></a>
</span>
</footer>
</article>
}
templ QuotePage(quote *model.Quote) {
{{ host := ctx.Value(middleware.ContextKey("config")).(*config.Config).Host }}
@Layout(HeaderParams{
Title: "Цитата #" + strconv.Itoa(int(quote.ID)),
URL: fmt.Sprintf("%s/quote/%d", host, quote.ID),
Description: templ.EscapeString(quote.Quote),
}) {
@Quote(quote)
}
}