Unverified Commit ec5f65bf authored by zapashcanon's avatar zapashcanon
Browse files

first commit

parents
(lang dune 2.8)
(name osh)
(license ISC)
(authors "Léo Andrès <contact@ndrs.fr>")
(maintainers "Léo Andrès <contact@ndrs.fr>")
(source
(github ocamlpro/osh))
(generate_opam_files true)
(using menhir 2.1)
(package
(name osh)
(synopsis "TODO")
(description
"TODO")
(tags
(TODO))
(depends
(ocaml
(>= 4.08))
(dream (>= 1.0.0~alpha2))
(ocb (>= 0.1))
(bisect_ppx
(and
:with-test
(>= 2.6)
:dev))))
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "TODO"
description: "TODO"
maintainer: ["Léo Andrès <contact@ndrs.fr>"]
authors: ["Léo Andrès <contact@ndrs.fr>"]
license: "ISC"
tags: ["TODO"]
homepage: "https://github.com/ocamlpro/osh"
bug-reports: "https://github.com/ocamlpro/osh/issues"
depends: [
"dune" {>= "2.8"}
"ocaml" {>= "4.08"}
"dream" {>= "1.0.0~alpha2"}
"ocb" {>= "0.1"}
"bisect_ppx" {with-test & >= "2.6" & dev}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ocamlpro/osh.git"
This diff is collapsed.
body {
padding-top: 3rem;
padding-bottom: 3rem;
color: #5a5a5a;
background-color: #EEEEEE;
line-height: 1.6;
font-size: 18px;
}
.featurette-divider {
margin: 5rem 0;
}
.cardheader,.card-body {
background-color: #EEEEEE;
}
.card-text {
text-align: justify;
}
.card-image {
max-width: 200px;
}
#page-title {
text-align: center;
}
<!-- -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif,courier,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif,'courier new',courier,serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif,tahoma,Fontin-Bold,Fontin-Regular,Fontin-Italic,Fontin-SmallCaps
This diff is collapsed.
<h1 id="page-title">Osh</h1>
<hr class="featurette-divider">
<h2 class="page-subtitle">Generate Shields with OCaml</h2>
<br />
You can generate a badge with an URL of the form: ```/badge?label=build&color=green&style=classic&label_color=black&status=passing&scale=2.0```.
Preview: [![the result](/badge?label=build&amp;color=green&amp;style=classic&amp;label_color=black&amp;status=passing&amp;scale=2.0)](/badge?label=build&amp;color=green&amp;style=classic&amp;label_color=black&amp;status=passing&amp;scale=2.0).
(executable
(name server)
(modules content server template)
(libraries dream ocb omd))
(rule
(targets template.ml)
(deps template.eml.html)
(action
(run dream_eml %{deps} --workspace %{workspace_root})))
(rule
(target content.ml)
(deps
(source_tree content))
(action
(with-stdout-to
%{null}
(run ocaml-crunch -m plain content -o %{target}))))
let render ~title ~content =
Template.render_unsafe ~title ~content:(Dream.html_escape content)
let asset_loader _root path _request =
match Content.read ("assets/" ^ path) with
| None -> Dream.empty `Not_Found
| Some asset -> Dream.respond asset
let page path =
match Content.read (path ^ ".md") with
| None -> None
| Some page -> Some (Omd.of_string page |> Omd.to_html)
let () =
Dream.run @@ Dream.logger
@@ Dream.router
[ Dream.get "/assets/**" (Dream.static ~loader:asset_loader "")
; Dream.get "/" (fun _request ->
match page "index" with
| None -> Dream.empty `Not_Found
| Some content ->
Dream.html
(Template.render_unsafe ~title:"title" ~content) )
; Dream.get "/badge" (fun request ->
Dream.respond ~headers:["Content-Type", "image/svg+xml"] (
let open Ocb in
let label = match Dream.query "label" request with
| None -> "Label"
| Some label -> label
in
let color = match Dream.query "color" request with
| None -> Color.Blue
| Some color -> Color.of_string color
in
let style = match Dream.query "style" request with
| None -> Style.Flat
| Some style -> Style.of_string style
in
let label_color = match Dream.query "label_color" request with
| None -> Color.Black
| Some label_color -> Color.of_string label_color
in
let status = match Dream.query "status" request with
| None -> "Status"
| Some status -> status
in
let scale = match Dream.query "scale" request with
| None -> 1.
| Some scale -> begin match float_of_string_opt scale with
| None -> 1.
| Some scale -> scale
end
in
Format.asprintf "%a" (
Gen.mk ~label ~color ~style ~label_color ~status ~icon:None ~icon_width:0. ~scale
) ()
)
)
]
@@ Dream.not_found
let render_unsafe ~title ~content =
<!DOCTYPE html>
<html lang="en">
<head>
<title><%s title %> | OCamlPro</title>
<link rel="icon" type="image/svg+xml" href="assets/img/logo_ocp_icon.svg">
<link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="https://www.ocamlpro.com"><img src="assets/img/logo_ocamlpro.png" alt="OCamlPro" height="42" /></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav me-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<br />
<br />
<br />
<br />
<main>
<div class="container">
<%s! content %>
</div>
<hr class="featurette-divider">
<footer class="container">
<p>&copy; 2011–2021 OCamlPro &middot;
<a href="https://twitter.com/ocamlpro">Twitter</a> &middot;
<a href="https://www.linkedin.com/company/2152404/">LinkedIn</a> &middot;
<a href="mailto:contact@ocamlpro.com">Email</a> &middot;
<a href="tel:+33184800481">Phone</a> &middot;
<a href="https://www.openstreetmap.org/node/2996094140">21 rue de Châtillon, 75014 Paris, France</a> &middot;
</p>
</footer>
</main>
<script src="assets/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment