2023-03-03 18:54:50 +01:00
|
|
|
import * as coming_events_json from './../assets/documents/idf_agendadulibre_coming.json' assert { type: "json" } ;
|
2023-03-04 22:53:12 +01:00
|
|
|
import sendPostMastodon, { filterRegionAgendaDuLibreEvents, groupEventsByDay} from "./libs/utils.mjs";
|
2023-03-03 18:54:50 +01:00
|
|
|
import moment from 'moment';
|
2023-03-04 22:53:12 +01:00
|
|
|
|
|
|
|
import {getArticlesFromDaysInJson,diffDaysBetweenTwoDates} from './libs/rss_management.mjs'
|
|
|
|
|
2023-03-03 18:54:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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', '')
|
|
|
|
|
|
|
|
|
2023-03-03 19:16:59 +01:00
|
|
|
// content += `\n* [${event.title}](${eventUrl})` ;
|
|
|
|
content += `\n* [${event.city} - ${event.title}](${eventUrl})` ;
|
2023-03-03 18:54:50 +01:00
|
|
|
content += `\n* ${tags}` ;
|
|
|
|
|
|
|
|
let start = moment(new Date(event.start_time)).format(event_date_format)
|
|
|
|
let end = moment(new Date(event.end_time)).format(event_date_format)
|
|
|
|
content += `\n ${start} -- ${end}` ;
|
|
|
|
})
|
2023-03-03 19:16:59 +01:00
|
|
|
content += `\n`;
|
2023-03-03 18:54:50 +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")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2023-03-03 19:16:59 +01:00
|
|
|
postLink();
|