2023-03-03 17:28:41 +01:00
|
|
|
|
|
|
|
import sendPostMastodon from "./utils.mjs";
|
|
|
|
import * as coming_events_json from './../assets/documents/agendadulibre_coming_openstreetmap.json' assert { type: "json" };
|
|
|
|
import {getArticlesFromDaysInJson} from "./utils.mjs";
|
|
|
|
|
|
|
|
const days_filter = 7;
|
|
|
|
|
|
|
|
function makeTitleContentFromAgendaDulibre(articles) {
|
|
|
|
|
|
|
|
let content = '';
|
|
|
|
|
2023-03-03 17:52:10 +01:00
|
|
|
if(! articles.length ){
|
|
|
|
return '- Aucun évènement prévu. T_T'
|
|
|
|
}
|
2023-03-03 17:28:41 +01:00
|
|
|
articles.forEach(item=>{
|
|
|
|
content += `\n* ${item.city} - ${item.title}` ;
|
2023-03-03 17:52:10 +01:00
|
|
|
let start = new Date(item.start_time)
|
|
|
|
let end = new Date(item.end_time)
|
|
|
|
content += `\n <${start} -- ${end}>` ;
|
2023-03-03 17:28:41 +01:00
|
|
|
})
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function postLink() {
|
|
|
|
|
|
|
|
console.log("curator: résumé des prochains évènements de l'agenda du libre en ile de france dans les " + days_filter + " jours")
|
2023-03-03 17:52:10 +01:00
|
|
|
let events_list = coming_events_json.default;
|
2023-03-03 17:28:41 +01:00
|
|
|
|
2023-03-03 17:52:10 +01:00
|
|
|
events_list = getArticlesFromDaysInJson(events_list,days_filter);
|
2023-03-03 17:28:41 +01:00
|
|
|
|
|
|
|
let contentOfPost = 'Prochains évènements OpenStreetMap dans les ' + days_filter + ' prochains jours: \n'
|
2023-03-03 17:52:10 +01:00
|
|
|
+ makeTitleContentFromAgendaDulibre(events_list)
|
2023-03-03 17:28:41 +01:00
|
|
|
|
|
|
|
let configPost = {
|
|
|
|
author: 'curator',
|
|
|
|
website: 'openstreetmap.fr',
|
|
|
|
// disable_slugify: true,
|
|
|
|
slug: "osm_event_picture",
|
|
|
|
content_type: "text/markdown",
|
|
|
|
folder_image: process.cwd() + '/assets/',
|
2023-03-03 17:52:10 +01:00
|
|
|
image: "osm_default.jpg",
|
2023-03-03 17:28:41 +01:00
|
|
|
message: `# ${contentOfPost}
|
|
|
|
|
|
|
|
#agenda #floss #openstreetmap #hebdo`,
|
|
|
|
}
|
|
|
|
sendPostMastodon(configPost)
|
|
|
|
}
|
|
|
|
|
2023-03-03 17:52:10 +01:00
|
|
|
postLink();
|