aboutsummaryrefslogtreecommitdiffstats
path: root/models/item
diff options
context:
space:
mode:
Diffstat (limited to 'models/item')
-rw-r--r--models/item/item.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/models/item/item.go b/models/item/item.go
index 48d76bf..ebc1214 100644
--- a/models/item/item.go
+++ b/models/item/item.go
@@ -70,16 +70,33 @@ func (i *Item) FullSave() {
func (i *Item) GetFullContent() {
g := goose.New()
article, err := g.ExtractFromURL(i.Url)
+ if err != nil {
+ log.Println(err)
+ return
+ }
+
+ if article.TopNode == nil {
+ return
+ }
+
var md, img string
md = ""
img = ""
+ md = string(blackfriday.MarkdownCommon([]byte(article.CleanedText)))
+
+ ht, err := article.TopNode.Html()
if err != nil {
- log.Println(err)
- } else {
- md = string(blackfriday.MarkdownCommon([]byte(article.CleanedText)))
- img = article.TopImage
+ return
}
+ p := bluemonday.NewPolicy()
+ p.AllowElements("blockquote", "a", "img", "p", "h1", "h2", "h3", "h4", "b", "i", "em", "strong")
+ p.AllowAttrs("href").OnElements("a")
+ p.AllowAttrs("src", "alt").OnElements("img")
+ md = p.Sanitize(ht)
+
+ img = article.TopImage
+
_, err = models.DB.Exec(`UPDATE item
SET full_content=?, header_image=?
WHERE id=?`, md, img, i.Id)