Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/global/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ let packages = "/packages"
let packages_search = "/packages/search"
let packages_autocomplete_fragment = "/packages/autocomplete"
let with_hash = Option.fold ~none:"/p" ~some:(( ^ ) "/u/")
let package ?hash v = with_hash hash ^ "/" ^ v
let package_docs v = "/p/" ^ v ^ "/doc"
let with_version = Option.value ~default:"latest"
let with_page p = if p = "" then p else "/" ^ p
let with_page p = if p = "" then "" else "/" ^ p

let package_with_version ?version ?hash ?(page = "") v =
with_hash hash ^ "/" ^ v ^ "/" ^ with_version version ^ with_page page
let package_overview ?version ?hash name =
with_hash hash ^ "/" ^ name ^ "/" ^ with_version version

let package_doc ?hash ?version ?(page = "index.html") v =
with_hash hash ^ "/" ^ v ^ "/" ^ with_version version ^ "/doc/" ^ page
let package_documentation ?hash ?version ?(page = "index.html") name =
with_hash hash ^ "/" ^ name ^ "/" ^ with_version version ^ "/doc/" ^ page

let package_file ?version ?hash ~filepath name =
with_hash hash ^ "/" ^ name ^ "/" ^ with_version version ^ "/" ^ filepath

let community = "/community"
let success_story v = "/success-stories/" ^ v
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/components/navmap.eml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let render
<% (match maptoc with [] -> %>
<span class="block py-2 text-gray-700">Package contains no libraries</span>
<% | _ -> %>
<a class="py-1 font-medium text-body-600 hover:text-orange-600 transition-colors" href="<%s Url.package_doc package.name ?version %>">
<a class="py-1 font-medium text-body-600 hover:text-orange-600 transition-colors" href="<%s Url.package_documentation package.name ?version %>">
package <%s package.name %>
</a>
<ul>
Expand Down
8 changes: 4 additions & 4 deletions src/ocamlorg_frontend/components/package_breadcrumbs.eml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ let render_package_and_version
let version = Package.url_version package in
let url (version : string option) =
match path with
| Overview _ -> Url.package_with_version package.name ?version
| Documentation _ -> Url.package_doc package.name ?version ?hash ?page
| Overview _ -> Url.package_overview package.name ?version
| Documentation _ -> Url.package_documentation package.name ?version ?hash ?page
in
let version_options v =
<% if v = package.latest_version then ( %>
Expand All @@ -50,7 +50,7 @@ let render_package_and_version
in
<li>
<h1 class="inline text-base">
<a class="font-semibold underline" href="<%s Url.package_with_version package.name ?version %>"><%s package.name %></a>
<a class="font-semibold underline" href="<%s Url.package_overview package.name ?version %>"><%s package.name %></a>
</h1>
</li>
<li>
Expand Down Expand Up @@ -101,7 +101,7 @@ let render_docs_path_breadcrumbs
<ul class="flex flex-wrap gap-x-2 text-base leading-8 package-breadcrumbs">
<%s! render_package_and_version ~path:(Documentation path) ?page ?hash package %>
<li>
<a class="underline font-semibold" href="<%s! Url.package_doc package.name ?version %>">Documentation</a>
<a class="underline font-semibold" href="<%s! Url.package_documentation package.name ?version %>">Documentation</a>
</li>
<% (match path with
| Index -> %>
Expand Down
9 changes: 9 additions & 0 deletions src/ocamlorg_frontend/package.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type version = Latest | Specific of string
type documentation_status = Success | Failure | Unknown

type package = {
name : string;
Expand All @@ -13,6 +14,14 @@ type package = {
authors : Ood.Opam_user.t list;
maintainers : Ood.Opam_user.t list;
publication : float;
homepages : string list;
source : (string * string list) option;
(* TODO: these should be part of package.json coming from voodoo, but they
currently aren't

documentation_status : documentation_status; readme_filename : string
option; changes_filename : string option; license_filename : string
option;*)
}

let specific_version package =
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/pages/package_documentation.eml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Package_layout.render
~package
~path
?page
~canonical:(Url.package_doc package.name ~version:(Package.specific_version package) ~page:(Url.package_doc ?version:(Some (Package.specific_version package)) package.name))
~canonical:(Url.package_documentation package.name ~version:(Package.specific_version package) ~page:(Url.package_documentation ?version:(Some (Package.specific_version package)) package.name))
~styles:["css/main.css"; "css/doc.css"] @@
<div x-data="{ open: false, sidebar: window.innerWidth >= 1024 && true, showOnMobile: false}" @resize.window="sidebar = window.innerWidth >= 1024" x-on:close-sidebar="sidebar=window.innerWidth >= 1024 && true">
<button :title='(sidebar? "close" : "open")+" sidebar"' class="flex items-center bg-primary-600 p-3 z-30 rounded-full text-white shadow-md bottom-20 fixed lg:hidden right-10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Package_layout.render
<p class="mt-1 text-base text-gray-500">We're sorry, for some reason we don't have the documentation for this package.</p>
</div>
<div class="mt-10 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6">
<a href="<%s Url.package_with_version package.name ?version %>"
<a href="<%s Url.package_overview package.name ?version %>"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500">
Go To Package Overview
</a>
Expand Down
47 changes: 22 additions & 25 deletions src/ocamlorg_frontend/pages/package_overview.eml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
type documentation_status =
| Success
| Failure
| Unknown

let side_box_link ~href ~title ~icon_html =
<a href="<%s href %>" class="flex items-center py-2 px-4 hover:text-primary-600">
<%s! icon_html %>
Expand All @@ -11,22 +6,24 @@ let side_box_link ~href ~title ~icon_html =

let num_of_users_to_show = 4

type sidebar_data = {
documentation_status : Package.documentation_status;
readme_filename : string option;
changes_filename : string option;
license_filename : string option;
}

let render
~documentation_status
~(sidebar_data: sidebar_data)
~content
~content_title
~dependencies
~rev_dependencies
~conflicts
~homepages
~source
~readme_filename
~changes_filename
~license_filename
(package : Package.package) =
let render_dependency ~version ~name ~cstr =
<li class="flex m-0 space-x-3 py-2 px-4 hover:bg-gray-100">
<a href="<%s Url.package_with_version name ?version %>" class="text-primary-600 hover:underline">
<a href="<%s Url.package_overview name ?version %>" class="text-primary-600 hover:underline">
<%s name %>
</a>
<% match cstr with None -> () | Some cstr -> %>
Expand Down Expand Up @@ -73,7 +70,7 @@ let specific_version = Package.specific_version package in
Package_layout.render
~title:(Printf.sprintf "%s %s · OCaml Package" package.name (Package.render_version package))
~description:(Printf.sprintf "%s %s: %s" package.name (Package.render_version package) package.synopsis)
~canonical:(Url.package_with_version package.name ~version:specific_version)
~canonical:(Url.package_overview package.name ~version:specific_version)
~package
~path:(Overview content_title) @@
<div class="flex md:space-x-4 xl:space-x-12 flex-col md:flex-row justify-between">
Expand Down Expand Up @@ -163,33 +160,33 @@ Package_layout.render
</div>
</div>
<div class="flex flex-col mt-8 text-body-400">
<% (match documentation_status with
<% (match sidebar_data.documentation_status with
| Success -> %>
<a href="<%s Url.package_doc package.name ?version %>" class="px-4 h-10 items-center mb-2 rounded-md bg-primary-600 text-white flex font-bold hover:underline">
<a href="<%s Url.package_documentation package.name ?version %>" class="px-4 h-10 items-center mb-2 rounded-md bg-primary-600 text-white flex font-bold hover:underline">
<%s! Icons.documentation "w-6 h-6 mr-2 inline-block" %>
Documentation
</a>
<% | Unknown -> ( %>
<a href="<%s Url.package_doc package.name ?version %>" class="p-4 mb-2 flex gap-x-2 bg-background-default text-gray-600 font-semibold text-base">
<a href="<%s Url.package_documentation package.name ?version %>" class="p-4 mb-2 flex gap-x-2 bg-background-default text-gray-600 font-semibold text-base">
<%s! Icons.error "" %>
Documentation status is unknown.
</a><% )
| Failure -> ( %>
<a href="<%s Url.package_doc package.name ?version %>" class="p-4 mb-2 flex gap-x-2 bg-background-default text-gray-600 font-semibold text-base">
<a href="<%s Url.package_documentation package.name ?version %>" class="p-4 mb-2 flex gap-x-2 bg-background-default text-gray-600 font-semibold text-base">
<%s! Icons.error "" %>
Documentation failed to build.
</a><% ));%>
<% homepages |> List.iter (fun homepage -> %>
<% package.homepages |> List.iter (fun homepage -> %>
<%s! side_box_link ~icon_html:(Icons.package_homepage "h-4 w-4 mr-2 inline-block") ~href:homepage ~title:(Utils.host_of_uri homepage) %>
<% ); %>
<% (match readme_filename with Some readme_filename -> %>
<%s! side_box_link ~icon_html:(Icons.changelog "h-4 w-4 mr-2 inline-block") ~href:(Url.package_with_version package.name ?version ~page:(readme_filename ^ ".html")) ~title:"Readme" %>
<% (match sidebar_data.readme_filename with Some readme_filename -> %>
<%s! side_box_link ~icon_html:(Icons.changelog "h-4 w-4 mr-2 inline-block") ~href:(Url.package_file package.name ?version ~filepath:(readme_filename ^ ".html")) ~title:"Readme" %>
<% | _ -> ()); %>
<% (match changes_filename with Some changes_filename -> %>
<%s! side_box_link ~icon_html:(Icons.changelog "h-4 w-4 mr-2 inline-block") ~href:(Url.package_with_version package.name ?version ~page:(changes_filename ^ ".html")) ~title:"Changelog" %>
<% (match sidebar_data.changes_filename with Some changes_filename -> %>
<%s! side_box_link ~icon_html:(Icons.changelog "h-4 w-4 mr-2 inline-block") ~href:(Url.package_file package.name ?version ~filepath:(changes_filename ^ ".html")) ~title:"Changelog" %>
<% | _ -> ()); %>
<% (match license_filename with Some license_filename -> %>
<%s! side_box_link ~icon_html:(Icons.license "h-4 w-4 mr-2 inline-block") ~href:(Url.package_with_version package.name ?version ~page:(license_filename ^ ".html")) ~title:( package.license ^ " License") %>
<% (match sidebar_data.license_filename with Some license_filename -> %>
<%s! side_box_link ~icon_html:(Icons.license "h-4 w-4 mr-2 inline-block") ~href:(Url.package_file package.name ?version ~filepath:(license_filename ^ ".html")) ~title:( package.license ^ " License") %>
<% | _ -> ()); %>
<%s! side_box_link ~icon_html:(Icons.edit "h-4 w-4 mr-2 inline-block") ~href:(Url.github_opam_file package.name specific_version) ~title:"Edit opam file" %>
</div>
Expand All @@ -200,7 +197,7 @@ Package_layout.render
<h2 class="mt-8 font-semibold text-base text-body-400">Maintainers</h2>
<%s! render_user_list package.maintainers %>

<% match source with
<% match package.source with
| None -> ()
| Some (uri, checksums) -> %>
<h2 class="font-semibold mt-8 mb-3 text-base text-body-400">Sources</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/pages/packages.eml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let href_package pkg = Url.package_with_version pkg.name ?version:(Package.url_version pkg)
let href_package pkg = Url.package_overview pkg.name ?version:(Package.url_version pkg)

let render (stats : Package.packages_stats option) (featured_packages : Package.package list) =
Layout.render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let render
x-init="max=<%s string_of_int i %>"
id="package-autocomplete-<%s string_of_int i %>-0"
:aria-selected="row == <%s string_of_int i %> && col == 0"
href="<%s Url.package_with_version package.name %>"
href="<%s Url.package_overview package.name %>"
:class='{ "bg-background-mid-blue text-white": row == <%s string_of_int i %> && col == 0, "text-primary-600": row != <%s string_of_int i %> || col != 0}'
class="flex-grow px-2 py-2 leading-6 font-semibold hover:bg-primary-100 inline-block"
>
Expand All @@ -57,7 +57,7 @@ let render
<a
id="package-autocomplete-<%s string_of_int i %>-1"
:aria-selected="row == <%s string_of_int i %> && col == 1"
href="<%s Url.package_doc package.name %>"
href="<%s Url.package_documentation package.name %>"
:class='{ "bg-background-mid-blue text-white": row == <%s string_of_int i %> && col == 1}'
class="justify-self-end px-2 py-2 leading-6 font-semibold hover:bg-primary-100">
docs
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/pages/packages_search.eml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let render ~total ~search (packages : Package.package list) = Layout.render ~tit
<% packages |> List.iter (fun (package : Package.package) -> %>
<li class="border-gray-200 border-t mt-4 pt-4 mb-2 space-y-2">
<a
href="<%s Url.package_with_version package.name %>"
href="<%s Url.package_overview package.name %>"
class="text-lg font-semibold text-primary-600 inline-block"
>
<%s package.name %>
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/pages/releases.eml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Layout.render
<a href="<%s Url.release release.version %>" class="text-primary-600 font-medium block">
Release Notes
</a>
<a href="<%s Url.package_with_version "ocaml" ~version:release.version %>" class="text-primary-600 font-medium block">
<a href="<%s Url.package_overview "ocaml" ~version:release.version %>" class="text-primary-600 font-medium block">
OCaml Package
</a>
<a href="<%s Url.manual_with_version release.version %>" class="text-primary-600 font-medium block">
Expand Down
Loading