Skip to content

Commit

Permalink
Docker build for latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
colloqi committed Feb 16, 2023
1 parent a1e08c1 commit 262b091
Show file tree
Hide file tree
Showing 9 changed files with 389 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Server code to manage piSignage players in a LAN or Private Network or to setup

1. Change to pisignage-server directory where you have pulled the code last time
2. Issue the command `git pull origin master`
***IMPORTANT: If you are upadating from before 24 Nov 2016, after git pull, please change the uri variable in config/env/development.js to 'mongodb://localhost/pisignage-dev' to retain the old data***
***IMPORTANT: If you are updating from before 24 Nov 2016, after git pull, please change the uri variable in config/env/development.js to 'mongodb://localhost/pisignage-dev' to retain the old data***
3. Apply your code changes if any
4. rm package-lock.json
5. rm -rf node_modules (entire directory and its contents)
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ exports.getSettings = function(req,res) {
} else {
var obj = data.toObject()
obj.serverIp = serverIp;
exec('git log -1 --format=%cd;git rev-parse HEAD',function(err,stdout,stderr){
exec('git log -1 --format="%cd" && git log -1 --format="%H"',function(err,stdout,stderr){
if(err || stderr){
obj.date = 'N/A';
obj.version = 'N/A';
console.log('There was an error obtaining the current server version from git:');
console.log(stderr);
}else{
stdout = stdout.trim().split('\n');
obj.date = [stdout[0].split(' ')[1],stdout[0].split(' ')[2],stdout[0].split(' ')[4]].join(' ');
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/players.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ exports.upload = function (cpuId, filename, data) {
// else
// console.log("info","Forever Log file saved for player : "+cpuId);
})
} else if (path.extname(filename) == '.log' && filename != "forever_out.log") {
} else if (path.extname(filename) == '.log' && filename.indexOf('forever_out.log')===-1 ) {
try {
logData = JSON.parse(data);
logData.installation = player.installation;
Expand Down
104 changes: 104 additions & 0 deletions app/controllers/rss-feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
'use strict';

var FeedParser = require('feedparser'),
axios = require('axios'),
rest = require('../others/restware');

exports.getFeeds = function(req,res){
var link = decodeURIComponent(req.query['link']),
feedlimit = req.query['feedlimit'] || 100;

if (!link)
return rest.sendError(res, '**** Please provide a link to fetch RSS as query parameter link=\<link\>');

if (link.indexOf("://") == -1) {
link = 'http://' + link;
}

var reqt = axios({
method: 'get',
url: link,
responseType: 'stream'
}),
feedparser = new FeedParser({"feedUrl": link}),
index = 0,
news = [];

res.replySent = false;

reqt
.then(function (response) {
var stream = response.data;

stream.setEncoding('utf8');

if (response.status !== 200) {
stream.emit('error', new Error('Bad status code, can\'t fetch feeds from given URL'));
}
else {
// The response `body` -- res.body -- is a stream
stream.pipe(feedparser);
}
})
.catch(function (error) {
// handle error
if (!res.replySent) {
res.replySent = true;
return rest.sendError(res, '**** request error, please check RSS feed URL', error);
}
})
.then(function () {
// always executed
});

// reqt.on('error', function (error) {
// if (!res.replySent) {
// res.replySent = true;
// return rest.sendError(res, '**** request error, please check RSS feed URL', error);
// }
// });

// reqt.on('response', function (resp) {
// var stream = this;
//
// resp.setEncoding('utf8');
//
// if (resp.statusCode != 200)
// return this.emit('error', new Error('Bad status code, can\'t fetch feeds from given URL'));
//
// stream.pipe(feedparser);
// });

feedparser.on('error', function(error) {
if (!res.replySent) {
res.replySent = true;
return rest.sendError(res, '**** feedparser error, please check RSS feed URL', error);
}
});

feedparser.on('readable', function() {
var stream = this,
meta = this.meta,
item;

while (item = stream.read()) {
if (item.title)
item.title = item.title.replace(/'/g, "`")
if (item.description)
item.description = item.description.replace(/'/g, "`")
if(news.length < feedlimit)
news.push(item);
else
break;
}
});
feedparser.on('end',function(){
if (!res.replySent) {
res.replySent = true;
return rest.sendSuccess(res, 'RSS feeds', news);
}
})
}



2 changes: 2 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var assets = require('../app/controllers/assets'),
players = require('../app/controllers/players'),
groups = require('../app/controllers/groups'),
labels = require('../app/controllers/labels'),
rssFeed = require('../app/controllers/rss-feed'),
licenses = require('../app/controllers/licenses');
//gcalAuthorize = require('../app/controllers/gcal-authorize');

Expand Down Expand Up @@ -75,6 +76,7 @@ router.get('/api/labels/:label', labels.getObject)
router.post('/api/labels', labels.createObject);
router.post('/api/labels/:label', labels.updateObject);
router.delete('/api/labels/:label', labels.deleteObject);
router.get('/api/rssfeed', rssFeed.getFeeds);

require('../app/controllers/licenses').getSettingsModel(function(err,settings){
var uploadLicense = multer({dest:(config.licenseDirPath+(settings.installation || "local"))})
Expand Down

0 comments on commit 262b091

Please sign in to comment.