aboutsummaryrefslogtreecommitdiffstats
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
parenteffcafcb7d2010c4d182b296ff2cf5b55cc91cf5 (diff)
downloadneko-d256564c435c5cef02262fb64fb2bddcd38c05a1.tar.gz
neko-d256564c435c5cef02262fb64fb2bddcd38c05a1.tar.bz2
neko-d256564c435c5cef02262fb64fb2bddcd38c05a1.zip
add full view toggle kb shortcut
-rw-r--r--models/item/item.go25
-rw-r--r--static/ui.js16
2 files changed, 34 insertions, 7 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)
diff --git a/static/ui.js b/static/ui.js
index 4f9305c..4df0550 100644
--- a/static/ui.js
+++ b/static/ui.js
@@ -109,10 +109,17 @@ var AppModel = Backbone.Model.extend({
},
star: function() {
- if(this.get('selectedIndex') > 0) {
+ if(this.get('selectedIndex') >= 0) {
App.items.at(this.get('selectedIndex')).toggleStar();
}
+ },
+
+ full: function() {
+ if(this.get('selectedIndex') >= 0) {
+ App.items.at(this.get('selectedIndex')).full();
+ }
}
+
});
var App = new AppModel();
@@ -206,7 +213,7 @@ var Item = Backbone.Model.extend({
},
full: function() {
- this.set({'full': true});
+ this.set({'full': !(this.get('full'))} );
}
});
@@ -544,7 +551,10 @@ function boot() {
event.preventDefault();
App.star();
}
-
+ if (event.which == 70) {
+ event.preventDefault();
+ App.full();
+ }
});
App.boot();