don't truncate news notes display

This commit is contained in:
Dan Ballard 2016-01-09 06:29:40 -08:00
parent 62366427fb
commit b45d101657
3 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,8 @@ import (
_ "github.com/lib/pq"
"strconv"
"time"
"html/template"
"strings"
)
type News struct {
@ -17,6 +19,7 @@ type News struct {
Category_id int
Date time.Time
Notes string
htmlNotes template.HTML
}
const (
@ -138,6 +141,10 @@ func (news *News) Id() int {
return news.id
}
func (news *News) HTMLNotes() template.HTML {
return news.htmlNotes
}
func nullStringToString(str *sql.NullString) string {
if str.Valid {
return str.String
@ -182,6 +189,9 @@ func scanNews(rows *sql.Rows) (*News, error) {
news.Url = nullStringToString(&url)
news.Title = nullStringToString(&title)
news.Notes = nullStringToString(&notes)
// support wordpress style <quote> tags
news.Notes = strings.Replace(news.Notes, "quote>", "blockquote>", -1)
news.htmlNotes = template.HTML(news.Notes)
if category_id.Valid {
news.Category_id = int(category_id.Int64)

View File

@ -5,7 +5,6 @@ import (
"fmt"
"github.com/dballard/transmet/categories"
"github.com/gorilla/csrf"
"html/template"
"net/http"
"path/filepath"

View File

@ -43,7 +43,7 @@
</div>
<div class="row">
<div class="col-xs-2">&nbsp;</div>
<div class="col-xs-8 post-preview">{{truncate .post.Notes 500}}</div>
<div class="col-xs-8 post-content"> {{ .post.HTMLNotes }}</div>
<div class="col-xs-2 post-delete">
<form method="POST" action="/news/{{.post.Id}}/delete" class="confirm-news-delete">{{ .csrfField }}
<input type="submit" class="btn btn-sm btn-block" value="Delete" />