Commit 4b74adb2 authored by yPhil's avatar yPhil
Browse files

Reading XML file, loosely testing json/xml, converting XML to Json OK

parent a01cd7bf
This diff is collapsed.
......@@ -39,7 +39,8 @@
"npm": "^7.5.2",
"pm2": "^4.5.4",
"request": "^2.88.2",
"sanitize": "^2.1.0"
"sanitize": "^2.1.0",
"xml2json": "^0.12.0"
},
"devDependencies": {
"mocha": "^8.3.0",
......
const express = require('express'),
path = require('path'),
index = require('./routes/router'),
router = require('./routes/router'),
fs = require('fs'),
pjson = require('./package.json'),
bodyParser = require('body-parser'),
......@@ -24,7 +24,7 @@ app.use('/favicons', express.static(path.join(__dirname, pjson.FAVICONS_CACHE_DI
app.use('/static', express.static(path.join(__dirname, 'public')));
app.use('/bower', express.static(path.join(__dirname, 'bower_components')));
app.use('/', index);
app.use('/', router);
app.use(helmet.originAgentCluster());
app.use(helmet.noSniff());
......
......@@ -300,6 +300,8 @@ var PTL = (function() {
PTL.tab.empty(function() {
PTL.tab.populate(JSON.parse(e.target.result), true);
});
} else {
PTL.util.importNetVibes(e.target.result);
}
};
})(f);
......
......@@ -27,7 +27,7 @@ PTL.tab = {
});
$tabs.on('mouseup', '.ui-tabs-active a', function(e){
console.log('plop!: %s (%s)');
// console.log('plop!: %s (%s)');
e.preventDefault();
if (e.which === 1) {
PTL.dialog.editGroup($(this));
......
This diff is collapsed.
const request = require('request'),
zlib = require('zlib'),
FeedParser = require('feedparser');
exports.getFeed = getFeed;
exports.getFeed = getFeed;
function maybeDecompress (res, encoding) {
var decompress;
......@@ -77,7 +78,7 @@ function getFeed (urlfeed, callback) {
})
.on ('error', function (err) {
var meta = this.meta;
console.error('HUUM (%s) %s %s', err.message, meta.title, urlfeed);
console.error('Error reading feed [%s] (%s)', err.message, urlfeed);
callback (err.message);
})
.on ('end', function () {
......
......@@ -11,7 +11,7 @@ const express = require('express'),
pjson = require('../package.json'),
Iconv = require('iconv').Iconv,
sanitize = require('sanitize').middleware,
zlib = require('zlib'),
parser = require('xml2json'),
morgan = require('morgan');
require('events').EventEmitter.defaultMaxListeners = 15;
......@@ -22,8 +22,45 @@ process.on('uncaughtException', function(err) {
console.error('### Pétrolette uncaughtException: %s', err);
});
var options = {
object: false,
reversible: false,
coerce: true,
sanitize: false,
trim: false,
arrayNotation: false,
alternateTextNode: false
};
router.use(sanitize);
router.get('/parser', function (req, res) {
console.error('plop!!!: %s (%s)', req.query.x);
// var xml = req.query.xml;
// // console.error('xml: %s (%s)',xml, req);
// var json = parser.toJson(xml);
// if (json) {
// res.send(json);
// } else if (err) {
// console.log('err: %s (%s)', err, res);
// res.status(500).send(err.code);
// } else {
// res.status(500).send('Bad file');
// }
// var xml = "<foo attr=\"value\">bar</foo>";
// console.error("##### input -> %s", xml, req.query.plop);
// xml to json
// console.error("##### to json -> %s", json);
});
router.get('/feed', function(req, res) {
var dnsreq = request(req.query.feedurl);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment