route to convert xml files
This commit is contained in:
parent
cd87d78f06
commit
698c01ac07
1
app.js
1
app.js
@ -44,6 +44,7 @@ const port = 3300
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`gtg2json app listening at http://localhost:${port}`)
|
||||
console.log(`convert your Getting things gnomes files at http://localhost:${port}/xml`)
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
|
@ -8,6 +8,7 @@ var router = express.Router();
|
||||
let convertFiles = true;
|
||||
// let convertFiles = false;
|
||||
let computeDataOnExtract = true;
|
||||
// let computeDataOnExtract = false;
|
||||
|
||||
let jsonAllData = {
|
||||
tasks : {},
|
||||
@ -19,20 +20,32 @@ let jsonAllData = {
|
||||
/**
|
||||
* obtenir la liste de tags que l'on a entré
|
||||
*/
|
||||
router.get('/xml', async function (req, res, next) {
|
||||
fs.stat('sources/gtg_tasks.xml', function(err, stat) {
|
||||
if(err == null) {
|
||||
console.log('File sources/gtg_tasks.xml exists');
|
||||
} else if(err.code === 'ENOENT') {
|
||||
// file does not exist
|
||||
res.send('le fichier sources/gtg_tasks.xml est introuvable. Impossible d en extraire des infos. Importez d abord les fichiers de données xml de Getting Things Gnome dans le dossier sources')
|
||||
} else {
|
||||
console.log('Some other error: ', err.code);
|
||||
}
|
||||
});
|
||||
|
||||
convertOneXmlToJson('gtg_tasks', res)
|
||||
convertOneXmlToJson('tags', res)
|
||||
convertOneXmlToJson('projects', res)
|
||||
console.log('success conversion xml')
|
||||
res.redirect('/')
|
||||
})
|
||||
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
|
||||
jsonAllData.tags = require('../sources/tags_gtg.json')
|
||||
jsonAllData.tasks = require('../sources/gtg_tasks_gtg.json')
|
||||
if(!jsonAllData.tasks){
|
||||
res.redirect('/xml')
|
||||
}
|
||||
|
||||
if (computeDataOnExtract) {
|
||||
|
||||
@ -47,6 +60,7 @@ router.get('/', async function (req, res, next) {
|
||||
title: "Conversion de GTG tâches",
|
||||
json : jsonAllData,
|
||||
markdown : markdownExportData,
|
||||
weeklyDevReport,
|
||||
getPercent,
|
||||
computeBgColorOnProportionOfOpenTasks,
|
||||
getPercentOfOpenTasks
|
||||
@ -210,17 +224,18 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
|
||||
}
|
||||
let datenow = new Date();
|
||||
let markdownExportData = ''
|
||||
let weeklyDevReport = ''
|
||||
function exportToMarkdown(res) {
|
||||
|
||||
|
||||
markdownExportData = `# Export de Tâches GTG \n date: ` + datenow.toLocaleString()
|
||||
// fichier de rapport des tâches fermées durant les 7 derniers jours
|
||||
markdownExportData += `\n# Rapport hebdomadaire de dev `;
|
||||
markdownExportData += `\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
|
||||
weeklyDevReport += `\n# Rapport hebdomadaire de dev `;
|
||||
weeklyDevReport += `\r\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
|
||||
jsonAllData.stats.listDevWeeklyClosed.map(elem => {
|
||||
markdownExportData += `\n * ${elem.title}`;
|
||||
weeklyDevReport += `\n* ${elem.title}`;
|
||||
})
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n ${weeklyDevReport}`;
|
||||
markdownExportData += `\n---`;
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n# Rapport des tâches durant les 7 derniers jours `;
|
||||
|
@ -13,7 +13,8 @@ block content
|
||||
li #{json.stats.listClosedWeekly.length} fermées cette semaine
|
||||
li #{json.stats.listClosedMonthly.length} fermées ce mois-ci
|
||||
section.markdown
|
||||
article(language="md")= markdown
|
||||
h2 Rapport de dev de la semaine
|
||||
article(language="md")= weeklyDevReport
|
||||
section.tags
|
||||
h2 #{json.tags.tagstore.tag.length} Tags
|
||||
p maximum de #{json.stats.maxTasksCountPerTag} tâches pour un tag.
|
||||
|
Loading…
Reference in New Issue
Block a user