readability integration

This commit is contained in:
Nazar Kanaev
2020-07-15 21:34:14 +01:00
parent 5d5f95725f
commit ef0e404b90
7 changed files with 2113 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -83,5 +83,10 @@
body: new FormData(form),
})
},
crawl: function(url) {
return fetch('/page?url=' + url).then(function(res) {
return res.text()
})
}
}
})()

View File

@@ -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
}
})
}
},
}
})