diff options
Diffstat (limited to 'pkg/tpl/quote.templ')
-rw-r--r-- | pkg/tpl/quote.templ | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pkg/tpl/quote.templ b/pkg/tpl/quote.templ index 34429d1..7b38faa 100644 --- a/pkg/tpl/quote.templ +++ b/pkg/tpl/quote.templ @@ -2,11 +2,14 @@ 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> @@ -14,24 +17,24 @@ templ Quote(quote *model.Quote) { </header> @templ.Raw(quote.Text()) <footer> - <span> - <a target="_blank" href={ templ.URL(fmt.Sprintf("https://t.me/share/url?url=https://sh.org.ru/quote/%d", 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=https://sh.org.ru/quote/%d", 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=https://sh.org.ru/quote/%d", quote.ID)) }><i class="fa fa-odnoklassniki-square" aria-hidden="true"></i></a> - </span> + @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> ·  + <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> </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("https://sh.org.ru/quote/%d", quote.ID), + Title: "Цитата #" + strconv.Itoa(int(quote.ID)), + URL: fmt.Sprintf("%s/quote/%d", host, quote.ID), Description: templ.EscapeString(quote.Quote), }) { @Quote(quote) |