[Quotes]: quotes parser

This commit is contained in:
Denis Zheleztsov 2021-05-12 08:23:37 +03:00
parent 2540eeee26
commit 5161350c20
2 changed files with 10 additions and 4 deletions

View File

@ -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 := "<figure class=\"text-end\"><blockquote class=\"blockquote quote\"><small>" + author[0][2] + "</small></blockquote>"
quote := "<figure class=\"text-end quote\"><blockquote class=\"blockquote\"><small>" + author[0][2] + "</small></blockquote>"
if len(author) > 0 && author[0][1] != "" {
quote += `<figcaption class="blockquote-footer">` + author[0][1] + `</figcaption>`
}
@ -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 {

View File

@ -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;
}