Compare commits
3 Commits
42c92e6047
...
698c01ac07
Author | SHA1 | Date | |
---|---|---|---|
698c01ac07 | |||
cd87d78f06 | |||
79bf2f4847 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ sources/
|
|||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
output/
|
output/
|
||||||
|
output/*
|
||||||
|
3
app.js
3
app.js
@ -43,7 +43,8 @@ const port = 3300
|
|||||||
|
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Example app listening at http://localhost:${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;
|
module.exports = app;
|
||||||
|
9
export_md_to_html.sh
Normal file
9
export_md_to_html.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/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 ____"
|
10
import_xml.sh
Normal file
10
import_xml.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/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/ ____"
|
124
routes/index.js
124
routes/index.js
@ -8,6 +8,7 @@ var router = express.Router();
|
|||||||
let convertFiles = true;
|
let convertFiles = true;
|
||||||
// let convertFiles = false;
|
// let convertFiles = false;
|
||||||
let computeDataOnExtract = true;
|
let computeDataOnExtract = true;
|
||||||
|
// let computeDataOnExtract = false;
|
||||||
|
|
||||||
let jsonAllData = {
|
let jsonAllData = {
|
||||||
tasks : {},
|
tasks : {},
|
||||||
@ -19,20 +20,32 @@ let jsonAllData = {
|
|||||||
/**
|
/**
|
||||||
* obtenir la liste de tags que l'on a entré
|
* 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) {
|
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
|
// récupérer le contenu des json
|
||||||
jsonAllData.tags = require('../sources/tags_gtg.json')
|
jsonAllData.tags = require('../sources/tags_gtg.json')
|
||||||
jsonAllData.tasks = require('../sources/gtg_tasks_gtg.json')
|
jsonAllData.tasks = require('../sources/gtg_tasks_gtg.json')
|
||||||
|
if(!jsonAllData.tasks){
|
||||||
|
res.redirect('/xml')
|
||||||
|
}
|
||||||
|
|
||||||
if (computeDataOnExtract) {
|
if (computeDataOnExtract) {
|
||||||
|
|
||||||
@ -46,6 +59,8 @@ router.get('/', async function (req, res, next) {
|
|||||||
res.render('index', {
|
res.render('index', {
|
||||||
title: "Conversion de GTG tâches",
|
title: "Conversion de GTG tâches",
|
||||||
json : jsonAllData,
|
json : jsonAllData,
|
||||||
|
markdown : markdownExportData,
|
||||||
|
weeklyDevReport,
|
||||||
getPercent,
|
getPercent,
|
||||||
computeBgColorOnProportionOfOpenTasks,
|
computeBgColorOnProportionOfOpenTasks,
|
||||||
getPercentOfOpenTasks
|
getPercentOfOpenTasks
|
||||||
@ -208,49 +223,56 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
let datenow = new Date();
|
let datenow = new Date();
|
||||||
let dataTagsMd = `# Export de Tâches GTG \n date: ` + datenow.toLocaleString()
|
let markdownExportData = ''
|
||||||
|
let weeklyDevReport = ''
|
||||||
function exportToMarkdown(res) {
|
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
|
// fichier de rapport des tâches fermées durant les 7 derniers jours
|
||||||
dataTagsMd += `\n# Rapport hebdomadaire de dev `;
|
weeklyDevReport += `\n# Rapport hebdomadaire de dev `;
|
||||||
dataTagsMd += `\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
|
weeklyDevReport += `\r\n## ${jsonAllData.stats.listDevWeeklyClosed.length} ont été fermées `;
|
||||||
jsonAllData.stats.listDevWeeklyClosed.map(elem => {
|
jsonAllData.stats.listDevWeeklyClosed.map(elem => {
|
||||||
dataTagsMd += `\n * ${elem.title}`;
|
weeklyDevReport += `\n* ${elem.title}`;
|
||||||
})
|
})
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n ${weeklyDevReport}`;
|
||||||
dataTagsMd += `\n---`;
|
markdownExportData += `\n---`;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n# Rapport des tâches durant les 7 derniers jours `;
|
markdownExportData += `\n# Rapport des tâches durant les 7 derniers jours `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
|
markdownExportData += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
jsonAllData.stats.listClosedWeekly.map(elem => {
|
jsonAllData.stats.listClosedWeekly.map(elem => {
|
||||||
dataTagsMd += `\n * ${elem.title}`;
|
markdownExportData += `\n * ${elem.title}`;
|
||||||
})
|
})
|
||||||
dataTagsMd += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
markdownExportData += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
jsonAllData.stats.listOpenWeekly.map(elem => {
|
jsonAllData.stats.listOpenWeekly.map(elem => {
|
||||||
dataTagsMd += `\n * ${elem.title}`;
|
markdownExportData += `\n * ${elem.title}`;
|
||||||
})
|
})
|
||||||
dataTagsMd += `\n--- `;
|
markdownExportData += `\n--- `;
|
||||||
// fichier de rapport des tâches fermées durant les 31 derniers jours
|
// fichier de rapport des tâches fermées durant les 31 derniers jours
|
||||||
dataTagsMd += `\n# Rapport des autres tâches durant le mois `;
|
markdownExportData += `\n# Rapport des autres tâches durant le mois `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n## ${jsonAllData.stats.listClosedWeekly.length} ont été fermées `;
|
markdownExportData += `\n## ${jsonAllData.stats.listClosedMonthly.length} ont été fermées `;
|
||||||
dataTagsMd += `\n `;
|
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## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
markdownExportData += `\n--- `;
|
||||||
dataTagsMd += `\n `;
|
|
||||||
dataTagsMd += `\n--- `;
|
|
||||||
// stats de fermeture des tâches
|
// stats de fermeture des tâches
|
||||||
dataTagsMd += `\n# Stats de fermeture des tâches `;
|
markdownExportData += `\n# Stats de fermeture des tâches `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n--- `;
|
markdownExportData += `\n--- `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n# Export de toutes les ${jsonAllData.stats.listOpen.length} tâches ouvertes GTG \n `;
|
markdownExportData += `\n# Export de toutes les ${jsonAllData.stats.listOpen.length} tâches ouvertes GTG \n `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
|
|
||||||
// jsonAllData.stats.listOpen.map(elem => {
|
// jsonAllData.stats.listOpen.map(elem => {
|
||||||
// dataTagsMd += `\n## ${elem.title} `;
|
// dataTagsMd += `\n## ${elem.title} `;
|
||||||
@ -260,32 +282,32 @@ function exportToMarkdown(res) {
|
|||||||
// dataTagsMd += `\n prévu pour : ${elem.duedate | ''} `;
|
// dataTagsMd += `\n prévu pour : ${elem.duedate | ''} `;
|
||||||
// dataTagsMd += `\n ${elem.content} `;
|
// dataTagsMd += `\n ${elem.content} `;
|
||||||
// })
|
// })
|
||||||
dataTagsMd += `\n--- `;
|
markdownExportData += `\n--- `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
|
markdownExportData += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
//
|
//
|
||||||
// jsonAllData.stats.listClosed.map(elem=>{
|
// jsonAllData.stats.listClosed.map(elem=>{
|
||||||
// dataTagsMd += `\n * ${elem.title} `;
|
// dataTagsMd += `\n * ${elem.title} `;
|
||||||
// })
|
// })
|
||||||
|
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n# Export de Tags GTG \n `;
|
markdownExportData += `\n# Export de Tags GTG \n `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
|
|
||||||
let sortedTagsByTitle = _.sortBy(jsonAllData.tags.tagstore.tag, [(o) => {
|
let sortedTagsByTitle = _.sortBy(jsonAllData.tags.tagstore.tag, [(o) => {
|
||||||
o["$"].name
|
o["$"].name
|
||||||
}])
|
}])
|
||||||
|
|
||||||
sortedTagsByTitle.map(elem => {
|
sortedTagsByTitle.map(elem => {
|
||||||
dataTagsMd += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
|
markdownExportData += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
|
||||||
})
|
})
|
||||||
|
|
||||||
dataTagsMd += `\n `;
|
markdownExportData += `\n `;
|
||||||
dataTagsMd += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
|
markdownExportData += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
|
||||||
// write file to disk
|
// write file to disk
|
||||||
fs.writeFile(`output/export_tags.md`, dataTagsMd, `utf8`, (err) => {
|
fs.writeFile(`output/export_hebdo.md`, markdownExportData, `utf8`, (err) => {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(`Error writing file: ${err}`);
|
console.log(`Error writing file: ${err}`);
|
||||||
|
@ -12,6 +12,9 @@ block content
|
|||||||
li #{json.stats.listClosed.length} fermées
|
li #{json.stats.listClosed.length} fermées
|
||||||
li #{json.stats.listClosedWeekly.length} fermées cette semaine
|
li #{json.stats.listClosedWeekly.length} fermées cette semaine
|
||||||
li #{json.stats.listClosedMonthly.length} fermées ce mois-ci
|
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
|
section.tags
|
||||||
h2 #{json.tags.tagstore.tag.length} Tags
|
h2 #{json.tags.tagstore.tag.length} Tags
|
||||||
p maximum de #{json.stats.maxTasksCountPerTag} tâches pour un tag.
|
p maximum de #{json.stats.maxTasksCountPerTag} tâches pour un tag.
|
||||||
@ -36,7 +39,7 @@ block content
|
|||||||
if t.tasksListIsActiveByTitle
|
if t.tasksListIsActiveByTitle
|
||||||
span.text-right.tasks #{t.tasksListIsActiveByTitle.length}
|
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(class=computeBgColorOnProportionOfOpenTasks(getPercent(t.tasksListIsActiveByTitle.length, t.tasks))) #{getPercent(t.tasksListIsActiveByTitle.length, t.tasks)} %
|
||||||
span.text-right.tasks #{getPercentOfOpenTasks(t.tasksListIsActiveByTitle.length)} %
|
span.text-right.tasks #{getPercent(t.tasksListIsActiveByTitle.length,json.stats.listOpen.length )} %
|
||||||
button.text-right.toggle voir
|
button.text-right.toggle voir
|
||||||
ul
|
ul
|
||||||
each activetask in t.tasksListIsActiveByTitle
|
each activetask in t.tasksListIsActiveByTitle
|
||||||
|
Loading…
Reference in New Issue
Block a user