diff options
author | Alban Gruin | 2021-09-19 12:29:50 +0200 |
---|---|---|
committer | Alban Gruin | 2021-09-19 12:39:11 +0200 |
commit | 4b05babc1e5a4466028d7d210d9a7920a4a401f7 (patch) | |
tree | eda874f6ab2c8b613d09546a62064e0172c88df8 /src/pages.ml | |
parent | d489f3743cca9e6fb3dddbf10bbcb1e188b09f0b (diff) |
server, ics, pages: allow to generate ICS from modules
This adds the ability to generate an ICS file from a module ID, and to
filter it based on its groups.
To do this, you can enter a module ID on the frontpage. Then, µCS will
fetch the timetable, then return a page where one can select the
group(s) they want to filter (this is enabled by the new
Ics.get_all_groups function). Then, µCS is able to generate a link to
that calendar, not unlike with a single group ID.
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'src/pages.ml')
-rw-r--r-- | src/pages.ml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pages.ml b/src/pages.ml index 2cb0aa4..feb2769 100644 --- a/src/pages.ml +++ b/src/pages.ml @@ -48,6 +48,11 @@ let main = common {| <input type="text" name="group" id="id_group" required /> <input type="submit" value="Générer un ICS" /> </form> + <form action="/filter" method="get"> + <label for="id_module">ID du module</label> + <input type="text" name="module" id="id_module" required /> + <input type="submit" value="Générer un ICS" /> + </form> </section> <section> <p> @@ -99,3 +104,18 @@ let link lnk = <a href="|} ^ lnk ^ {|">|} ^ lnk ^ {|</a> </section> |} + +let select module_id groups = + let options = + Seq.map (fun group -> " <option>" ^ escape group ^ "</option>") groups + |> List.of_seq + |> String.concat "\n" in + common @@ {| + <form method="post" action="/lnk"> + <select name="groups" multiple> +|} ^ options ^ {| + </select> + <input type="hidden" name="module" value="|} ^ module_id ^ {|" /> + <input type="submit" text="Valider" /> + </form> +|} |