diff --git a/.dockerignore b/.dockerignore index b92e5a54cb..9b3088e619 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,4 +10,3 @@ !tailwind.config.js !init-cache !.git -!v2 diff --git a/Dockerfile b/Dockerfile index 7c6342fd5b..4d7382f030 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ COPY --from=build /home/opam/_build/default/src/ocamlorg_web/bin/main.exe /bin/s COPY playground/asset playground/asset RUN git clone https://github.com/ocaml-web/html-compiler-manuals /manual -ADD v2 /v2 +ADD data/v2 /v2 RUN git config --global --add safe.directory /var/opam-repository diff --git a/v2/conferences/ocaml/2013/call.md b/data/v2/conferences/ocaml/2013/call.md similarity index 100% rename from v2/conferences/ocaml/2013/call.md rename to data/v2/conferences/ocaml/2013/call.md diff --git a/v2/conferences/ocaml/2013/index.md b/data/v2/conferences/ocaml/2013/index.md similarity index 100% rename from v2/conferences/ocaml/2013/index.md rename to data/v2/conferences/ocaml/2013/index.md diff --git a/v2/conferences/ocaml/2013/program.md b/data/v2/conferences/ocaml/2013/program.md similarity index 100% rename from v2/conferences/ocaml/2013/program.md rename to data/v2/conferences/ocaml/2013/program.md diff --git a/v2/conferences/ocaml/2013/proposals/core-bench.pdf b/data/v2/conferences/ocaml/2013/proposals/core-bench.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/core-bench.pdf rename to data/v2/conferences/ocaml/2013/proposals/core-bench.pdf diff --git a/v2/conferences/ocaml/2013/proposals/ctypes.pdf b/data/v2/conferences/ocaml/2013/proposals/ctypes.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/ctypes.pdf rename to data/v2/conferences/ocaml/2013/proposals/ctypes.pdf diff --git a/v2/conferences/ocaml/2013/proposals/formats-as-gadts.pdf b/data/v2/conferences/ocaml/2013/proposals/formats-as-gadts.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/formats-as-gadts.pdf rename to data/v2/conferences/ocaml/2013/proposals/formats-as-gadts.pdf diff --git a/v2/conferences/ocaml/2013/proposals/frenetic.pdf b/data/v2/conferences/ocaml/2013/proposals/frenetic.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/frenetic.pdf rename to data/v2/conferences/ocaml/2013/proposals/frenetic.pdf diff --git a/v2/conferences/ocaml/2013/proposals/goji.pdf b/data/v2/conferences/ocaml/2013/proposals/goji.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/goji.pdf rename to data/v2/conferences/ocaml/2013/proposals/goji.pdf diff --git a/v2/conferences/ocaml/2013/proposals/gpgpu.pdf b/data/v2/conferences/ocaml/2013/proposals/gpgpu.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/gpgpu.pdf rename to data/v2/conferences/ocaml/2013/proposals/gpgpu.pdf diff --git a/v2/conferences/ocaml/2013/proposals/injectivity.pdf b/data/v2/conferences/ocaml/2013/proposals/injectivity.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/injectivity.pdf rename to data/v2/conferences/ocaml/2013/proposals/injectivity.pdf diff --git a/v2/conferences/ocaml/2013/proposals/merlin.pdf b/data/v2/conferences/ocaml/2013/proposals/merlin.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/merlin.pdf rename to data/v2/conferences/ocaml/2013/proposals/merlin.pdf diff --git a/v2/conferences/ocaml/2013/proposals/ocamlot.pdf b/data/v2/conferences/ocaml/2013/proposals/ocamlot.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/ocamlot.pdf rename to data/v2/conferences/ocaml/2013/proposals/ocamlot.pdf diff --git a/v2/conferences/ocaml/2013/proposals/optimizations.pdf b/data/v2/conferences/ocaml/2013/proposals/optimizations.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/optimizations.pdf rename to data/v2/conferences/ocaml/2013/proposals/optimizations.pdf diff --git a/v2/conferences/ocaml/2013/proposals/platform.pdf b/data/v2/conferences/ocaml/2013/proposals/platform.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/platform.pdf rename to data/v2/conferences/ocaml/2013/proposals/platform.pdf diff --git a/v2/conferences/ocaml/2013/proposals/profiling-memory.pdf b/data/v2/conferences/ocaml/2013/proposals/profiling-memory.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/profiling-memory.pdf rename to data/v2/conferences/ocaml/2013/proposals/profiling-memory.pdf diff --git a/v2/conferences/ocaml/2013/proposals/runtime-types.pdf b/data/v2/conferences/ocaml/2013/proposals/runtime-types.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/runtime-types.pdf rename to data/v2/conferences/ocaml/2013/proposals/runtime-types.pdf diff --git a/v2/conferences/ocaml/2013/proposals/weather-related-data.pdf b/data/v2/conferences/ocaml/2013/proposals/weather-related-data.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/weather-related-data.pdf rename to data/v2/conferences/ocaml/2013/proposals/weather-related-data.pdf diff --git a/v2/conferences/ocaml/2013/proposals/wxocaml.pdf b/data/v2/conferences/ocaml/2013/proposals/wxocaml.pdf similarity index 100% rename from v2/conferences/ocaml/2013/proposals/wxocaml.pdf rename to data/v2/conferences/ocaml/2013/proposals/wxocaml.pdf diff --git a/v2/conferences/ocaml/2013/slides/bourgoin.pdf b/data/v2/conferences/ocaml/2013/slides/bourgoin.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/bourgoin.pdf rename to data/v2/conferences/ocaml/2013/slides/bourgoin.pdf diff --git a/v2/conferences/ocaml/2013/slides/bozman.pdf b/data/v2/conferences/ocaml/2013/slides/bozman.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/bozman.pdf rename to data/v2/conferences/ocaml/2013/slides/bozman.pdf diff --git a/v2/conferences/ocaml/2013/slides/canou.pdf b/data/v2/conferences/ocaml/2013/slides/canou.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/canou.pdf rename to data/v2/conferences/ocaml/2013/slides/canou.pdf diff --git a/v2/conferences/ocaml/2013/slides/carty.pdf b/data/v2/conferences/ocaml/2013/slides/carty.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/carty.pdf rename to data/v2/conferences/ocaml/2013/slides/carty.pdf diff --git a/v2/conferences/ocaml/2013/slides/chambart.pdf b/data/v2/conferences/ocaml/2013/slides/chambart.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/chambart.pdf rename to data/v2/conferences/ocaml/2013/slides/chambart.pdf diff --git a/v2/conferences/ocaml/2013/slides/garrigue.pdf b/data/v2/conferences/ocaml/2013/slides/garrigue.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/garrigue.pdf rename to data/v2/conferences/ocaml/2013/slides/garrigue.pdf diff --git a/v2/conferences/ocaml/2013/slides/guha.pdf b/data/v2/conferences/ocaml/2013/slides/guha.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/guha.pdf rename to data/v2/conferences/ocaml/2013/slides/guha.pdf diff --git a/v2/conferences/ocaml/2013/slides/henry.pdf b/data/v2/conferences/ocaml/2013/slides/henry.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/henry.pdf rename to data/v2/conferences/ocaml/2013/slides/henry.pdf diff --git a/v2/conferences/ocaml/2013/slides/james.pdf b/data/v2/conferences/ocaml/2013/slides/james.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/james.pdf rename to data/v2/conferences/ocaml/2013/slides/james.pdf diff --git a/v2/conferences/ocaml/2013/slides/lefessant.pdf b/data/v2/conferences/ocaml/2013/slides/lefessant.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/lefessant.pdf rename to data/v2/conferences/ocaml/2013/slides/lefessant.pdf diff --git a/v2/conferences/ocaml/2013/slides/leroy.pdf b/data/v2/conferences/ocaml/2013/slides/leroy.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/leroy.pdf rename to data/v2/conferences/ocaml/2013/slides/leroy.pdf diff --git a/v2/conferences/ocaml/2013/slides/madhavapeddy.pdf b/data/v2/conferences/ocaml/2013/slides/madhavapeddy.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/madhavapeddy.pdf rename to data/v2/conferences/ocaml/2013/slides/madhavapeddy.pdf diff --git a/v2/conferences/ocaml/2013/slides/padioleau.pdf b/data/v2/conferences/ocaml/2013/slides/padioleau.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/padioleau.pdf rename to data/v2/conferences/ocaml/2013/slides/padioleau.pdf diff --git a/v2/conferences/ocaml/2013/slides/sheets.pdf b/data/v2/conferences/ocaml/2013/slides/sheets.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/sheets.pdf rename to data/v2/conferences/ocaml/2013/slides/sheets.pdf diff --git a/v2/conferences/ocaml/2013/slides/vaugon.pdf b/data/v2/conferences/ocaml/2013/slides/vaugon.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/vaugon.pdf rename to data/v2/conferences/ocaml/2013/slides/vaugon.pdf diff --git a/v2/conferences/ocaml/2013/slides/white.pdf b/data/v2/conferences/ocaml/2013/slides/white.pdf similarity index 100% rename from v2/conferences/ocaml/2013/slides/white.pdf rename to data/v2/conferences/ocaml/2013/slides/white.pdf diff --git a/v2/conferences/ocaml/2013/talks/index.md b/data/v2/conferences/ocaml/2013/talks/index.md similarity index 100% rename from v2/conferences/ocaml/2013/talks/index.md rename to data/v2/conferences/ocaml/2013/talks/index.md diff --git a/src/ocamlorg_data/data.ml b/src/ocamlorg_data/data.ml index bcaae984b3..57ff89591b 100644 --- a/src/ocamlorg_data/data.ml +++ b/src/ocamlorg_data/data.ml @@ -238,3 +238,5 @@ module Conference = struct let all = Conference.all let get_by_slug slug = List.find_opt (fun x -> String.equal slug x.slug) all end + +module V2 = V2 diff --git a/src/ocamlorg_data/data.mli b/src/ocamlorg_data/data.mli index 655415ad3f..2146d5e1d0 100644 --- a/src/ocamlorg_data/data.mli +++ b/src/ocamlorg_data/data.mli @@ -211,3 +211,7 @@ module Conference : sig val all : t list val get_by_slug : string -> t option end + +module V2 : sig + include module type of V2 +end diff --git a/src/ocamlorg_data/dune b/src/ocamlorg_data/dune index ac90548237..c0b610ecd2 100644 --- a/src/ocamlorg_data/dune +++ b/src/ocamlorg_data/dune @@ -340,3 +340,22 @@ (with-stdout-to %{target} (run %{ood_gen} conferences))))) + +(rule + (target v2.ml) + (deps + (:v2 + (source_tree %{workspace_root}/data/v2))) + (action + (chdir + %{workspace_root}/data/v2 + (with-stdout-to + %{target} + (progn + (echo "let assets = [") + (pipe-stdout + (run find . -type f) + (run cut -b 2-) + (run sed "s/^/\"/") + (run sed "s/$/\";/")) + (echo "]")))))) diff --git a/src/ocamlorg_web/lib/config.ml b/src/ocamlorg_web/lib/config.ml index e0b85393f5..6b31272ae1 100644 --- a/src/ocamlorg_web/lib/config.ml +++ b/src/ocamlorg_web/lib/config.ml @@ -8,4 +8,4 @@ let http_port = env_with_default "OCAMLORG_HTTP_PORT" "8080" |> int_of_string let manual_path = env_with_default "OCAMLORG_MANUAL_PATH" "http-compiler-manuals" -let v2_path = env_with_default "OCAMLORG_V2_PATH" "v2" +let v2_path = env_with_default "OCAMLORG_V2_PATH" "data/v2" diff --git a/src/ocamlorg_web/lib/redirection.ml b/src/ocamlorg_web/lib/redirection.ml index 4be1fcdb2e..0aeb4966ef 100644 --- a/src/ocamlorg_web/lib/redirection.ml +++ b/src/ocamlorg_web/lib/redirection.ml @@ -1,19 +1,28 @@ open Ocamlorg -let rec files path = - if Sys.is_regular_file path then [ path ] - else - Sys.readdir path |> Array.to_list - |> List.concat_map (fun p -> files @@ path ^ "/" ^ p) - let v2_assets = - let f p = - let p = String.concat "/" p in - ("meetings/" ^ p, Url.conference p) + let confs = + [ "/conference/"; "/meetings/"; "/meeting/"; "/workshops/"; "/workshop/" ] + in + let redirects confs target source = + let f s = (s ^ source, target) in + List.map f confs + in + let f path = + let open String in + if starts_with ~prefix:"/conferences/" path && ends_with ~suffix:".pdf" path + then redirects confs path (sub path 13 (length path - 13)) + else [] in - Config.v2_path |> files - |> List.map (fun s -> - s |> String.split_on_char '/' |> List.tl |> List.tl |> f) + let g conf = + let year = String.sub conf.Data.Conference.date 0 4 in + [ ""; "/index.html" ] + |> List.concat_map (fun s -> + redirects ("/conferences/" :: confs) + ("/conferences/" ^ conf.slug) + ("ocaml/" ^ year ^ s)) + in + List.concat_map f Data.V2.assets @ List.concat_map g Data.Conference.all let from_v2 = [ @@ -207,88 +216,27 @@ let from_v2 = ("/meetings/index.fr.html", Url.conferences); ("/meetings/index.html", Url.conferences); ("/meetings", Url.conferences); - ( "/meetings/ocaml/2008/index.html", - Url.conference "ocaml-users-and-developers-conference-2008" ); - ( "/meetings/ocaml/2008", - Url.conference "ocaml-users-and-developers-conference-2008" ); - ( "/meetings/ocaml/2008/index.html", - Url.conference "ocaml-users-and-developers-conference-2008" ); - ( "/meetings/ocaml/2008", - Url.conference "ocaml-users-and-developers-conference-2008" ); - ( "/meetings/ocaml/2009/index.html", - Url.conference "ocaml-users-and-developers-conference-2009" ); - ( "/meetings/ocaml/2009", - Url.conference "ocaml-users-and-developers-conference-2009" ); - ( "/meetings/ocaml/2010/index.html", - Url.conference "ocaml-users-and-developers-conference-2010" ); - ( "/meetings/ocaml/2010", - Url.conference "ocaml-users-and-developers-conference-2010" ); - ( "/meetings/ocaml/2011/index.html", - Url.conference "ocaml-users-and-developers-conference-2011" ); - ( "/meetings/ocaml/2011", - Url.conference "ocaml-users-and-developers-conference-2011" ); - ( "/meetings/ocaml/2012/index.html", - Url.conference "ocaml-users-and-developers-conference-2012" ); ( "/meetings/ocaml/2013/call.html", Url.conference "ocaml-users-and-developers-conference-2013" ); - ( "/meetings/ocaml/2013", - Url.conference "ocaml-users-and-developers-conference-2013" ); - ( "/meetings/ocaml/2013/index.html", - Url.conference "ocaml-users-and-developers-conference-2013" ); ( "/meetings/ocaml/2013/program.html", Url.conference "ocaml-users-and-developers-conference-2013" ); - ( "/meetings/ocaml/2013", - Url.conference "ocaml-users-and-developers-conference-2013" ); ( "/meetings/ocaml/2013/talks/index.html", Url.conference "ocaml-users-and-developers-conference-2013" ); ( "/meetings/ocaml/2014/cfp.html", Url.conference "ocaml-users-and-developers-conference-2014" ); - ( "/meetings/ocaml/2014", - Url.conference "ocaml-users-and-developers-conference-2014" ); - ( "/meetings/ocaml/2014/index.html", - Url.conference "ocaml-users-and-developers-conference-2014" ); ( "/meetings/ocaml/2014/ocaml2014_10.html", Url.conference "ocaml-users-and-developers-conference-2014" ); ( "/meetings/ocaml/2014/program.html", Url.conference "ocaml-users-and-developers-conference-2014" ); ( "/meetings/ocaml/2015/cfp.html", Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2015", - Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2015/index.html", - Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2015", - Url.conference "ocaml-users-and-developers-conference-2015" ); ( "/meetings/ocaml/2015/program.html", Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2015", - Url.conference "ocaml-users-and-developers-conference-2015" ); ( "/meetings/ocaml/2015/program.txt", Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2015", - Url.conference "ocaml-users-and-developers-conference-2015" ); - ( "/meetings/ocaml/2016/index.html", - Url.conference "ocaml-users-and-developers-conference-2016" ); - ( "/meetings/ocaml/2016", - Url.conference "ocaml-users-and-developers-conference-2016" ); - ( "/meetings/ocaml/2017/index.html", - Url.conference "ocaml-users-and-developers-conference-2017" ); - ( "/meetings/ocaml/2017", - Url.conference "ocaml-users-and-developers-conference-2017" ); - ( "/meetings/ocaml/2018/index.html", - Url.conference "ocaml-users-and-developers-conference-2018" ); - ( "/meetings/ocaml/2018", - Url.conference "ocaml-users-and-developers-conference-2018" ); - ( "/meetings/ocaml/2019/index.html", - Url.conference "ocaml-users-and-developers-conference-2019" ); - ( "/meetings/ocaml/2019", - Url.conference "ocaml-users-and-developers-conference-2019" ); - ( "/meetings/ocaml/2020/index.html", - Url.conference "ocaml-users-and-developers-conference-2020" ); - ( "/meetings/ocaml/2020", - Url.conference "ocaml-users-and-developers-conference-2020" ); ("/meetings/ocaml/index.html", Url.conferences); ("/meetings/ocaml", Url.conferences); + ("/workshops", Url.conferences); ("/ocamllabs/index.html", Url.index); ("/ocamllabs", Url.index); ("/platform/index.html", Url.learn_platform); @@ -316,30 +264,6 @@ let make ?(permanent = false) t = Some (Dream.get origin (fun req -> Dream.redirect ~status req new_))) t) -let ocaml_workshops = - List.map - (fun (slug : string) -> - make ~permanent:true [ ("/workshop/" ^ slug, Url.conference slug) ]) - [ - "ocaml-users-and-developers-conference-2008"; - "ocaml-users-and-developers-conference-2009"; - "ocaml-users-and-developers-conference-2010"; - "ocaml-users-and-developers-conference-2011"; - "ocaml-users-and-developers-conference-2012"; - "ocaml-users-and-developers-conference-2013"; - "ocaml-users-and-developers-conference-2014"; - "ocaml-users-and-developers-conference-2015"; - "ocaml-users-and-developers-conference-2016"; - "ocaml-users-and-developers-conference-2017"; - "ocaml-users-and-developers-conference-2018"; - "ocaml-users-and-developers-conference-2019"; - "ocaml-users-and-developers-conference-2020"; - "ocaml-users-and-developers-conference-2020"; - "ocaml-users-and-developers-conference-2021"; - "ocaml-users-and-developers-conference-2022"; - "ocaml-users-and-developers-conference-2023"; - ] - let package req = let package = Dream.param req "name" in Dream.redirect req (Url.Package.overview package) @@ -350,22 +274,19 @@ let package_docs req = let t = Dream.scope "" [] - ([ - make ~permanent:true [ ("feed.xml", "planet.xml") ]; - make from_v2; - make ~permanent:true v2_assets; - make [ ("/blog", "/ocaml-planet") ]; - make ~permanent:true [ ("/opportunities", "/jobs") ]; - make ~permanent:true - [ ("/carbon-footprint", "/policies/carbon-footprint") ]; - make ~permanent:true [ ("/privacy-policy", "/policies/privacy-policy") ]; - make ~permanent:true - [ ("/code-of-conduct", "/policies/code-of-conduct") ]; - make ~permanent:true [ ("/opportunities", "/jobs") ]; - (* make ~permanent:false [ (Url.conferences, Url.community ^ - "#conferences") ]; *) - Dream.get "/p/:name" package; - Dream.get "/u/:hash/p/:name" package; - Dream.get "/p/:name/doc" package_docs; - ] - @ ocaml_workshops) + [ + make ~permanent:true [ ("feed.xml", "planet.xml") ]; + make ~permanent:true from_v2; + make ~permanent:true v2_assets; + make ~permanent:true [ ("/blog", "/ocaml-planet") ]; + make ~permanent:true [ ("/opportunities", "/jobs") ]; + make ~permanent:true + [ ("/carbon-footprint", "/policies/carbon-footprint") ]; + make ~permanent:true [ ("/privacy-policy", "/policies/privacy-policy") ]; + make ~permanent:true [ ("/code-of-conduct", "/policies/code-of-conduct") ]; + (* make ~permanent:false [ (Url.conferences, Url.community ^ + "#conferences") ]; *) + Dream.get "/p/:name" package; + Dream.get "/u/:hash/p/:name" package; + Dream.get "/p/:name/doc" package_docs; + ]