mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 20:49:54 +00:00
newsfeed: showAsList implemented.
This commit is contained in:
parent
aa3a3bdf16
commit
3e96e8b3f5
@ -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;
|
||||||
|
}
|
||||||
|
@ -129,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,
|
||||||
@ -137,7 +141,7 @@ Module.register("newsfeed", {
|
|||||||
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: this.newsItems
|
items: items
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -247,7 +251,6 @@ Module.register("newsfeed", {
|
|||||||
this.sendNotification("NEWS_FEED_UPDATE", { items: updatedItems });
|
this.sendNotification("NEWS_FEED_UPDATE", { items: updatedItems });
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.warn(newsItems);
|
|
||||||
this.newsItems = newsItems;
|
this.newsItems = newsItems;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,56 +1,56 @@
|
|||||||
{% if loaded %}
|
{% if loaded %}
|
||||||
{% if config.showAsList %}
|
{% if config.showAsList %}
|
||||||
<ul class="newsfeed-list">
|
<ul class="newsfeed-list">
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<li>
|
<li>
|
||||||
{% if (config.showSourceTitle and item.sourceTitle) or config.showPublishDate %}
|
{% if (config.showSourceTitle and item.sourceTitle) or config.showPublishDate %}
|
||||||
<div class="newsfeed-source light small dimmed">
|
<div class="newsfeed-source light small dimmed">
|
||||||
{% if item.sourceTitle and config.showSourceTitle %}
|
{% if item.sourceTitle and config.showSourceTitle %}
|
||||||
{{ item.sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
|
{{ item.sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config.showPublishDate %}
|
{% if config.showPublishDate %}
|
||||||
{{ item.publishDate }}:
|
{{ item.publishDate }}:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
|
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</div>
|
</div>
|
||||||
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
|
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
|
||||||
{% if config.truncDescription %}
|
{% if config.truncDescription %}
|
||||||
{{ item.description | truncate(config.lengthDescription) }}
|
{{ item.description | truncate(config.lengthDescription) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ item.description }}
|
{{ item.description }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% 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">
|
||||||
{% if sourceTitle and config.showSourceTitle %}
|
{% if sourceTitle and config.showSourceTitle %}
|
||||||
{{ sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
|
{{ sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config.showPublishDate %}
|
{% if config.showPublishDate %}
|
||||||
{{ publishDate }}:
|
{{ publishDate }}:
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
|
||||||
|
{{ title }}
|
||||||
|
</div>
|
||||||
|
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
|
||||||
|
{% if config.truncDescription %}
|
||||||
|
{{ description | truncate(config.lengthDescription) }}
|
||||||
|
{% else %}
|
||||||
|
{{ description }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
|
|
||||||
{{ title }}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
|
{% endif %}
|
||||||
{% if config.truncDescription %}
|
|
||||||
{{ description | truncate(config.lengthDescription) }}
|
|
||||||
{% else %}
|
|
||||||
{{ description }}
|
|
||||||
{% 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