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

View File

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

View File

@ -43,7 +43,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-2">&nbsp;</div> <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"> <div class="col-xs-2 post-delete">
<form method="POST" action="/news/{{.post.Id}}/delete" class="confirm-news-delete">{{ .csrfField }} <form method="POST" action="/news/{{.post.Id}}/delete" class="confirm-news-delete">{{ .csrfField }}
<input type="submit" class="btn btn-sm btn-block" value="Delete" /> <input type="submit" class="btn btn-sm btn-block" value="Delete" />