Compare commits
3 Commits
42c92e6047
...
698c01ac07
Author | SHA1 | Date | |
---|---|---|---|
698c01ac07 | |||
cd87d78f06 | |||
79bf2f4847 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ sources/
|
||||
.idea
|
||||
node_modules
|
||||
output/
|
||||
output/*
|
||||
|
3
app.js
3
app.js
@ -43,7 +43,8 @@ const port = 3300
|
||||
|
||||
|
||||
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;
|
||||
|
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 = 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) {
|
||||
|
||||
@ -46,6 +59,8 @@ router.get('/', async function (req, res, next) {
|
||||
res.render('index', {
|
||||
title: "Conversion de GTG tâches",
|
||||
json : jsonAllData,
|
||||
markdown : markdownExportData,
|
||||
weeklyDevReport,
|
||||
getPercent,
|
||||
computeBgColorOnProportionOfOpenTasks,
|
||||
getPercentOfOpenTasks
|
||||
@ -208,49 +223,56 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
|
||||
return result;
|
||||
}
|
||||
let datenow = new Date();
|
||||
let dataTagsMd = `# Export de Tâches GTG \n date: ` + datenow.toLocaleString()
|
||||
|
||||
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
|
||||
dataTagsMd += `\n# Rapport hebdomadaire de dev `;
|
||||
dataTagsMd += `\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 => {
|
||||
dataTagsMd += `\n * ${elem.title}`;
|
||||
weeklyDevReport += `\n* ${elem.title}`;
|
||||
})
|
||||
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 `;
|
||||
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 `;
|
||||
jsonAllData.stats.listClosedWeekly.map(elem => {
|
||||
dataTagsMd += `\n * ${elem.title}`;
|
||||
markdownExportData += `\n * ${elem.title}`;
|
||||
})
|
||||
dataTagsMd += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
||||
dataTagsMd += `\n `;
|
||||
markdownExportData += `\n## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
||||
markdownExportData += `\n `;
|
||||
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
|
||||
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# 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## ${jsonAllData.stats.listOpenWeekly.length} ont été ouvertes `;
|
||||
dataTagsMd += `\n `;
|
||||
dataTagsMd += `\n--- `;
|
||||
markdownExportData += `\n--- `;
|
||||
// stats de fermeture des tâches
|
||||
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 `;
|
||||
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 `;
|
||||
|
||||
// jsonAllData.stats.listOpen.map(elem => {
|
||||
// dataTagsMd += `\n## ${elem.title} `;
|
||||
@ -260,32 +282,32 @@ function exportToMarkdown(res) {
|
||||
// dataTagsMd += `\n prévu pour : ${elem.duedate | ''} `;
|
||||
// dataTagsMd += `\n ${elem.content} `;
|
||||
// })
|
||||
dataTagsMd += `\n--- `;
|
||||
dataTagsMd += `\n `;
|
||||
dataTagsMd += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
|
||||
dataTagsMd += `\n `;
|
||||
markdownExportData += `\n--- `;
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n# Export de toutes les ${jsonAllData.stats.listClosed.length} tâches fermées GTG \n `;
|
||||
markdownExportData += `\n `;
|
||||
//
|
||||
// jsonAllData.stats.listClosed.map(elem=>{
|
||||
// dataTagsMd += `\n * ${elem.title} `;
|
||||
// })
|
||||
|
||||
dataTagsMd += `\n `;
|
||||
dataTagsMd += `\n# Export de Tags GTG \n `;
|
||||
dataTagsMd += `\n `;
|
||||
dataTagsMd += `\n `;
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n# Export de Tags GTG \n `;
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n `;
|
||||
|
||||
let sortedTagsByTitle = _.sortBy(jsonAllData.tags.tagstore.tag, [(o) => {
|
||||
o["$"].name
|
||||
}])
|
||||
|
||||
sortedTagsByTitle.map(elem => {
|
||||
dataTagsMd += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
|
||||
markdownExportData += `\n * ${elem['$'].name} , ${elem.tasks | 0}`;
|
||||
})
|
||||
|
||||
dataTagsMd += `\n `;
|
||||
dataTagsMd += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
|
||||
markdownExportData += `\n `;
|
||||
markdownExportData += `\n rapport généré avec gtg2nodejs par tykayn - contact@cipherbliss.com `;
|
||||
// write file to disk
|
||||
fs.writeFile(`output/export_tags.md`, dataTagsMd, `utf8`, (err) => {
|
||||
fs.writeFile(`output/export_hebdo.md`, markdownExportData, `utf8`, (err) => {
|
||||
|
||||
if (err) {
|
||||
console.log(`Error writing file: ${err}`);
|
||||
|
@ -12,6 +12,9 @@ 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.
|
||||
@ -36,7 +39,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 #{getPercentOfOpenTasks(t.tasksListIsActiveByTitle.length)} %
|
||||
span.text-right.tasks #{getPercent(t.tasksListIsActiveByTitle.length,json.stats.listOpen.length )} %
|
||||
button.text-right.toggle voir
|
||||
ul
|
||||
each activetask in t.tasksListIsActiveByTitle
|
||||
|
Loading…
Reference in New Issue
Block a user