Compare commits

..

3 commits

16 changed files with 3604 additions and 679 deletions

3
.gitignore vendored
View file

@ -1,5 +1,4 @@
node_modules
public/build
result
.direnv
.direnv

View file

@ -1,18 +1,7 @@
{
"tree": {
"Rentrée": {
"Évènements pour les masteriens": {},
"Exchange and international students": {},
"Départements": {},
"Amphis de rentrée": {},
"Divers rentrée": {},
"Associatif divers": {},
"Visites": {}
},
"Délégation Générale Numérique": {},
"COF": {
"Évènements (COF)": {},
"Rentrée du COF": {},
"Assemblées Générales (COF)": {},
"BdA": {
"Évènements (BdA)": {},
@ -20,56 +9,26 @@
}
},
"Clubs COF": {
"PLS": {},
"HackENS": {},
"Club Bouffe": {},
"Club réseau": {},
"hackENS": {},
"Écriv'ENS": {},
"BOcal": {},
"CinéClub": {},
"Ernestophone": {},
"Club Jeux": {},
"DDR": {},
"BandarrêtdurgENS": {},
"L'Hômonerie": {},
"Ulmity": {},
"Arts pla'": {},
"Club Inutile ☔": {}
},
"BDS": {
"Évènements (BDS)": {},
"Rentrée du BDS": {}
},
"Clubs BDS": {
"Valse": {},
"Créneaux encadrés": {},
"ENSelle": {}
},
"BDS": {},
"La Nuit de l'ENS": {},
"Délégation Générale": {},
"K-Fêt": {},
"Écocampus": {},
"La Psychédéliste": {},
"Ambassadeur·rice·s santé": {}
},
"sources": {
"dgnum-nc": {
"dmo7DgdmTnsMd8zo": {
"name": "Valse"
},
"eEPk6miCzozgPb42": {
"name": "Délégation Générale Numérique",
"short_name": "DGNum",
"color": "#27327a"
}
},
"eleves-ens": {
"qG6jpJPfK37Nw8ZC": {
"name": "PLS"
},
"caey6jt6pTgKengA": {
"name": "BOcal",
"color": "#e6973e"
},
"LLWm8qK9iC5YGrrR": {
"name": "Délégation Générale",
"short_name": "DG"
@ -81,7 +40,7 @@
"w442JdS5AaQ6czrP": {
"name": "Écriv'ENS"
},
"aoazRGFcjHSe4LxG": {
"fRtjDkjrZyn6fxd8": {
"name": "K-Fêt",
"color": "#c63b52",
"default_location": "K-Fêt"
@ -119,95 +78,40 @@
"name": "BandarrêtdurgENS",
"short_name": "Banda"
},
"TyMrLaPPDzT7yAGC": {
"name": "BDS"
},
"kR8fMzmf4ciop9Je": {
"name": "Club Jeux",
"short_name": "Jeux",
"color": "#5f9ae0"
"name": "Club Jeux",
"short_name": "Jeux",
"color": "#5f9ae0"
}
},
"klub-reseau": {
"5WrcagPPARQ3BD87": {
"name": "Club réseau",
"default_location": "Cave d'hackENS"
},
"22rQF3gjjz8LifZC": {
"name": "La Psychédéliste",
"short_name": "Psychédéliste"
},
"AfHYkm3gqQ4fRRj5": {
"name": "HackENS",
"TFEAKjAgNFQZpNjo": {
"name": "hackENS",
"default_location": "Cave d'hackENS"
}
},
"frama-agenda": {
"qZcPZdGb5YtJHrNZ": {
"name": "ENSelle"
},
"K6iGBG47WXaKWs3Q": {
"name": "Créneaux encadrés",
"initial": false
},
"TFjE83ASCMK9rfRi": {
"name": "BandarrêtdurgENS",
"short_name": "Banda"
},
"dSYCtdC6bgyWpKyt": {
"name": "Évènements (BDS)"
},
"goXLq2dQ8LgFAjkM": {
"name": "Club Bouffe"
},
"Q8w6dw4jGLBP9ftB": {
"name": "Écocampus"
},
"T5WoHbs4FT5A945Z": {
"name": "CinéClub"
},
"zmgdYw62RatzmGDt": {
"name": "Ulmity"
},
"iXGysEGxo7EsKjwG": {
"name": "Ambassadeur·rice·s santé",
"short_name": "Amba. santé",
"color": "#f5a142"
},
"AYNpoC674yAjEmRy": {
"name": "L'Hômonerie"
},
"MJf2wnQafbLc2arS": {
"name": "Arts pla'",
"color": "#ffb969"
},
"qS7WJwyBaGRQFyX3": {
"name": "Exchange and international students",
"short_name": "Exchange"
},
"fGmpGCNZrHQkNt7L": {
"name": "Départements",
"short_name": "Dpt",
"initial": false
},
"W6qjeqEzEekNieWk": {
"name": "Évènements pour les masteriens",
"short_name": "Master"
},
"oDPMTBSma2bfo6WS": {
"name": "Amphis de rentrée",
"short_name": "Amphis",
"initial": false
},
"aPXtDmXDxmLxkERg": {
"name": "Divers rentrée",
"short_name": "Rentrée"
},
"fqK3nqqPtXLyo4Y4": {
"name": "Rentrée du COF",
"short_name": "COF"
},
"YQnfcozPDoRgNSBb": {
"name": "Rentrée du BDS",
"short_name": "BDS"
},
"tfA32kgc3GM2fH2C": {
"name": "Visites"
},
"KDNA4GrFMkkJrwNd": {
"name": "Associatif divers",
"short_name": "Asso"
"name": "Ambassadeur·rice·s santé",
"short_name": "Amba. santé",
"color": "#f5a142"
}
}
}

View file

@ -1,20 +1,10 @@
{
"nameMap": {
"Amphi Jourdan": "Amphithéâtre Jourdan",
"Cour aux Ernest": "Cour aux Ernests",
"R2-21 (Jourdan)": "R2-21",
"Salle Jean Ibanes (Jourdan, R1-07)": "Salle Jean Ibanes (R1-07)",
"Salle Madeleine Rebérioux (Jourdan, R2-02)": "Salle Madeleine Rebérioux (R2-02)",
"Salle Marcel Roncayolo (Jourdan, R2-05)": "Salle Marcel Roncayolo (R2-05)",
"Cour des bibliothèques": "Cour du NIR",
"Salle Jaurès": "Amphithéâtre Jaurès",
"Jaurès": "Amphithéâtre Jaurès",
"Dussane": "Salle Dussane",
"Cour aux Ernest": "Cour aux Ernests",
"Restaurant": "Pôt",
"29 rue d'Ulm": "Bâtiment du 29",
"Gymnase": "Gymnase Jean Prévost",
"Pôt (Restaurant)": "Pôt"
"Salle Marcel Roncayolo (Jourdan, R2-05)": "Salle Marcel Roncayolo (R2-05)"
},
"rooms": {
@ -22,7 +12,6 @@
"Amphithéâtre Galois",
"Bibliothèque Lettres",
"Salle Histoire",
"Salle Aron",
"Salle Cavaillès",
"Salle Dussane",
"Salle des Actes",
@ -31,10 +20,6 @@
"Salle Cartan",
"Salle Noether",
"Salle Bourbaki",
"Petite salle ECLA",
"Salle Reig ECLA",
"Salle Césaire ECLA",
"Salle Beckett",
"Cour aux Ernests",
"Cour du NIR",
"Cour Pasteur",
@ -43,17 +28,11 @@
"Canopée",
"K-Fêt",
"Cave d'hackENS",
"Gymnase Jean Prévost",
"Salle d'expression artistique (SEA)",
"Locaux des départements lettres et sciences humaines et sociales"
"Gymnase"
],
"24 rue Lhomond": ["Salle CONF IV"],
"29 rue d'Ulm": [
"Bâtiment du 29",
"Bibliothèque des sciences expérimentales",
"Amphithéâtre Jaurès"],
"29 rue d'Ulm": ["Bibliothèque des sciences expérimentales", "Salle Jaurès"],
"Jourdan": [
"Campus de Jourdan",
"Bibliothèque de Jourdan",
"Salle Marcel Roncayolo (R2-05)",
"Salle Madeleine Rebérioux (R2-02)",

View file

@ -1,44 +1,9 @@
{ pkgs ? import ./nix {} }:
{
sources ? import ./npins,
pkgs ? import sources.nixpkgs { },
}:
let
inherit (pkgs.lib.fileset)
fileFilter
gitTrackedWith
intersection
toSource
;
in
{
package = pkgs.buildNpmPackage {
name = "metis";
src = toSource {
root = ./.;
fileset = intersection (gitTrackedWith { } ./.) (
fileFilter ({ name, hasExt, ... }: !(hasExt "nix") && name != "npins") ./.
);
};
npmDepsHash = "sha256-RbjWNVY8KlPP9ajQRnrsWhOZiiyyMGQSY39lmZnTC1I=";
installPhase = ''
cp -r public $out
'';
};
devShell = pkgs.mkShell {
name = "metis.dev";
packages = [ pkgs.nodejs ];
};
providers = {
eleves-ens = "cloud.eleves.ens.fr";
frama-agenda = "framagenda.org";
dgnum-nc = "cloud.dgnum.eu";
production = pkgs.npmlock2nix.build {
src = ./.;
installPhase = "cp -r public/build $out";
buildCommands = [ "npm run build" ];
};
shell = import ./shell.nix { inherit pkgs; };
}

12
nix/default.nix Normal file
View file

@ -0,0 +1,12 @@
# nix/default.nix
{ pkgs ? import <nixpkgs> {} }:
let
sources = import ./sources.nix;
in
import sources.nixpkgs {
overlays = [
(self: super: {
npmlock2nix = pkgs.callPackage sources.npmlock2nix { };
})
];
}

38
nix/sources.json Normal file
View file

@ -0,0 +1,38 @@
{
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c",
"sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "master",
"description": "Nix Packages collection",
"homepage": "",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "21.05",
"sha256": "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36",
"type": "tarball",
"url": "https://github.com/nixos/nixpkgs/archive/21.05.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"npmlock2nix": {
"branch": "master",
"description": null,
"homepage": null,
"owner": "nix-community",
"repo": "npmlock2nix",
"rev": "ff17a3c59233911f776d8d462d61d82a3e41df34",
"sha256": "0l624gkkpn1r0g48b204k0wcqm9cwy5rzd5mnxwfjhyjj1wg4nl7",
"type": "tarball",
"url": "https://github.com/nix-community/npmlock2nix/archive/ff17a3c59233911f776d8d462d61d82a3e41df34.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

174
nix/sources.nix Normal file
View file

@ -0,0 +1,174 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
fetch_local = spec: spec.path;
fetch_builtin-tarball = name: throw
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';
fetch_builtin-url = name: throw
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';
#
# Various helpers
#
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name:
(
concatMapStrings (s: if builtins.isList s then "-" else s)
(
builtins.split "[^[:alnum:]+._?=-]+"
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources: system:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs name spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git name spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
replace = name: drv:
let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {};
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

View file

@ -1,47 +0,0 @@
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
mkSource = spec:
assert spec ? type; let
path =
if spec.type == "Git" then mkGitSource spec
else if spec.type == "GitRelease" then mkGitSource spec
else if spec.type == "PyPi" then mkPyPiSource spec
else if spec.type == "Channel" then mkChannelSource spec
else builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };
mkGitSource = { repository, revision, url ? null, hash, ... }:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else assert repository.type == "Git"; builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};
mkPyPiSource = { url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource = { url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

View file

@ -1,11 +0,0 @@
{
"pins": {
"nixpkgs": {
"type": "Channel",
"name": "nixpkgs-unstable",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre696114.dfffb2e7a52d/nixexprs.tar.xz",
"hash": "15dj4hcx5wqcnxwfhh1gx2rpcwyip794bkmv0vpz4f01hibr7wd2"
}
},
"version": 3
}

3748
package-lock.json generated

File diff suppressed because it is too large Load diff

BIN
public.tar.gz Normal file

Binary file not shown.

View file

@ -4,7 +4,7 @@
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>Calendrier de la DGNum</title>
<title>Calendrier du Club Réseau</title>
<link rel='icon' href='/favicon.svg'>
<link rel='stylesheet' href='/global.css'>

View file

@ -1 +1,5 @@
(import ./. { }).devShell
{ pkgs ? import ./nix { } }:
pkgs.npmlock2nix.shell {
src = ./.;
nodejs = pkgs.nodejs-14_x;
}

View file

@ -102,7 +102,6 @@
title: room
}))
),
filterResourcesWithEvents: true,
height: '100%',
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
nowIndicator: true,
@ -142,6 +141,8 @@
trigger: 'hover',
placement: 'top'
});
} else {
info.el.style.display = "none"
}
},
viewDidMount: arg => {
@ -205,12 +206,6 @@
<FullCalendar bind:this={calendar} options={$options} />
<EventModal event={$event} open={openModal} {toggle} />
<script
defer
data-domain="calendrier.dgnum.eu"
src="https://analytics.dgnum.eu/js/script.js"
></script>
</div>
<style>

View file

@ -17,7 +17,7 @@
<ModalBody>
<p>Calendrier commun de la vie étudiante de l'ENS</p>
<b>Comment rajouter son calendrier&nbsp;:</b>
<b>Comment rajouter son calendrier :</b>
<ul>
<li>
Utiliser un NextCloud, idéalement
@ -26,18 +26,15 @@
</li>
<li>Créer un calendrier dessus, créer un lien de partage public.</li>
<li>
Envoyer le lien de partage public à la DGNum<br />
(calendrier [at] dgnum [.] eu) pour faire une requête d'ajout.
Envoyer le lien de partage public au Club Réseau<br />
(club-reseau [at] lists [.] ens [.] psl [.] eu) pour faire une requête d'ajout.
</li>
</ul>
<p>Code source&nbsp;:
<a href="https://git.dgnum.eu/DGNum/metis">https://git.dgnum.eu/DGNum/metis</a>
</p>
</ModalBody>
<ModalFooter>
<Icon name="balloon-heart" class="text-danger fs-5" />
<span class="fs-7">Propulsé par la <a href="https://dgnum.eu">Délégation Générale Numérique</a></span>
<span class="fs-7">Propulsé par le Club Réseau de l'ENS</span>
</ModalFooter>
</Modal>

View file

@ -190,6 +190,14 @@ function fcEventFromjCalEvent(cal) {
}
}
function mkEventsFromCalendar(id, cal) {
return fetchCalendar(id, cal).then(calendar => {
if (calendar[0] !== 'vcalendar') return
const cal = new Calendar(id, calendar)
return cal.events.map(fcEventFromjCalEvent(cal))
})
}
export function mkSource(name) {
const calendarId = calendarsByName[name]
if (!calendarId) return null