diff --git a/routes/index.js b/routes/index.js index 826ee07..aae316b 100644 --- a/routes/index.js +++ b/routes/index.js @@ -5,6 +5,9 @@ var parseString = require("xml2js").parseString; var router = express.Router(); var fileToOpen = 'gtg_tasks' +// const convertFiles = true; +const convertFiles = false; + const json = { tasks : {}, projects : {}, @@ -16,17 +19,24 @@ const json = { */ router.get('/', async function (req, res, next) { + if(convertFiles){ + convertOneXmlToJson('gtg_tasks',res) convertOneXmlToJson('tags',res) convertOneXmlToJson('projects',res) + }else{ + console.log('================== conversion de fichiers désactivée dans index.js ================== ') + } // récupérer le contenu des json fs.readFile(`sources/tags_gtg.json`, "utf-8", function (err, data) { if (err) console.log(err); - json.tags = data + json.tags = JSON.parse(data) + console.log('json', json) + res.render('index', {title: "Conversion de GTG tâches", json: json}) }); - res.render('index', {title: "Conversion de GTG tâches", json: json}) + }); @@ -34,7 +44,6 @@ router.get('/', async function (req, res, next) { function convertOneXmlToJson(fileToOpen,res){ fs.readFile(`sources/${fileToOpen}.xml`, "utf-8", function (err, data) { if (err) console.log(err); - console.log(data); const results = transformToJson(data, fileToOpen, res) console.log('fichier converti en json', fileToOpen) diff --git a/views/index.jade b/views/index.jade index 3d63b9a..9ad292e 100644 --- a/views/index.jade +++ b/views/index.jade @@ -3,3 +3,8 @@ extends layout block content h1= title p Welcome to #{title} + section.tags + h2= "Tags" + ul + each t in json.tags.tagstore + li= t.$.name