Convert template.HTML to string

This commit is contained in:
Radhi Fadlillah 2018-03-06 16:48:06 +07:00
parent 8b31568eaf
commit b16c5cc363
3 changed files with 14 additions and 18 deletions

View file

@ -1,7 +1,6 @@
package cmd package cmd
import ( import (
"html/template"
nurl "net/url" nurl "net/url"
"strings" "strings"
"time" "time"
@ -81,7 +80,7 @@ func addBookmark(base model.Bookmark, offline bool) (book model.Bookmark, err er
book.MinReadTime = article.Meta.MinReadTime book.MinReadTime = article.Meta.MinReadTime
book.MaxReadTime = article.Meta.MaxReadTime book.MaxReadTime = article.Meta.MaxReadTime
book.Content = article.Content book.Content = article.Content
book.HTML = template.HTML(article.RawContent) book.HTML = article.RawContent
if book.Title == "" { if book.Title == "" {
book.Title = article.Meta.Title book.Title = article.Meta.Title

View file

@ -2,7 +2,6 @@ package cmd
import ( import (
"fmt" "fmt"
"html/template"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -121,7 +120,7 @@ func updateBookmarks(indices []string, url, title, excerpt string, tags []string
book.MinReadTime = article.Meta.MinReadTime book.MinReadTime = article.Meta.MinReadTime
book.MaxReadTime = article.Meta.MaxReadTime book.MaxReadTime = article.Meta.MaxReadTime
book.Content = article.Content book.Content = article.Content
book.HTML = template.HTML(article.RawContent) book.HTML = article.RawContent
mutex.Lock() mutex.Lock()
bookmarks[pos] = book bookmarks[pos] = book

View file

@ -1,7 +1,5 @@
package model package model
import "html/template"
// Tag is tag for the bookmark // Tag is tag for the bookmark
type Tag struct { type Tag struct {
ID int64 `db:"id" json:"id"` ID int64 `db:"id" json:"id"`
@ -21,7 +19,7 @@ type Bookmark struct {
MaxReadTime int `db:"max_read_time" json:"maxReadTime"` MaxReadTime int `db:"max_read_time" json:"maxReadTime"`
Modified string `db:"modified" json:"modified"` Modified string `db:"modified" json:"modified"`
Content string `db:"content" json:"-"` Content string `db:"content" json:"-"`
HTML template.HTML `db:"html" json:"-"` HTML string `db:"html" json:"-"`
Tags []Tag `json:"tags"` Tags []Tag `json:"tags"`
} }