88 lines
2.7 KiB
JavaScript
88 lines
2.7 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" };
|
|
import tasksList from '/home/tykayn/Nextcloud/ressources/social sorting/output/emacs_export_tasks.json' assert { type: "json" };
|
|
|
|
|
|
let folderPrefix = './emploi-du-temps/folders_build';
|
|
|
|
async function foldersGeneration(dirpath){
|
|
if(dirpath.length > 30){
|
|
dirpath = dirpath.slice(0,30)
|
|
}
|
|
await fs.promises.mkdir(`${folderPrefix}/${dirpath}`, { recursive: true })
|
|
}
|
|
export let sectionsCleaned = {}
|
|
|
|
/**
|
|
*
|
|
* @param generate_folders
|
|
* @returns Object un objet décrivant chaque partie des tasks.json
|
|
*/
|
|
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}`).then(r => {
|
|
console.log('r', r)
|
|
console.log('folders have been generated')
|
|
})
|
|
}
|
|
|
|
})
|
|
}
|
|
})
|
|
|
|
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();
|