50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
|
|
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 = '';
|
|
|
|
if(! articles.length ){
|
|
return '- Aucun évènement prévu. T_T'
|
|
}
|
|
articles.forEach(item=>{
|
|
content += `\n* ${item.city} - ${item.title}` ;
|
|
let start = new Date(item.start_time)
|
|
let end = new Date(item.end_time)
|
|
content += `\n <${start} -- ${end}>` ;
|
|
})
|
|
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")
|
|
let events_list = coming_events_json.default;
|
|
|
|
events_list = getArticlesFromDaysInJson(events_list,days_filter);
|
|
|
|
let contentOfPost = 'Prochains évènements OpenStreetMap dans les ' + days_filter + ' prochains jours: \n'
|
|
+ makeTitleContentFromAgendaDulibre(events_list)
|
|
|
|
let configPost = {
|
|
author: 'curator',
|
|
website: 'openstreetmap.fr',
|
|
// disable_slugify: true,
|
|
slug: "osm_event_picture",
|
|
content_type: "text/markdown",
|
|
folder_image: process.cwd() + '/assets/',
|
|
image: "osm_default.jpg",
|
|
message: `# ${contentOfPost}
|
|
|
|
#agenda #floss #openstreetmap #hebdo`,
|
|
}
|
|
sendPostMastodon(configPost)
|
|
}
|
|
|
|
postLink();
|