mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
Merge pull request #2580 from r3wald/feature/newsfeed-show-as-list
feature: show newsfeed as list
This commit is contained in:
commit
8be4604c97
@ -21,6 +21,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel,
|
|||||||
- Added custom-properties for gaps around body and between modules
|
- Added custom-properties for gaps around body and between modules
|
||||||
- Added test case for recurring calendar events
|
- Added test case for recurring calendar events
|
||||||
- Added new Environment Canada provider for default WEATHER module (weather data for Canadian locations only)
|
- Added new Environment Canada provider for default WEATHER module (weather data for Canadian locations only)
|
||||||
|
- Added list view for newsfeed module.
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
@ -12,3 +12,12 @@ iframe.newsfeed-fullarticle {
|
|||||||
bottom: inherit;
|
bottom: inherit;
|
||||||
top: -90px;
|
top: -90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.newsfeed-list {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsfeed-list li {
|
||||||
|
text-align: justify;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@ Module.register("newsfeed", {
|
|||||||
encoding: "UTF-8" //ISO-8859-1
|
encoding: "UTF-8" //ISO-8859-1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
showAsList: false,
|
||||||
showSourceTitle: true,
|
showSourceTitle: true,
|
||||||
showPublishDate: true,
|
showPublishDate: true,
|
||||||
broadcastNewsFeeds: true,
|
broadcastNewsFeeds: true,
|
||||||
@ -128,6 +129,10 @@ Module.register("newsfeed", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const item = this.newsItems[this.activeItem];
|
const item = this.newsItems[this.activeItem];
|
||||||
|
const items = this.newsItems.map(function (item) {
|
||||||
|
item.publishDate = moment(new Date(item.pubdate)).fromNow();
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loaded: true,
|
loaded: true,
|
||||||
@ -135,7 +140,8 @@ Module.register("newsfeed", {
|
|||||||
sourceTitle: item.sourceTitle,
|
sourceTitle: item.sourceTitle,
|
||||||
publishDate: moment(new Date(item.pubdate)).fromNow(),
|
publishDate: moment(new Date(item.pubdate)).fromNow(),
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.description
|
description: item.description,
|
||||||
|
items: items
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -192,7 +198,6 @@ Module.register("newsfeed", {
|
|||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
newsItems.forEach((item) => {
|
newsItems.forEach((item) => {
|
||||||
//Remove selected tags from the beginning of rss feed items (title or description)
|
//Remove selected tags from the beginning of rss feed items (title or description)
|
||||||
if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") {
|
if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") {
|
||||||
|
@ -1,4 +1,34 @@
|
|||||||
{% if loaded %}
|
{% if loaded %}
|
||||||
|
{% if config.showAsList %}
|
||||||
|
<ul class="newsfeed-list">
|
||||||
|
{% for item in items %}
|
||||||
|
<li>
|
||||||
|
{% if (config.showSourceTitle and item.sourceTitle) or config.showPublishDate %}
|
||||||
|
<div class="newsfeed-source light small dimmed">
|
||||||
|
{% if item.sourceTitle and config.showSourceTitle %}
|
||||||
|
{{ item.sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if config.showPublishDate %}
|
||||||
|
{{ item.publishDate }}:
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
|
||||||
|
{{ item.title }}
|
||||||
|
</div>
|
||||||
|
{% if config.showDescription %}
|
||||||
|
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
|
||||||
|
{% if config.truncDescription %}
|
||||||
|
{{ item.description | truncate(config.lengthDescription) }}
|
||||||
|
{% else %}
|
||||||
|
{{ item.description }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
<div>
|
<div>
|
||||||
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
|
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
|
||||||
<div class="newsfeed-source light small dimmed">
|
<div class="newsfeed-source light small dimmed">
|
||||||
@ -23,6 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% elseif error %}
|
{% elseif error %}
|
||||||
<div class="small dimmed">
|
<div class="small dimmed">
|
||||||
{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }}
|
{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user