76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
|
/**
|
||
|
* création d'emploi du temps avec des zones découpées en catégorie
|
||
|
* cela permet de parcourir tous les aspects de la méthodologie PARA sur différents créneaux
|
||
|
* @type {{duration: string, start: string, content: null}}
|
||
|
*/
|
||
|
import fs from 'node-fs';
|
||
|
import tasksList from '../sources/tasks.json' assert { type: "json" };
|
||
|
|
||
|
|
||
|
|
||
|
let folderPrefix = './emploi-du-temps/folders_build';
|
||
|
|
||
|
async function foldersGeneration(dirpath){
|
||
|
await fs.promises.mkdir(`${folderPrefix}/${dirpath}`, { recursive: true })
|
||
|
}
|
||
|
export let sectionsCleaned = {}
|
||
|
// TODO prendre le groupe de type projets; récupérer les tâches de level 2
|
||
|
export function get_sections_from_tasks_orgfile(generate_folders= false){
|
||
|
|
||
|
tasksList.contents.map( elem => {
|
||
|
let sectionTitle = elem.properties['raw-value'];
|
||
|
|
||
|
if(sectionTitle){
|
||
|
let cleanSectionName = removeBrackets(elem.properties['raw-value']).replace(/-*/g, "")
|
||
|
sectionsCleaned[cleanSectionName] = {}
|
||
|
|
||
|
if(generate_folders){
|
||
|
foldersGeneration(cleanSectionName);
|
||
|
}
|
||
|
console.log('section PARA: ', cleanSectionName)
|
||
|
elem.contents.map( content => {
|
||
|
let subSectionName = removeBrackets(content.properties['raw-value'])
|
||
|
console.log(' - ',subSectionName )
|
||
|
sectionsCleaned[cleanSectionName][subSectionName] = subSectionName
|
||
|
if(generate_folders){
|
||
|
foldersGeneration(`${cleanSectionName}/${subSectionName}`)
|
||
|
}
|
||
|
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
|
||
|
console.log('sectionsCleaned',sectionsCleaned)
|
||
|
return sectionsCleaned;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* clean org tasks headings of links to roam things, remove counter cookies
|
||
|
* @param input
|
||
|
* @returns {string|*}
|
||
|
*/
|
||
|
export function removeBrackets(input) {
|
||
|
if(!input){
|
||
|
return input;
|
||
|
}
|
||
|
return input
|
||
|
.replace(/{.*?}/g, "")
|
||
|
.replace('\'', ' ')
|
||
|
.replace(' ', ' ')
|
||
|
.replace(/\[.*?\/.*?\]/g, "")
|
||
|
.replace(/\[\[.*?\[/g, "")
|
||
|
.replace(/\]*/g, "")
|
||
|
.replace(/<.*?>/g, "")
|
||
|
.replace(/\(.*?\)/g, "")
|
||
|
.replace(']','')
|
||
|
.toLowerCase()
|
||
|
.trim()
|
||
|
//.replace('[','')
|
||
|
;
|
||
|
}
|
||
|
|
||
|
get_sections_from_tasks_orgfile(true);
|
||
|
|
||
|
console.log("* Emploi du temps pour deux semaines sans inclure les weekend \n")
|
||
|
//displayDays();
|