don't truncate news notes display
This commit is contained in:
parent
62366427fb
commit
b45d101657
10
news/news.go
10
news/news.go
|
@ -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(¬es)
|
||||
// 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)
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/dballard/transmet/categories"
|
||||
"github.com/gorilla/csrf"
|
||||
|
||||
"html/template"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-2"> </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" />
|
||||
|
|
Loading…
Reference in New Issue