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

View file

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

View file

@ -1,7 +1,5 @@
package model
import "html/template"
// Tag is tag for the bookmark
type Tag struct {
ID int64 `db:"id" json:"id"`
@ -11,18 +9,18 @@ type Tag struct {
// Bookmark is record of a specified URL
type Bookmark struct {
ID int64 `db:"id" json:"id"`
URL string `db:"url" json:"url"`
Title string `db:"title" json:"title"`
ImageURL string `db:"image_url" json:"imageURL"`
Excerpt string `db:"excerpt" json:"excerpt"`
Author string `db:"author" json:"author"`
MinReadTime int `db:"min_read_time" json:"minReadTime"`
MaxReadTime int `db:"max_read_time" json:"maxReadTime"`
Modified string `db:"modified" json:"modified"`
Content string `db:"content" json:"-"`
HTML template.HTML `db:"html" json:"-"`
Tags []Tag `json:"tags"`
ID int64 `db:"id" json:"id"`
URL string `db:"url" json:"url"`
Title string `db:"title" json:"title"`
ImageURL string `db:"image_url" json:"imageURL"`
Excerpt string `db:"excerpt" json:"excerpt"`
Author string `db:"author" json:"author"`
MinReadTime int `db:"min_read_time" json:"minReadTime"`
MaxReadTime int `db:"max_read_time" json:"maxReadTime"`
Modified string `db:"modified" json:"modified"`
Content string `db:"content" json:"-"`
HTML string `db:"html" json:"-"`
Tags []Tag `json:"tags"`
}
// Account is account for accessing bookmarks from web interface