import * as coming_events_json from './../assets/documents/idf_agendadulibre_coming.json' assert { type: "json" } ; import sendPostMastodon, { filterRegionAgendaDuLibreEvents, groupEventsByDay} from "./libs/utils.mjs"; import moment from 'moment'; import {getArticlesFromDaysInJson} from "./libs/rss_management.mjs"; let event_date_format = 'HH:mm' const days_filter = 7; moment.locale('fr') function makeTitleContentFromAgendaDulibre(articles) { let content = ''; if (!articles.length) { return '- Aucun évènement prévu. T_T' } articles = groupEventsByDay(articles); let sortedDays = Object.keys(articles) sortedDays.forEach((dayOfEvents, index) => { // console.log('item', item, articles[item]) console.log('item', dayOfEvents) content += `\n## ${dayOfEvents}` ; articles[dayOfEvents].forEach(event =>{ console.log('event.title', event.title) let tags = '#'+event.tags.split(' ').join(' #') let eventUrl = event.url.replace('.json', '') let start = moment(new Date(event.start_time)).utcOffset(0).format(event_date_format) let end = moment(new Date(event.end_time)).utcOffset(0).format(event_date_format) // content += `\n* [${event.title}](${eventUrl})` ; content += `\n* [${event.city} ${start} - ${end} | ${event.title}](${eventUrl})` ; content += `\n ${tags}` ; content += `\n ` ; }) content += `\n`; }) 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 = filterRegionAgendaDuLibreEvents(events_list, "12"); events_list = getArticlesFromDaysInJson(events_list, days_filter); let contentOfPost = 'Prochains évènements libristes en île de France dans les ' + days_filter + ' prochains jours: \n' + makeTitleContentFromAgendaDulibre(events_list) let configPost = { author: 'curator', website: 'openstreetmap.fr', slug: "floss_event_picture", content_type: "text/markdown", folder_image: process.cwd() + '/assets/', image: "floss_default.jpg", message: `# ${contentOfPost} #agenda #floss #openstreetmap #hebdo`, } sendPostMastodon(configPost) } postLink();