group days for adl events
This commit is contained in:
parent
eddf735722
commit
c633f547de
@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
nvm use 16
|
|
||||||
#cd /home/tykayn/www/multi-account-post-schedule-mastodon
|
|
||||||
wget --no-check-certificate --no-directories -O ./documents/agendadulibre_openstreetmap.json https://www.agendadulibre.org/events.json?city=&near%5Blocation%5D=&near%5Bdistance%5D=®ion=&tag=openstreetmap
|
|
||||||
|
|
||||||
#node helpers/agendadulibre_coming_osm.mjs --force | tee -a /home/tykayn/log_autopost.txt 2>&1
|
|
||||||
node helpers/agendadulibre_coming_osm.mjs | tee -a /home/tykayn/log_autopost.txt 2>&1
|
|
6
assets/bash_scripts/agendadulibre_coming_osm.sh
Normal file
6
assets/bash_scripts/agendadulibre_coming_osm.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
nvm use 16
|
||||||
|
#cd /home/tykayn/www/multi-account-post-schedule-mastodon
|
||||||
|
wget --no-check-certificate --no-directories -O ./documents/agendadulibre_coming_openstreetmap.json https://www.agendadulibre.org/events.json?city=&near%5Blocation%5D=&near%5Bdistance%5D=®ion=&tag=openstreetmap
|
||||||
|
|
||||||
|
node helpers/agendadulibre_coming_osm.mjs --force | tee -a /home/tykayn/log_autopost.txt 2>&1
|
6
assets/bash_scripts/idf_agendadulibre.sh
Normal file
6
assets/bash_scripts/idf_agendadulibre.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
nvm use 16
|
||||||
|
#cd /home/tykayn/www/multi-account-post-schedule-mastodon
|
||||||
|
wget --no-check-certificate --no-directories -O ./documents/agendadulibre.json https://www.agendadulibre.org/events.json
|
||||||
|
|
||||||
|
node helpers/floss_idf.mjs --force | tee -a /home/tykayn/log_autopost.txt 2>&1
|
10790
assets/documents/idf_agendadulibre_coming.json
Normal file
10790
assets/documents/idf_agendadulibre_coming.json
Normal file
File diff suppressed because one or more lines are too long
BIN
assets/floss_default.jpg
Normal file
BIN
assets/floss_default.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
BIN
assets/floss_default_1.jpg
Normal file
BIN
assets/floss_default_1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
BIN
assets/floss_default_1.xcf
Normal file
BIN
assets/floss_default_1.xcf
Normal file
Binary file not shown.
BIN
assets/floss_default_2.jpg
Normal file
BIN
assets/floss_default_2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
79
helpers/floss_idf.mjs
Normal file
79
helpers/floss_idf.mjs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import * as coming_events_json from './../assets/documents/idf_agendadulibre_coming.json' assert { type: "json" } ;
|
||||||
|
import sendPostMastodon, {getArticlesFromDaysInJson, filterRegionAgendaDuLibreEvents, groupEventsByDay} from "./utils.mjs";
|
||||||
|
import moment from 'moment';
|
||||||
|
import {diffDaysBetweenTwoDates} from "./utils.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', '')
|
||||||
|
|
||||||
|
|
||||||
|
content += `\n* [${event.title}](${eventUrl})` ;
|
||||||
|
content += `\n* ${tags}` ;
|
||||||
|
content += `\n* ${event.city} - ${event.title}` ;
|
||||||
|
|
||||||
|
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}` ;
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
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();
|
||||||
|
|
||||||
|
let difftest = diffDaysBetweenTwoDates(new Date("2023-03-04T14:30:00.000Z") ,new Date())
|
||||||
|
console.log('new Date("2023-03-04T14:30:00.000Z") ', difftest )
|
@ -354,12 +354,12 @@ export function findPictureAndSendPost(postContent, configPost){
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function hasCliArgument(argument){
|
export function hasCliArgument(argument){
|
||||||
console.log('myArgs: ', myArgs);
|
|
||||||
return myArgs.indexOf(argument) !== -1
|
return myArgs.indexOf(argument) !== -1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import Parser from 'rss-parser';
|
import Parser from 'rss-parser';
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
let parser = new Parser();
|
let parser = new Parser();
|
||||||
|
|
||||||
@ -424,11 +424,12 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
|||||||
|
|
||||||
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
||||||
|
|
||||||
if( differenceDays <= nbOfDays){
|
console.log('differenceDays', differenceDays)
|
||||||
|
if( differenceDays <= nbOfDays || differenceDays == 0 || differenceDays == 1){
|
||||||
console.log('on garde', item.title)
|
console.log('on garde', item.title)
|
||||||
selectedEvents.push(item)
|
selectedEvents.push(item)
|
||||||
}else{
|
}else{
|
||||||
// console.log('on ne garde pas')
|
console.log('on ne garde pas', differenceDays)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -439,8 +440,34 @@ export function diffDaysBetweenTwoDates(date1,date2) {
|
|||||||
|
|
||||||
const diffTime = Math.abs(date2 - date1);
|
const diffTime = Math.abs(date2 - date1);
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||||
// console.log(diffTime + " milliseconds");
|
|
||||||
console.log(diffDays + " days");
|
|
||||||
return diffDays;
|
return diffDays;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function filterRegionAgendaDuLibreEvents(events_list, filter_critera) {
|
||||||
|
let selection = []
|
||||||
|
events_list.forEach(item=> {
|
||||||
|
if( item.region_id == filter_critera){
|
||||||
|
selection.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
moment.locale('fr');
|
||||||
|
|
||||||
|
export function groupEventsByDay(events_list){
|
||||||
|
let selection = {}
|
||||||
|
events_list.forEach(item=> {
|
||||||
|
|
||||||
|
let formattedDay = moment(item.start_time).format('dddd DD')
|
||||||
|
|
||||||
|
if( ! selection[formattedDay]){
|
||||||
|
selection[formattedDay] = []
|
||||||
|
selection[formattedDay].push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('selection', selection)
|
||||||
|
return selection;
|
||||||
}
|
}
|
@ -16,6 +16,7 @@
|
|||||||
"http-errors": "~1.6.3",
|
"http-errors": "~1.6.3",
|
||||||
"jade": "~1.11.0",
|
"jade": "~1.11.0",
|
||||||
"mastodon": "^1.2.2",
|
"mastodon": "^1.2.2",
|
||||||
|
"moment": "^2.29.4",
|
||||||
"morgan": "~1.9.1",
|
"morgan": "~1.9.1",
|
||||||
"node-fs": "^0.1.7",
|
"node-fs": "^0.1.7",
|
||||||
"nodemon": "^2.0.19",
|
"nodemon": "^2.0.19",
|
||||||
|
11
wget-log
Normal file
11
wget-log
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--2023-03-03 17:53:55-- https://www.agendadulibre.org/events.json?city=
|
||||||
|
Résolution de www.agendadulibre.org (www.agendadulibre.org)… 176.9.141.91
|
||||||
|
Connexion à www.agendadulibre.org (www.agendadulibre.org)|176.9.141.91|:443… connecté.
|
||||||
|
requête HTTP transmise, en attente de la réponse… 200 OK
|
||||||
|
Taille : non indiqué [application/json]
|
||||||
|
Sauvegarde en : « ./assets/documents/idf_agendadulibre_coming.json »
|
||||||
|
|
||||||
|
./assets/documents/idf_agendadulibre_coming.json [<=> ] 0 --.-KB/s
./assets/documents/idf_agendadulibre_coming.json [ <=> ] 463,07K 2,25MB/s
./assets/documents/idf_agendadulibre_coming.json [ <=> ] 890,10K 2,37MB/s ds 0,4s
|
||||||
|
|
||||||
|
2023-03-03 17:53:57 (2,37 MB/s) - « ./assets/documents/idf_agendadulibre_coming.json » sauvegardé [911459]
|
||||||
|
|
@ -2121,6 +2121,7 @@ __metadata:
|
|||||||
https: ^1.0.0
|
https: ^1.0.0
|
||||||
jade: ~1.11.0
|
jade: ~1.11.0
|
||||||
mastodon: ^1.2.2
|
mastodon: ^1.2.2
|
||||||
|
moment: ^2.29.4
|
||||||
morgan: ~1.9.1
|
morgan: ~1.9.1
|
||||||
node-fetch: ^3.2.10
|
node-fetch: ^3.2.10
|
||||||
node-fs: ^0.1.7
|
node-fs: ^0.1.7
|
||||||
@ -2354,6 +2355,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"moment@npm:^2.29.4":
|
||||||
|
version: 2.29.4
|
||||||
|
resolution: "moment@npm:2.29.4"
|
||||||
|
checksum: 0ec3f9c2bcba38dc2451b1daed5daded747f17610b92427bebe1d08d48d8b7bdd8d9197500b072d14e326dd0ccf3e326b9e3d07c5895d3d49e39b6803b76e80e
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"morgan@npm:~1.9.1":
|
"morgan@npm:~1.9.1":
|
||||||
version: 1.9.1
|
version: 1.9.1
|
||||||
resolution: "morgan@npm:1.9.1"
|
resolution: "morgan@npm:1.9.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user