Permalink
Browse files

First patch includes action script, for Tela Social Mediator, that co…

…nverts XML FISL to JSON. Then the other part is a 'static' load with localhost:8888/static/grid/index.html with system date set to July, 3th - for tests. http server should serve from this directory '.' because Grid HTML app will load ./channel and ./static files.
  • Loading branch information...
taboca committed Jun 3, 2013
1 parent 9c831ce commit f4bc8d0750fdad5a484bf0d87f6070272863b084
@@ -0,0 +1,92 @@
var sys = require("sys"),
pathFS = require("path"),
fs = require("fs")
url = require("url"),
http = require("http"),
xml2js = require('xml2js'),
out = require('../3rdparty/stdout-2-json/stdout-2-json');
var timer = null;
function start(name, appPath) {
var href = 'http://fisl.org.br/14/papers_ng/public/fast_grid?event_id=3';
var buffer = "";
var host = url.parse(href).host;
var path = url.parse(href).pathname;
var port = url.parse(href).port;
var search ='';
var searchProbe = url.parse(href).search;
if(typeof searchProbe != 'undefined') {
if(searchProbe) {
search=searchProbe;
}
}
var options = {
host: host,
port: port,
method: 'GET',
path: path+search
};
var strOut = "";
var accept = false;
var request = http.request(options);
request.end();
// This is network error
request.on('error', function (e) {
out.senderr({'result':'error','type':'offline','data':e} );
});
request.on('response', function (res) {
var strOut = "";
res.setEncoding('binary')
res.on('data', function (buffer) {
strOut += buffer;
});
res.on('end', function () {
var filePath = pathFS.join( __dirname, '..', appPath, 'channel', name+'.xml');
fs.writeFile(filePath, strOut, 'binary', function(err){
if (err) {
out.senderr({'result':'error', 'payload': err});
throw err;
}
var parser = new xml2js.Parser({'mergeAttrs':true});
var that=this;
parser.addListener('end', function(result) {
for(var i=0;i<result.response.slots[0].slot.length;i++) {
console.log('-------'+JSON.stringify(result.response.slots[0].slot[i].id));
result.response.slots[0].slot[i].title='';
result.response.slots[0].slot[i].abstract='';
//result.response.slots[i].abstract='';
}
var strOut = JSON.stringify(result.response.slots);
var filePath = pathFS.join( __dirname, '..', appPath, 'channel', name+'.json');
fs.writeFile(filePath, strOut, 'binary', function(err){
if (err) {
out.senderr({'result':'error', 'payload': err});
throw err;
}
out.send({'result':'ok'});
clearTimeout(timer);
});
});
var filePath = pathFS.join( __dirname, '..', appPath, 'channel', name+'.xml');
fs.readFile( filePath, function(err, data) {
parser.parseString(data);
});
});
});
})
}
out.send({'result':'note', 'data':'Will open + '+ process.argv[3] } );
timer = setTimeout(function () { out.send({'result':'expired'}) },15000);
start(process.argv[2], process.argv[3], process.argv[4]);
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,19 @@
{
"rules": [
{
"about":"start",
"function":"spawnJS",
"data":{"value":"transcode-fisl-json.js","about":"fisl"}, "to":"next"
},
{
"about":"next",
"function":"timer",
"data":{"value":30000},
"to":"start"
}
]
}
View
@@ -0,0 +1,19 @@
{
"rules": [
{ "about":"start",
"function":"timer",
"data":{"value":1000},
"to":"start/checked"
},
{
"about":"start/checked",
"function":"httpserver",
"data":{},
"to":"start"
}
]
}
View
@@ -0,0 +1,2 @@
html, body { margin:0; padding:0; overflow:hidden }
View
Binary file not shown.
View
@@ -0,0 +1,24 @@
* { color: white }
h2 { clear:both; padding:.1em; padding-left:1em; margin:.2em }
.dayStamp {
text-align:right;
}
.mark {
color:lightblue;
}
.item {
font-weight:normal;
padding-top:1em;
}
.title {
text-align:center;
padding:.6em;
line-height:1.5em;
}
Oops, something went wrong.

0 comments on commit f4bc8d0

Please sign in to comment.