Compare commits
6 Commits
2a594e0974
...
main
Author | SHA1 | Date | |
---|---|---|---|
f515b9d969 | |||
f22e8199e4 | |||
85ff4c0c6c | |||
d6f93f2f42 | |||
5d4d318a50 | |||
b2166a8425 |
@ -7,7 +7,6 @@
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
|
||||
Module.register('MMM-Wordpress', {
|
||||
defaults: {
|
||||
updateInterval: 600000, // 10 minutes
|
||||
@ -30,7 +29,7 @@ Module.register('MMM-Wordpress', {
|
||||
const numberOfPosts = this.config.numberOfPosts;
|
||||
|
||||
//hier müssen die posts noch rein!
|
||||
this.sendSocketNotification('GET_POSTS', { url, numberOfPosts });
|
||||
this.sendSocketNotification('GET_POSTS', { url, posts, numberOfPosts });
|
||||
},
|
||||
|
||||
socketNotificationReceived: function(notification, payload) {
|
||||
@ -48,7 +47,8 @@ Module.register('MMM-Wordpress', {
|
||||
for (let i = 0; i < posts.length; i++) {
|
||||
const post = posts[i];
|
||||
const postElement = document.createElement('div');
|
||||
postElement.innerHTML = `<h2>${this.stripTags(post.title.rendered)}</h2><p>${this.stripTags(post.excerpt.rendered)}</p>`;
|
||||
//postElement.innerHTML = `<h2>${this.stripTags(post.title.rendered)}</h2><p>${this.stripTags(post.excerpt.rendered)}</p>`;
|
||||
postElement.innerHTML = `<h2>${this.stripTags(post.title.rendered)}</h2><p>${this.stripTags(post.content.rendered)}</p>`;
|
||||
wrapper.appendChild(postElement);
|
||||
}
|
||||
} else {
|
||||
|
23
README.md
23
README.md
@ -1,5 +1,28 @@
|
||||
# Info
|
||||
|
||||
This module for Magic Mirror should display posts from a WordPress site.
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
```bash
|
||||
git clone https://github.com/tbuss/MMM-Wordpress.git
|
||||
cd MMM-Wordpress
|
||||
npm install
|
||||
```
|
||||
|
||||
# Config
|
||||
|
||||
Put this in your config.js
|
||||
|
||||
```js
|
||||
{
|
||||
module: 'MMM-Wordpress',
|
||||
position: 'bottom_bar', // or any other position
|
||||
config: {
|
||||
updateInterval: 10*60*1000, // 10 minutes
|
||||
url: 'https://www.your_wordpress.url',
|
||||
numberOfPosts: 5
|
||||
}
|
||||
},
|
||||
```
|
@ -7,9 +7,11 @@ module.exports = NodeHelper.create({
|
||||
},
|
||||
|
||||
socketNotificationReceived: function(notification, payload) {
|
||||
console.log('Notification!');
|
||||
if (notification === 'GET_POSTS') {
|
||||
const { url, numberOfPosts } = payload;
|
||||
const apiUrl = `${url}/wp-json/wp/v2/posts?per_page=${numberOfPosts}`;
|
||||
console.log('Notification: GET_POSTS');
|
||||
const { url, posts, numberOfPosts } = payload;
|
||||
const apiUrl = `${url}/wp-json/wp/v2/${posts}?per_page=${numberOfPosts}`;
|
||||
|
||||
request.get(apiUrl, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
Reference in New Issue
Block a user