From 5161350c20b288c679c6f017d8c65eeea89a6af3 Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Wed, 12 May 2021 08:23:37 +0300 Subject: [PATCH] [Quotes]: quotes parser --- node/ssr.go | 10 ++++++++-- templates/common/style.html | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/node/ssr.go b/node/ssr.go index a5092ec..0d72edf 100644 --- a/node/ssr.go +++ b/node/ssr.go @@ -69,7 +69,7 @@ func parseQuotes(message string) string { for _, line := range strings.Split(message, "\n") { if r.MatchString(line) { author := r.FindAllStringSubmatch(line, 1) - quote := "
" + author[0][2] + "
" + quote := "
" + author[0][2] + "
" if len(author) > 0 && author[0][1] != "" { quote += `` } @@ -245,7 +245,12 @@ func (s *ssr) singleMessageHandler(w http.ResponseWriter, r *http.Request) { return } - if err := tpl.Execute(w, s.newPageData(msgid, s.es.GetMessage(msgid), 1, false)); err != nil { + post := s.es.GetMessage(msgid) + if len(post) > 0 { + post[0].Message = parseQuotes(post[0].Message) + } + + if err := tpl.Execute(w, s.newPageData(msgid, post, 1, false)); err != nil { log.Error(err) } } @@ -268,6 +273,7 @@ func (s *ssr) searchHandler(w http.ResponseWriter, r *http.Request) { posts := s.es.DoSearch(string(m)) for i := range posts { posts[i].Date = parseTime(posts[i].Date) + posts[i].Message = parseQuotes(posts[i].Message) } if err := tpl.Execute(w, s.newPageData("search", posts, 1, false)); err != nil { diff --git a/templates/common/style.html b/templates/common/style.html index 906997f..a21404d 100644 --- a/templates/common/style.html +++ b/templates/common/style.html @@ -93,11 +93,11 @@ } .quote { - color: green; + color: #859900; border: 0; border-right: 1px; border-style: solid; - border-color: grey; + border-color: #586e75; padding-right: 0.5em; }