Migrated RSS news widget

This commit is contained in:
Fabio Manganiello 2020-11-26 17:11:03 +01:00
parent 3c9a633907
commit 0902099855
17 changed files with 137 additions and 11 deletions

View file

@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>platypush</title><link href="/static/css/chunk-2dcde994.9a64be0a.css" rel="prefetch"><link href="/static/css/chunk-4bbbb9a3.4d06e8fc.css" rel="prefetch"><link href="/static/css/chunk-5710a9bc.40372d79.css" rel="prefetch"><link href="/static/css/chunk-62a3d08e.46dc0c5b.css" rel="prefetch"><link href="/static/css/chunk-7c2209ed.a669bf94.css" rel="prefetch"><link href="/static/css/chunk-ed4988aa.53a5d02c.css" rel="prefetch"><link href="/static/js/chunk-2dcde994.af8aa6cd.js" rel="prefetch"><link href="/static/js/chunk-4bbbb9a3.d3030ed8.js" rel="prefetch"><link href="/static/js/chunk-5710a9bc.aefd4d41.js" rel="prefetch"><link href="/static/js/chunk-62a3d08e.15815e60.js" rel="prefetch"><link href="/static/js/chunk-7c2209ed.46b43454.js" rel="prefetch"><link href="/static/js/chunk-ed4988aa.fb022ef7.js" rel="prefetch"><link href="/static/css/app.45b363ac.css" rel="preload" as="style"><link href="/static/js/app.0d61a5ab.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71d8c4c8.js" rel="preload" as="script"><link href="/static/css/app.45b363ac.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71d8c4c8.js"></script><script src="/static/js/app.0d61a5ab.js"></script></body></html> <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>platypush</title><link href="/static/css/chunk-2dcde994.9a64be0a.css" rel="prefetch"><link href="/static/css/chunk-4bbbb9a3.4d06e8fc.css" rel="prefetch"><link href="/static/css/chunk-5301c11c.b2e9b4e4.css" rel="prefetch"><link href="/static/css/chunk-5710a9bc.40372d79.css" rel="prefetch"><link href="/static/css/chunk-62a3d08e.46dc0c5b.css" rel="prefetch"><link href="/static/css/chunk-7c2209ed.a669bf94.css" rel="prefetch"><link href="/static/css/chunk-e8078048.0533fdce.css" rel="prefetch"><link href="/static/js/chunk-2dcde994.af8aa6cd.js" rel="prefetch"><link href="/static/js/chunk-4bbbb9a3.d3030ed8.js" rel="prefetch"><link href="/static/js/chunk-5301c11c.8418e498.js" rel="prefetch"><link href="/static/js/chunk-5710a9bc.aefd4d41.js" rel="prefetch"><link href="/static/js/chunk-62a3d08e.15815e60.js" rel="prefetch"><link href="/static/js/chunk-7c2209ed.46b43454.js" rel="prefetch"><link href="/static/js/chunk-e8078048.c3960daf.js" rel="prefetch"><link href="/static/css/app.8b86c014.css" rel="preload" as="style"><link href="/static/js/app.254c470a.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71d8c4c8.js" rel="preload" as="script"><link href="/static/css/app.8b86c014.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71d8c4c8.js"></script><script src="/static/js/app.254c470a.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5301c11c"],{"3c5e":function(e,t,r){},"9e28":function(e,t,r){},af1f:function(e,t,r){"use strict";r("3c5e")},c845:function(e,t,r){"use strict";r.r(t);var s=r("7a23"),a=Object(s["F"])("data-v-2e27cc96");Object(s["u"])("data-v-2e27cc96");var o={class:"image-carousel"},i={ref:"background",class:"background"},n={key:1,class:"row info-container"},h={class:"col-6 weather-container"},c={key:0},u={class:"col-6 date-time-container"};Object(s["s"])();var m=a((function(e,t,r,a,m,d){var l=Object(s["z"])("Loading"),f=Object(s["z"])("Weather"),w=Object(s["z"])("DateTime");return Object(s["r"])(),Object(s["e"])("div",o,[m.images.length?Object(s["f"])("",!0):(Object(s["r"])(),Object(s["e"])(l,{key:0})),Object(s["h"])("div",i,null,512),Object(s["h"])("img",{ref:"img",src:d.imgURL,alt:"Your carousel images",style:{display:m.images.length?"block":"none"}},null,12,["src"]),d._showDate||d._showTime?(Object(s["r"])(),Object(s["e"])("div",n,[Object(s["h"])("div",h,[d._showWeather?(Object(s["r"])(),Object(s["e"])(f,{key:1,"show-icon":d._showWeatherIcon,"show-summary":d._showWeatherSummary,"show-temperature":d._showTemperature,"icon-color":r.weatherIconColor,"icon-size":r.weatherIconSize,animate:d._animateWeatherIcon},null,8,["show-icon","show-summary","show-temperature","icon-color","icon-size","animate"])):(Object(s["r"])(),Object(s["e"])("span",c," "))]),Object(s["h"])("div",u,[d._showTime||d._showDate?(Object(s["r"])(),Object(s["e"])(w,{key:0,"show-date":d._showDate,"show-time":d._showTime,"show-seconds":d._showSeconds},null,8,["show-date","show-time","show-seconds"])):Object(s["f"])("",!0)])])):Object(s["f"])("",!0)])})),d=(r("a9e3"),r("96cf"),r("1da1")),l=r("3e54"),f=r("3a5e"),w=r("365a"),g=r("5b43"),p={name:"ImageCarousel",components:{Weather:g["default"],DateTime:w["default"],Loading:f["a"]},mixins:[l["a"]],props:{imgDir:{type:String,required:!0},refreshSeconds:{type:Number,required:!1,default:15},showDate:{type:Boolean,required:!1,default:!1},showTime:{type:Boolean,required:!1,default:!1},showSeconds:{type:Boolean,required:!1,default:!1},showWeather:{type:Boolean,required:!1,default:!1},showTemperature:{type:Boolean,required:!1,default:!0},showWeatherIcon:{type:Boolean,required:!1,default:!0},showWeatherSummary:{type:Boolean,required:!1,default:!0},weatherIconColor:{type:String,required:!1,default:"white"},weatherIconSize:{type:Number,required:!1,default:70},animateWeatherIcon:{required:!1,default:!0}},data:function(){return{images:[],currentImage:void 0,loading:!1}},computed:{imgURL:function(){var e=8008;return"backend.http"in this.$root.config&&"port"in this.$root.config["backend.http"]&&(e=this.$root.config["backend.http"].port),"//"+window.location.hostname+":"+e+this.currentImage},_showDate:function(){return this.parseBoolean(this.showDate)},_showTime:function(){return this.parseBoolean(this.showTime)},_showSeconds:function(){return this.parseBoolean(this.showSeconds)},_showTemperature:function(){return this.parseBoolean(this.showTemperature)},_showWeather:function(){return this.parseBoolean(this.showWeather)},_showWeatherIcon:function(){return this.parseBoolean(this.showWeatherIcon)},_showWeatherSummary:function(){return this.parseBoolean(this.showWeatherSummary)},_animateWeatherIcon:function(){return this.parseBoolean(this.animateWeatherIcon)}},methods:{refresh:function(){var e=this;return Object(d["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.images.length){t.next=10;break}return e.loading=!0,t.prev=2,t.next=5,e.request("utils.search_web_directory",{directory:e.imgDir,extensions:[".jpg",".jpeg",".png"]});case 5:e.images=t.sent,e.shuffleImages();case 7:return t.prev=7,e.loading=!1,t.finish(7);case 10:e.images.length&&(e.currentImage=e.images.pop());case 11:case"end":return t.stop()}}),t,null,[[2,,7,10]])})))()},onNewImage:function(){if(this.$refs.img&&(this.$refs.background.style["background-image"]="url("+this.imgURL+")",this.$refs.img.style.width="auto",this.$refs.img.width>this.$refs.img.height)){var e=this.$refs.img.width/this.$refs.img.height;4/3<=e<=16/9&&(this.$refs.img.style.width="100%"),e<=4/3&&(this.$refs.img.style.height="100%")}},shuffleImages:function(){for(var e=this.images.length-1;e>0;e--){var t=Math.floor(Math.random()*(e+1)),r=this.images[e];this.images[e]=this.images[t],this.images[t]=r}}},mounted:function(){this.$refs.img.addEventListener("load",this.onNewImage),this.$refs.img.addEventListener("error",this.refresh),this.refresh(),setInterval(this.refresh,Math.round(1e3*this.refreshSeconds))}};r("af1f"),r("d233");p.render=m,p.__scopeId="data-v-2e27cc96";t["default"]=p},d233:function(e,t,r){"use strict";r("9e28")}}]);
//# sourceMappingURL=chunk-5301c11c.8418e498.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-e8078048"],{"3ddd":function(e,t,r){},a41f:function(e,t,r){"use strict";r("3ddd")},c306:function(e,t,r){"use strict";r.r(t);var n=r("7a23"),s=Object(n["F"])("data-v-919872a2");Object(n["u"])("data-v-919872a2");var i={class:"rss-news"},c={key:0,class:"article"};Object(n["s"])();var u=s((function(e,t,r,s,u,a){return Object(n["r"])(),Object(n["e"])("div",i,[e.currentArticle?(Object(n["r"])(),Object(n["e"])("div",c,[Object(n["h"])("div",{class:"source",textContent:Object(n["C"])(e.currentArticle.source)},null,8,["textContent"]),Object(n["h"])("div",{class:"title",textContent:Object(n["C"])(e.currentArticle.title)},null,8,["textContent"]),Object(n["h"])("div",{class:"published",textContent:Object(n["C"])(new Date(e.currentArticle.published).toDateString()+", "+new Date(e.currentArticle.published).toTimeString().substring(0,5))},null,8,["textContent"])])):Object(n["f"])("",!0)])})),a=(r("a9e3"),r("b680"),r("2909")),d=(r("96cf"),r("1da1")),l=r("3e54"),o={name:"RssNews",mixins:[l["a"]],props:{db:{type:String,required:!0},limit:{type:Number,required:!1,default:25},refreshSeconds:{type:Number,required:!1,default:15}},data:function(){return{articles:[],queue:[],currentArticle:void 0}},methods:{refresh:function(){var e=Object(d["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(this.queue.length){e.next=5;break}return e.next=3,this.request("db.select",{engine:this.db,query:"\n select s.title as source, e.title, e.summary,\n strftime('%Y-%m-%dT%H:%M:%fZ', e.published) as published\n from FeedEntry e join FeedSource s\n on e.source_id = s.id order by e.published desc limit ".concat(this.limit)});case 3:this.articles=e.sent,this.queue=Object(a["a"])(this.articles);case 5:if(this.queue.length){e.next=7;break}return e.abrupt("return");case 7:this.currentArticle=this.queue.pop();case 8:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},mounted:function(){this.refresh(),setInterval(this.refresh,parseInt((1e3*this.refreshSeconds).toFixed(0)))}};r("a41f");o.render=u,o.__scopeId="data-v-919872a2";t["default"]=o}}]);
//# sourceMappingURL=chunk-e8078048.c3960daf.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,2 +0,0 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ed4988aa"],{"7c73c":function(e,t,r){"use strict";r("7f9b")},"7f9b":function(e,t,r){},"9e28":function(e,t,r){},c845:function(e,t,r){"use strict";r.r(t);var a=r("7a23"),s=Object(a["F"])("data-v-cac91b06");Object(a["u"])("data-v-cac91b06");var o={class:"image-carousel"},i={ref:"background",class:"background"},n={key:1,class:"row info-container"},h={class:"col-6 weather-container"},c={key:0},u={class:"col-6 date-time-container"};Object(a["s"])();var m=s((function(e,t,r,s,m,d){var l=Object(a["z"])("Loading"),f=Object(a["z"])("Weather"),w=Object(a["z"])("DateTime");return Object(a["r"])(),Object(a["e"])("div",o,[m.images.length?Object(a["f"])("",!0):(Object(a["r"])(),Object(a["e"])(l,{key:0})),Object(a["h"])("div",i,null,512),Object(a["h"])("img",{ref:"img",src:d.imgURL,alt:"Your carousel images",style:{display:m.images.length?"block":"none"}},null,12,["src"]),d._showDate||d._showTime?(Object(a["r"])(),Object(a["e"])("div",n,[Object(a["h"])("div",h,[d._showWeather?(Object(a["r"])(),Object(a["e"])(f,{key:1,"show-icon":d._showWeatherIcon,"show-summary":d._showWeatherSummary,"show-temperature":d._showTemperature,"icon-color":r.weatherIconColor,"icon-size":r.weatherIconSize,animate:d._animateWeatherIcon},null,8,["show-icon","show-summary","show-temperature","icon-color","icon-size","animate"])):(Object(a["r"])(),Object(a["e"])("span",c," "))]),Object(a["h"])("div",u,[d._showTime||d._showDate?(Object(a["r"])(),Object(a["e"])(w,{key:0,"show-date":d._showDate,"show-time":d._showTime,"show-seconds":d._showSeconds},null,8,["show-date","show-time","show-seconds"])):Object(a["f"])("",!0)])])):Object(a["f"])("",!0)])})),d=(r("a9e3"),r("96cf"),r("1da1")),l=r("3e54"),f=r("3a5e"),w=r("365a"),g=r("5b43"),p={name:"ImageCarousel",components:{Weather:g["default"],DateTime:w["default"],Loading:f["a"]},mixins:[l["a"]],props:{imgDir:{type:String,required:!0},refreshSeconds:{type:Number,required:!1,default:15},showDate:{type:Boolean,required:!1,default:!1},showTime:{type:Boolean,required:!1,default:!1},showSeconds:{type:Boolean,required:!1,default:!1},showWeather:{type:Boolean,required:!1,default:!1},showTemperature:{type:Boolean,required:!1,default:!0},showWeatherIcon:{type:Boolean,required:!1,default:!0},showWeatherSummary:{type:Boolean,required:!1,default:!0},weatherIconColor:{type:String,required:!1,default:"white"},weatherIconSize:{type:Number,required:!1,default:70},animateWeatherIcon:{required:!1,default:!0}},data:function(){return{images:[],currentImage:void 0,loading:!1}},computed:{imgURL:function(){var e=8008;return"backend.http"in this.$root.config&&"port"in this.$root.config["backend.http"]&&(e=this.$root.config["backend.http"].port),"//"+window.location.hostname+":"+e+this.currentImage},_showDate:function(){return this.parseBoolean(this.showDate)},_showTime:function(){return this.parseBoolean(this.showTime)},_showSeconds:function(){return this.parseBoolean(this.showSeconds)},_showTemperature:function(){return this.parseBoolean(this.showTemperature)},_showWeather:function(){return this.parseBoolean(this.showWeather)},_showWeatherIcon:function(){return this.parseBoolean(this.showWeatherIcon)},_showWeatherSummary:function(){return this.parseBoolean(this.showWeatherSummary)},_animateWeatherIcon:function(){return this.parseBoolean(this.animateWeatherIcon)}},methods:{refresh:function(){var e=this;return Object(d["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.images.length){t.next=10;break}return e.loading=!0,t.prev=2,t.next=5,e.request("utils.search_web_directory",{directory:e.imgDir,extensions:[".jpg",".jpeg",".png"]});case 5:e.images=t.sent,e.shuffleImages();case 7:return t.prev=7,e.loading=!1,t.finish(7);case 10:e.images.length&&(e.currentImage=e.images.pop());case 11:case"end":return t.stop()}}),t,null,[[2,,7,10]])})))()},onNewImage:function(){if(this.$refs.img&&(this.$refs.background.style["background-image"]="url("+this.imgURL+")",this.$refs.img.style.width="auto",this.$refs.img.width>this.$refs.img.height)){var e=this.$refs.img.width/this.$refs.img.height;4/3<=e<=16/9&&(this.$refs.img.style.width="100%"),e<=4/3&&(this.$refs.img.style.height="100%")}},shuffleImages:function(){for(var e=this.images.length-1;e>0;e--){var t=Math.floor(Math.random()*(e+1)),r=this.images[e];this.images[e]=this.images[t],this.images[t]=r}}},mounted:function(){this.$refs.img.addEventListener("load",this.onNewImage),this.$refs.img.addEventListener("error",this.refresh),this.refresh(),setInterval(this.refresh,Math.round(1e3*this.refreshSeconds))}};r("7c73c"),r("d233");p.render=m,p.__scopeId="data-v-cac91b06";t["default"]=p},d233:function(e,t,r){"use strict";r("9e28")}}]);
//# sourceMappingURL=chunk-ed4988aa.fb022ef7.js.map

File diff suppressed because one or more lines are too long

View file

@ -26,6 +26,18 @@ import Loading from "@/components/Loading";
import DateTime from "@/components/widgets/DateTime/Index"; import DateTime from "@/components/widgets/DateTime/Index";
import Weather from "@/components/widgets/Weather/Index"; import Weather from "@/components/widgets/Weather/Index";
/**
* In order to use the image carousel widget you have to specify one or more
* resource directories in your backend.http configuration - that's needed to
* specify the external directories that will be exported through the web server.
* Example:
*
* ```yaml
* backend.http:
* resources:
* carousel: /mnt/hd/photos/albums/carousel
* ```
*/
export default { export default {
name: "ImageCarousel", name: "ImageCarousel",
components: {Weather, DateTime, Loading}, components: {Weather, DateTime, Loading},

View file

@ -0,0 +1,111 @@
<template>
<div class="rss-news">
<div class="article" v-if="currentArticle">
<div class="source" v-text="currentArticle.source"></div>
<div class="title" v-text="currentArticle.title"></div>
<div class="published" v-text="new Date(currentArticle.published).toDateString() + ', ' + new Date(currentArticle.published).toTimeString().substring(0,5)"></div>
</div>
</div>
</template>
<script>
import Utils from "@/Utils";
/**
* In order to use this widget you need to configure the `backend.http.poll` backend to
* poll a list of RSS sources.
*/
export default {
name: "RssNews",
mixins: [Utils],
props: {
// Database engine string pointing to the source of the RSS feeds.
// If not otherwise configured, you should set this to
// `sqlite:///<HOME>/.local/share/platypush/feeds/rss.db`.
db: {
type: String,
required: true,
},
// Maximum number of items to be shown in a cycle.
limit: {
type: Number,
required: false,
default: 25,
},
// How long an entry should be displayed before moving to the next one.
refreshSeconds: {
type: Number,
required: false,
default: 15,
},
},
data: function() {
return {
articles: [],
queue: [],
currentArticle: undefined,
}
},
methods: {
refresh: async function() {
if (!this.queue.length) {
this.articles = await this.request('db.select', {
engine: this.db,
query: `
select s.title as source, e.title, e.summary,
strftime('%Y-%m-%dT%H:%M:%fZ', e.published) as published
from FeedEntry e join FeedSource s
on e.source_id = s.id order by e.published desc limit ${this.limit}`,
})
this.queue = [...this.articles]
}
if (!this.queue.length)
return
this.currentArticle = this.queue.pop()
},
},
mounted: function() {
this.refresh()
setInterval(this.refresh, parseInt((this.refreshSeconds*1000).toFixed(0)))
},
}
</script>
<style lang="scss" scoped>
.rss-news {
width: 100%;
height: 100%;
display: flex;
align-items: center;
.article {
width: 90%;
padding: 0 2em;
.source {
font-size: 1.7em;
font-weight: bold;
margin-bottom: .5em;
}
.title {
font-size: 1.7em;
font-weight: normal;
margin-bottom: .5em;
}
.published {
text-align: right;
font-size: 1em;
}
}
}
</style>

View file

@ -134,7 +134,6 @@ export default {
<style> <style>
html { html {
overflow: auto; overflow: auto !important;
} }
</style> </style>