Compare commits

..

No commits in common. "698c01ac07b36ea2140ff745008ab0d0f91ed78d" and "42c92e6047a224c423222fbf1a6b8428064233ca" have entirely different histories.

6 changed files with 53 additions and 99 deletions

1
.gitignore vendored
View File

@ -2,4 +2,3 @@ sources/
.idea
node_modules
output/
output/*

3
app.js
View File

@ -43,8 +43,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`)
console.log(`Example app listening at http://localhost:${port}`)
})
module.exports = app;

View File

@ -1,9 +0,0 @@
#!/bin/bash
echo " _____ convert the markdown on output with pandoc ____"
pandoc output/export_hebdo.md -t html -s -o output/export_hebdo.html
pandoc output/export_tags.md -t html -s -o output/export_tags.html
pandoc output/export_all.md -t html -s -o output/export_all.html
ls -larth output/*.html
echo " _____ ok files converted to html ____"

View File

@ -1,10 +0,0 @@
#!/bin/bash
echo " _____ import files from ~/.var/app/org.gnome.GTG/data/gtg ____"
cp ~/.var/app/org.gnome.GTG/data/gtg/*.xml ./sources
ls -larth sources/*.xml
echo " _____ ok files imported ____"
echo " _____ you can convert with running 'node app.js' ____"
echo " _____ and open http://localhost:3300/ ____"

View File

@ -8,7 +8,6 @@ var router = express.Router();
let convertFiles = true;
// let convertFiles = false;
let computeDataOnExtract = true;
// let computeDataOnExtract = false;
let jsonAllData = {
tasks : {},
@ -20,32 +19,20 @@ 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) {
@ -59,8 +46,6 @@ router.get('/', async function (req, res, next) {
res.render('index', {
title: "Conversion de GTG tâches",
json : jsonAllData,
markdown : markdownExportData,
weeklyDevReport,
getPercent,
computeBgColorOnProportionOfOpenTasks,
getPercentOfOpenTasks
@ -223,56 +208,49 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
return result;
}
let datenow = new Date();
let markdownExportData = ''
let weeklyDevReport = ''
let dataTagsMd = `# Export de Tâches GTG \n date: ` + datenow.toLocaleString()
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
weeklyDevReport += `\n# Rapport hebdomadaire de dev `;
weeklyDevReport += `\r\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
dataTagsMd += `\n# Rapport hebdomadaire de dev `;
dataTagsMd += `\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
jsonAllData.stats.listDevWeeklyClosed.map(elem => {
weeklyDevReport += `\n* ${elem.title}`;
dataTagsMd += `\n * ${elem.title}`;
})
markdownExportData += `\n ${weeklyDevReport}`;
markdownExportData += `\n---`;
markdownExportData += `\n `;
markdownExportData += `\n# Rapport des tâches durant les 7 derniers jours `;
markdownExportData += `\n `;
markdownExportData += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
markdownExportData += `\n `;
dataTagsMd += `\n `;
dataTagsMd += `\n---`;
dataTagsMd += `\n `;
dataTagsMd += `\n# Rapport des tâches durant les 7 derniers jours `;
dataTagsMd += `\n `;
dataTagsMd += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
dataTagsMd += `\n `;
jsonAllData.stats.listClosedWeekly.map(elem => {
markdownExportData += `\n * ${elem.title}`;
dataTagsMd += `\n * ${elem.title}`;
})
markdownExportData += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
markdownExportData += `\n `;
dataTagsMd += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
dataTagsMd += `\n `;
jsonAllData.stats.listOpenWeekly.map(elem => {
markdownExportData += `\n * ${elem.title}`;
dataTagsMd += `\n * ${elem.title}`;
})
markdownExportData += `\n--- `;
dataTagsMd += `\n--- `;
// fichier de rapport des tâches fermées durant les 31 derniers jours
markdownExportData += `\n# Rapport des autres tâches durant le mois `;
markdownExportData += `\n `;
markdownExportData += `\n## ${jsonAllData.stats.listClosedMonthly.length} ont été fermées `;
markdownExportData += `\n `;
jsonAllData.stats.listClosedMonthly.map(elem => {
markdownExportData += `\n * ${elem.title}`;
})
markdownExportData += `\n## ${jsonAllData.stats.listOpenMonthly.length} ont été ouvertes `;
markdownExportData += `\n `;
jsonAllData.stats.listOpenMonthly.map(elem => {
markdownExportData += `\n * ${elem.title}`;
})
dataTagsMd += `\n# Rapport des autres tâches durant le mois `;
dataTagsMd += `\n `;
dataTagsMd += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
dataTagsMd += `\n `;
markdownExportData += `\n--- `;
dataTagsMd += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
dataTagsMd += `\n `;
dataTagsMd += `\n--- `;
// stats de fermeture des tâches
markdownExportData += `\n# Stats de fermeture des tâches `;
markdownExportData += `\n `;
markdownExportData += `\n--- `;
markdownExportData += `\n `;
markdownExportData += `\n# Export de toutes les ${jsonAllData.stats.listOpen.length} tâches ouvertes GTG \n `;
markdownExportData += `\n `;
dataTagsMd += `\n# Stats de fermeture des tâches `;
dataTagsMd += `\n `;
dataTagsMd += `\n--- `;
dataTagsMd += `\n `;
dataTagsMd += `\n# Export de toutes les ${jsonAllData.stats.listOpen.length} tâches ouvertes GTG \n `;
dataTagsMd += `\n `;
// jsonAllData.stats.listOpen.map(elem => {
// dataTagsMd += `\n## ${elem.title} `;
@ -282,32 +260,32 @@ function exportToMarkdown(res) {
// dataTagsMd += `\n prévu pour : ${elem.duedate | ''} `;
// dataTagsMd += `\n ${elem.content} `;
// })
markdownExportData += `\n--- `;
markdownExportData += `\n `;
markdownExportData += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
markdownExportData += `\n `;
dataTagsMd += `\n--- `;
dataTagsMd += `\n `;
dataTagsMd += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
dataTagsMd += `\n `;
//
// jsonAllData.stats.listClosed.map(elem=>{
// dataTagsMd += `\n * ${elem.title} `;
// })
markdownExportData += `\n `;
markdownExportData += `\n# Export de Tags GTG \n `;
markdownExportData += `\n `;
markdownExportData += `\n `;
dataTagsMd += `\n `;
dataTagsMd += `\n# Export de Tags GTG \n `;
dataTagsMd += `\n `;
dataTagsMd += `\n `;
let sortedTagsByTitle = _.sortBy(jsonAllData.tags.tagstore.tag, [(o) => {
o["$"].name
}])
sortedTagsByTitle.map(elem => {
markdownExportData += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
dataTagsMd += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
})
markdownExportData += `\n `;
markdownExportData += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
dataTagsMd += `\n `;
dataTagsMd += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
// write file to disk
fs.writeFile(`output/export_hebdo.md`, markdownExportData, `utf8`, (err) => {
fs.writeFile(`output/export_tags.md`, dataTagsMd, `utf8`, (err) => {
if (err) {
console.log(`Error writing file: ${err}`);

View File

@ -12,9 +12,6 @@ block content
li #{json.stats.listClosed.length} fermées
li #{json.stats.listClosedWeekly.length} fermées cette semaine
li #{json.stats.listClosedMonthly.length} fermées ce mois-ci
section.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.
@ -39,7 +36,7 @@ block content
if t.tasksListIsActiveByTitle
span.text-right.tasks #{t.tasksListIsActiveByTitle.length}
span.text-right.tasks(class=computeBgColorOnProportionOfOpenTasks(getPercent(t.tasksListIsActiveByTitle.length, t.tasks))) #{getPercent(t.tasksListIsActiveByTitle.length, t.tasks)} %
span.text-right.tasks #{getPercent(t.tasksListIsActiveByTitle.length,json.stats.listOpen.length )} %
span.text-right.tasks #{getPercentOfOpenTasks(t.tasksListIsActiveByTitle.length)} %
button.text-right.toggle voir
ul
each activetask in t.tasksListIsActiveByTitle