aboutsummaryrefslogtreecommitdiffstats
path: root/models/item
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-11-21 15:13:15 -0700
committerAdam Mathes <adam@trenchant.org>2017-11-21 15:13:15 -0700
commitd256564c435c5cef02262fb64fb2bddcd38c05a1 (patch)
tree902914fb325bd8de68f0df052cabb2a3d21dc79e /models/item
parenteffcafcb7d2010c4d182b296ff2cf5b55cc91cf5 (diff)
downloadneko-d256564c435c5cef02262fb64fb2bddcd38c05a1.tar.gz
neko-d256564c435c5cef02262fb64fb2bddcd38c05a1.tar.bz2
neko-d256564c435c5cef02262fb64fb2bddcd38c05a1.zip
add full view toggle kb shortcut
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)