2024-10-06 17:04:37 +03:00
|
|
|
package tpl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-08 03:43:08 +03:00
|
|
|
"sh.org.ru/pkg/config"
|
|
|
|
"sh.org.ru/pkg/middleware"
|
2024-10-06 17:04:37 +03:00
|
|
|
"sh.org.ru/pkg/model"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
templ Quote(quote *model.Quote) {
|
2024-10-08 03:43:08 +03:00
|
|
|
{{ host := ctx.Value(middleware.ContextKey("config")).(*config.Config).Host }}
|
2024-10-06 17:04:37 +03:00
|
|
|
<article>
|
2024-10-07 01:06:55 +03:00
|
|
|
<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>
|
2024-10-06 17:04:37 +03:00
|
|
|
@templ.Raw(quote.Text())
|
|
|
|
<footer>
|
2024-10-08 03:43:08 +03:00
|
|
|
@Rate(quote, 0)
|
2024-10-07 01:06:55 +03:00
|
|
|
<span>
|
|
|
|
if quote.Archive {
|
|
|
|
<abbr title="Цитата из старого цитатника">Архив</abbr>
|
|
|
|
}
|
2024-10-08 03:43:08 +03:00
|
|
|
<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> · 
|
|
|
|
<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> · 
|
|
|
|
<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>
|
2024-10-07 01:06:55 +03:00
|
|
|
</span>
|
2024-10-06 17:04:37 +03:00
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ QuotePage(quote *model.Quote) {
|
2024-10-08 03:43:08 +03:00
|
|
|
{{ host := ctx.Value(middleware.ContextKey("config")).(*config.Config).Host }}
|
2024-10-06 17:04:37 +03:00
|
|
|
@Layout(HeaderParams{
|
2024-10-08 03:43:08 +03:00
|
|
|
Title: "Цитата #" + strconv.Itoa(int(quote.ID)),
|
|
|
|
URL: fmt.Sprintf("%s/quote/%d", host, quote.ID),
|
2024-10-06 17:04:37 +03:00
|
|
|
Description: templ.EscapeString(quote.Quote),
|
|
|
|
}) {
|
|
|
|
@Quote(quote)
|
|
|
|
}
|
|
|
|
}
|