1
0
Fork 0
forked from Deuxfleurs/site

Compare commits

...

3 commits

8 changed files with 601 additions and 1399 deletions

21
.gitignore vendored
View file

@ -2,3 +2,24 @@ public/
node_modules/
*.swp
.awsclirc
reated by https://www.toptal.com/developers/gitignore/api/venv
# Edit at https://www.toptal.com/developers/gitignore?templates=venv
### venv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
.Python
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
.venv
pip-selfcheck.json
# End of https://www.toptal.com/developers/gitignore/api/venv
script/calendar_generator/.gitignore

7
script/README.md Normal file
View file

@ -0,0 +1,7 @@
# Scripts
## Calendar Generator
A rust module to generate calendar in ascii
Usage :
`cargo run MM-YYYY`

71
script/calendar_generator/.gitignore vendored Normal file
View file

@ -0,0 +1,71 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust,emacs
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,emacs
### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# End of https://www.toptal.com/developers/gitignore/api/rust,emacs

290
script/calendar_generator/Cargo.lock generated Normal file
View file

@ -0,0 +1,290 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "calendar_generator"
version = "0.1.0"
dependencies = [
"chrono",
]
[[package]]
name = "cc"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "iana-time-zone"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "js-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "proc-macro2"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "2.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"

View file

@ -0,0 +1,9 @@
[package]
name = "calendar_generator"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.38"

View file

@ -0,0 +1,129 @@
use chrono::prelude::*;
use std::env;
use chrono::NaiveDate;
fn get_month( num :i8) -> & 'static str {
match num {
1 => return "JANVIER",
2 => return "FEVRIER",
3 => return "MARS",
4 => return "AVRIL",
5 => return "MAI",
6 => return "JUIN",
7 => return "JUILLET",
8 => return "AOUT",
9 => return "SEPTEMBRE",
10 => return "OCTOBRE",
11 => return "NOVEMBRE",
12 => return "DECEMBRE",
_=> return "",
}
}
fn nb_empty_space_before(day : Weekday) -> i8{
match day {
Weekday::Mon => return 0,
Weekday::Tue => return 1,
Weekday::Wed => return 2,
Weekday::Thu => return 3,
Weekday::Fri => return 4,
Weekday::Sat => return 5,
Weekday::Sun => return 6,
}
}
fn get_pretty_day(day_nb : i8) -> String {
if day_nb < 10 {
return "0".to_owned() + &day_nb.to_string();
}
return day_nb.to_string();
}
fn get_ascii_calendar(date : NaiveDate) -> String {
let binding = date.to_string();
let split_date = binding.split("-").collect::<Vec<_>>();
let month = split_date[1];
let year = split_date[0];
let month_name = get_month(month.parse::<i8>().expect("REASON"));
let space = 38 - "CALENDRIER".len() - 1 - month_name.len() - 1 - 4;
let mut calendar = String::from(".——————————————————————————————————————.\n");
calendar += "|";
for _ in 0..(space/2){
calendar += " ";
}
calendar += &("CALENDRIER".to_owned() + " " + month_name + " " + year);
for _ in 0..(space/2 + (space % 2)){
calendar = calendar.to_string() + " ";
}
calendar += "|\n";
calendar += "|——————————————————————————————————————|\n";
let mut top_line = String::from("| ");
let mut middle_line = String::from("| |");
let base_date = NaiveDate::from_ymd_opt(year.parse::<i32>().expect("REASON"),
1 + month.parse::<u32>().expect("REASON"),
1).unwrap();
// fill empty spaces
let nb_space = nb_empty_space_before(base_date.weekday());
for _ in 0..nb_space{
top_line += "———— ";
middle_line += " |"
}
let mut day_nb = 1;
for day in base_date.iter_days().take(50){
if day.month() != base_date.month(){
// complete to the end of the week
top_line += "———— ";
middle_line += " |";
if day.weekday() == Weekday::Sun {
calendar += &(top_line.clone() + " |\n");
calendar += &(middle_line .clone() + &(" |\n"));
calendar += &(top_line.clone() + " |\n");
break;
}
}
else {
if day.weekday() == Weekday::Sun {
calendar += &(top_line.clone() + "———— |\n");
calendar += &(middle_line .clone() + &(" ".to_owned() + &get_pretty_day(day_nb) + " | |\n"));
top_line = String::from("| ");
middle_line = String::from("| |");
}
else {
top_line += "———— ";
middle_line += &(" ".to_owned() + &get_pretty_day(day_nb) + " |");
}
}
day_nb += 1
}
calendar += "|______________________________________|\n";
return calendar;
}
fn main() {
let args: Vec<_> = env::args().collect();
if args.len() <= 1
{
println!("At least one month must be specified");
return;
}
for month in env::args(){
match NaiveDate::parse_from_str(&("01-".to_owned() + &month), "%d-%m-%Y") {
Ok(date) => println!("{}", get_ascii_calendar(date)),
Err(error) => println!("could not parse .{}. due to: {}", month, error),
}
}
}

View file

@ -0,0 +1,73 @@
#!/usr/bin/env python3
import vobject
import wget
import csv
from ics import Calendar, Event
def get_month(month : int):
match month:
case 1:
return "Janvier"
case 2:
return "Fevrier"
case 3:
return "Mars"
case 4:
return "Avril"
case 5:
return "Mai"
case 6:
return "Juin"
case 7:
return "Juillet"
case 8:
return "Aout"
case 9:
return "Septembre"
case 10:
return "Octobre"
case 11:
return "Novembre"
case 12:
return "Decembre"
if __name__ == "__main__":
url = "https://sogo.deuxfleurs.fr/SOGo/dav/public/lx/Calendar/22-63E29280-1-71341300.ics"
filename = wget.download(url)
# read the data from the file
data = open(filename).read()
c = Calendar(data)
for e in c.events:
html = "<li role=\"none\"><a href="
if (e.location is not None and "http" in e.location):
html += "\"" + e.location + "\""
else:
html += "\"#\""
html += ">"
html += e.name + "</a> "
if (e.location is not None and "http" in e.location):
html += " en ligne"
elif e.location is not None:
html += e.location
html += ","
html += "<span class=\"highlight\"> le " + str(e.begin.day) + " " + get_month(e.begin.month) + " " + str(e.begin.year)+ " à "
if e.begin.hour == 0:
html += "00:"
else:
html += str(e.begin.hour) + ":"
if e.begin.minute == 0:
html += "00 </span>"
else:
html += str(e.begin.minute) + "</span>"
if e.description is not None :
html += ".<br>" + e.description + "</li>"
print("\n" + html)

File diff suppressed because one or more lines are too long