mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
readability integration
This commit is contained in:
2071
template/static/javascripts/Readability.js
Normal file
2071
template/static/javascripts/Readability.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -83,5 +83,10 @@
|
||||
body: new FormData(form),
|
||||
})
|
||||
},
|
||||
crawl: function(url) {
|
||||
return fetch('/page?url=' + url).then(function(res) {
|
||||
return res.text()
|
||||
})
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
@@ -43,6 +43,7 @@ var vm = new Vue({
|
||||
},
|
||||
'itemSelected': null,
|
||||
'itemSelectedDetails': {},
|
||||
'itemSelectedReadability': '',
|
||||
'itemSearch': '',
|
||||
'settings': 'create',
|
||||
'loading': {
|
||||
@@ -115,6 +116,7 @@ var vm = new Vue({
|
||||
this.refreshItems()
|
||||
},
|
||||
'itemSelected': function(newVal, oldVal) {
|
||||
this.itemSelectedReadability = ''
|
||||
this.itemSelectedDetails = this.itemsById[newVal]
|
||||
if (this.itemSelectedDetails.status == 'unread') {
|
||||
this.itemSelectedDetails.status = 'read'
|
||||
@@ -303,5 +305,18 @@ var vm = new Vue({
|
||||
vm.refreshFeeds()
|
||||
})
|
||||
},
|
||||
getReadable: function(item) {
|
||||
if (item.link) {
|
||||
var vm = this
|
||||
api.crawl(item.link).then(function(body) {
|
||||
if (!body.length) return
|
||||
var doc = new DOMParser().parseFromString(body, 'text/html')
|
||||
var parsed = new Readability(doc).parse()
|
||||
if (parsed && parsed.content) {
|
||||
vm.itemSelectedReadability = parsed.content
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user