diff --git a/bin/main.ml b/bin/main.ml index b1ca2a0..82275b9 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -103,13 +103,42 @@ module Sync = struct let cmd = Cmd.v info term end +let find_latest_stable bundles = + bundles + |> List.filter_map (fun (b : Metadata.Bundle.t) -> + match b.tag with + | None -> None + | Some tag -> + (match Scanf.sscanf_opt tag "%d.%d.%d" (fun x y z -> x, y, z) with + | None -> None + | Some tup -> Some (tup, b))) + |> List.sort (fun ((maj, min, patch), _) ((maj', min', patch'), _) -> + (* reverse sort, biggest first *) + match Int.compare maj' maj with + | 0 -> + (match Int.compare min' min with + | 0 -> Int.compare patch' patch + | otherwise -> otherwise) + | otherwise -> otherwise) + |> function + | [] -> None + | (_, bundle) :: _ -> Some bundle +;; + module Http = struct let serve dev metadata_file port = let title = "Dune Nightly" in let base_url = Config.Server.url in let bundles = Metadata.import_from_json metadata_file in + let latest_release = + match find_latest_stable bundles with + | None -> "" + | Some bundle -> + (* guaranteed to exist at this point *) + Option.get bundle.tag + in let routes = - let main_page = Web.generate_main_page ~title ~base_url bundles in + let main_page = Web.generate_main_page ~title ~base_url ~latest_release bundles in Web.Route.empty |> Web.Route.add ~path:"/" main_page |> Web.Route.add ~path:"/index.html" main_page diff --git a/lib/component.mlx b/lib/component.mlx index 4eaf47f..2dc14be 100644 --- a/lib/component.mlx +++ b/lib/component.mlx @@ -1,6 +1,16 @@ module Info = struct - let curl_with_sh url = - Format.sprintf "curl -fsSL %s | sh" url |> JSX.string + let curl_with_sh ~url ~sh_args = + let sh_args = match sh_args with + | None -> "" + | Some x -> " " ^ x + in + Printf.sprintf "curl -fsSL %s | sh%s" url sh_args |> JSX.string + + let curl_with_sh_nightly ~url = curl_with_sh ~url ~sh_args:None + + let curl_with_sh_stable ~url ~version = + let sh_args = Some (Printf.sprintf "-s - --release %s" version) in + curl_with_sh ~url ~sh_args end module Link = struct @@ -25,43 +35,15 @@ end module Curl = struct let make ~script () =
- + script - - - +
+ +
+
+ +
end diff --git a/lib/container.mlx b/lib/container.mlx index ee5315f..736d4ab 100644 --- a/lib/container.mlx +++ b/lib/container.mlx @@ -33,7 +33,7 @@ let navbar () = "Share Feedback" "FAQs" "Manual Installation" - "Last Month Release History" + "Last Month Build History" @@ -58,7 +58,7 @@ let footer_info () = "Share Feedback" "FAQs" "Manual Installation" - "Last Month Release History" + "Last Month Build History"
diff --git a/lib/main.mlx b/lib/main.mlx index 6209cc4..fab14ea 100644 --- a/lib/main.mlx +++ b/lib/main.mlx @@ -38,15 +38,23 @@ let warning () =
-let getting_started ~install_url () = +let getting_started ~install_url ~latest_release:version () =
+

"Install Dune"

- "Copy & Install" + "Copy & Install (nightly)" +

+ + +

+ + "Copy & Install (stable)"

- + +

"Getting Started"

"You can create and run your first hello-world program using Dune like this"

@@ -237,7 +245,7 @@ let installation_target ~base_url ~bundle target = "Certificate" -let manual_installation ~base_url ~releases () = +let manual_installation ~base_url ~builds () =

"Manual Installation"

@@ -246,12 +254,12 @@ let manual_installation ~base_url ~releases () =

"Featured Downloads"

- "This is the latest release of the Dune nightly. See the " - "release history" - " section for all past releases." + "This is the latest build of the Dune nightly. See the " + "build history" + " section for all past builds."

    - (let bundle: Metadata.Bundle.t = releases |> List.hd in + (let bundle: Metadata.Bundle.t = builds |> List.hd in bundle.targets |> List.map (installation_target ~base_url ~bundle) |> JSX.list) @@ -259,7 +267,7 @@ let manual_installation ~base_url ~releases () =

    "Installing the binary"

    - "After downloading a binary release of Dune, make it executable and place it somewhere reachable by your PATH:" + "After downloading a binary build of Dune, make it executable and place it somewhere reachable by your PATH:"

    @@ -307,19 +315,19 @@ let release_information ~base_url ~bundle ~target () = -let release_history ~base_url ~releases () = +let build_history ~base_url ~builds () = let open Metadata in -
    +
    -

    "Last Month Release History"

    +

    "Last Month Build History"

    "Here is a list of the " - (JSX.int (List.length releases)) + (JSX.int (List.length builds)) " latest builds of the Dune nightly."

    ( - releases + builds |> List.map (fun (bundle: Bundle.t) -> let date = Bundle.get_date_string_from ~prefix:"nightly-" bundle in let summary = Format.sprintf "dune %s" date in @@ -347,15 +355,15 @@ let release_history ~base_url ~releases () =
    -let page ~base_url ~releases () = - let releases = Core.List.take 30 releases in +let page ~base_url ~latest_release ~builds () = + let builds = Core.List.take 30 builds in let install_url = Filename.concat base_url "install" in
    - + - - + +
    diff --git a/lib/web.ml b/lib/web.ml index add3e01..23f0015 100644 --- a/lib/web.ml +++ b/lib/web.ml @@ -1,7 +1,7 @@ let export_website_to_string ~title content = Container.page ~title content |> JSX.render -let generate_main_page ~title ~base_url releases = - Main.page ~base_url ~releases () |> export_website_to_string ~title +let generate_main_page ~title ~base_url ~latest_release builds = + Main.page ~base_url ~latest_release ~builds () |> export_website_to_string ~title ;; let generate_error_page ~title reason = diff --git a/static/install b/static/install index 6a11ef9..e50b832 100755 --- a/static/install +++ b/static/install @@ -41,6 +41,23 @@ success_bold() { printf "%b%s %b" "${Bold_Green}" "$*" "${Color_Off}" } +while [ "$#" -gt "0" ]; do + arg="$1" + shift + case "$arg" in + -r|--release) + if [ "$#" -eq "0" ]; then + error "--release must be passed an argument" + fi + release="$1" + shift + ;; + *) + error "Unknown argument: ${arg}" + ;; + esac +done + tildify() { case "$1" in "$HOME"/*) @@ -78,7 +95,13 @@ esac tar_target_name="dune-$target" tar_target="$tar_target_name.tar.gz" -dune_tar_uri="https://nightly.dune.build/latest/$target" + +release=${release:-nightly} +if [ "$release" = "nightly" ]; then + dune_tar_uri="https://nightly.dune.build/latest/${target}" +else + dune_tar_uri="https://nightly.dune.build/stable/${release}/${target}" +fi install_dir="$HOME/.local" bin_dir="${install_dir}/bin" @@ -345,4 +368,4 @@ fi # end of main } -main +main "$@" diff --git a/static/main.css b/static/main.css index ea95f89..5659e3b 100644 --- a/static/main.css +++ b/static/main.css @@ -554,6 +554,22 @@ video { --tw-contain-style: ; } +.container { + width: 100%; +} + +@media (min-width: 60em) { + .container { + max-width: 60em; + } +} + +@media (min-width: 80em) { + .container { + max-width: 80em; + } +} + .absolute { position: absolute; }