Playing with dynamically serving my static website.
0

Configure Feed

Select the types of activity you want to include in your feed.

Inital commit

author
Michael Dales
date (Nov 24, 2024, 8:12 AM UTC) commit a0f257e5
+746
+29
.gitignore
··· 1 + *.annot 2 + *.cmo 3 + *.cma 4 + *.cmi 5 + *.a 6 + *.o 7 + *.cmx 8 + *.cmxs 9 + *.cmxa 10 + 11 + # ocamlbuild working directory 12 + _build/ 13 + 14 + # ocamlbuild targets 15 + *.byte 16 + *.native 17 + 18 + # oasis generated files 19 + setup.data 20 + setup.log 21 + 22 + # Merlin configuring file for Vim and Emacs 23 + .merlin 24 + 25 + # Dune generated files 26 + *.install 27 + 28 + # Local OPAM switch 29 + _opam/
+179
LICENSE.md
··· 1 + ###### V. 1.2 2 + 3 + # European Union Public Licence 4 + 5 + *EUPL © the European Union 2007, 2016* 6 + 7 + This European Union Public Licence (the *'EUPL'*) applies to **the Work** (as defined below) which is provided under the terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such use is covered by a right of the copyright holder of the Work). 8 + 9 + The Work is provided under the terms of this Licence when **the Licensor** (as defined below) has placed the following notice immediately following the copyright notice for the Work: 10 + 11 + > Licensed under the EUPL 12 + 13 + or has expressed by any other means his willingness to license under the EUPL. 14 + 15 + ### 1. Definitions 16 + 17 + In this Licence, the following terms have the following meaning: 18 + 19 + - *'The Licence'*: this Licence. 20 + 21 + - *'The Original Work'*: the work or software distributed or communicated by the Licensor under this Licence, available as Source Code and also as Executable Code as the case may be. 22 + 23 + - *'Derivative Works'*: the works or software that could be created by the Licensee, based upon the Original Work or modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in the country mentioned in Article 15. 24 + 25 + - *'The Work'*: the Original Work or its Derivative Works. 26 + 27 + - *'The Source Code'*: the human-readable form of the Work which is the most 28 + convenient for people to study and modify. 29 + 30 + - *'The Executable Code'*: any code which has generally been compiled and which is meant to be interpreted by a computer as a program. 31 + 32 + - *'The Licensor'*: the natural or legal person that distributes or communicates the Work under the Licence. 33 + 34 + - *'Contributor(s)'*: any natural or legal person who modifies the Work under the Licence, or otherwise contributes to the creation of a Derivative Work. 35 + 36 + - *'The Licensee'* or *'You'*: any natural or legal person who makes any usage of the Work under the terms of the Licence. 37 + 38 + - *'Distribution'* or *'Communication'*: any act of selling, giving, lending, renting, distributing, communicating, transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential functionalities at the disposal of any other natural or legal person. 39 + 40 + ### 2. Scope of the rights granted by the Licence 41 + 42 + The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for the duration of copyright vested in the Original Work: 43 + 44 + - use the Work in any circumstance and for all usage, 45 + 46 + - reproduce the Work, 47 + 48 + - modify the Work, and make Derivative Works based upon the Work, 49 + 50 + - communicate to the public, including the right to make available or display the Work or copies thereof to the public and perform publicly, as the case may be, the Work, 51 + 52 + - distribute the Work or copies thereof, 53 + 54 + - lend and rent the Work or copies thereof, 55 + 56 + - sublicense rights in the Work or copies thereof. 57 + 58 + Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the applicable law permits so. 59 + 60 + In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed by law in order to make effective the licence of the economic rights here above listed. 61 + 62 + The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the extent necessary to make use of the rights granted on the Work under this Licence. 63 + 64 + ### 3. Communication of the Source Code 65 + 66 + The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to distribute or communicate the Work. 67 + 68 + ### 4. Limitations on copyright 69 + 70 + Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations thereto. 71 + 72 + ### 5. Obligations of the Licensee 73 + 74 + The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those obligations are the following: 75 + 76 + - **Attribution right:** The Licensee shall keep intact all copyright, patent or 77 + trademarks notices and all notices that refer to the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work to carry prominent notices stating that the Work has been modified and the date of modification. 78 + 79 + - **Copyleft clause:** If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless the Original Work is expressly distributed only under this version of the Licence — for example by communicating *'EUPL v. 1.2 only'*. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the Work or Derivative Work that alter or restrict the terms of the Licence. 80 + 81 + - **Compatibility clause:** If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done under the terms of this Compatible Licence. For the sake of this clause, *'Compatible Licence'* refers to the licences listed in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. 82 + 83 + - **Provision of Source Code:** When distributing or communicating copies of the Work, the Licensee will provide a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available for as long as the Licensee continues to distribute or communicate the Work. 84 + 85 + - **Legal Protection:** This Licence does not grant permission to use the trade names, trademarks, service marks, or names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the copyright notice. 86 + 87 + ### 6. Chain of Authorship 88 + 89 + The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence. 90 + 91 + Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence. 92 + 93 + Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions to the Work, under the terms of this Licence. 94 + 95 + ### 7. Disclaimer of Warranty 96 + 97 + The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work and may therefore contain defects or *'bugs'* inherent to this type of development. 98 + 99 + For the above reason, the Work is provided under the Licence on an *'as is'* basis and without warranties of any kind concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this Licence. 100 + 101 + This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. 102 + 103 + ### 8. Disclaimer of Liability 104 + 105 + Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. 106 + 107 + ### 9. Additional agreements 108 + 109 + While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by the fact You have accepted any warranty or additional liability. 110 + 111 + ### 10. Acceptance of the Licence 112 + 113 + The provisions of this Licence can be accepted by clicking on an icon *'I agree'* placed under the bottom of a window displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms and conditions. 114 + 115 + Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution or Communication by You of the Work or copies thereof. 116 + 117 + ### 11. Information to the public 118 + 119 + In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, by offering to download the Work from a remote location) the distribution channel or media (for example, a website) must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence and the way it may be accessible, concluded, stored and reproduced by the Licensee. 120 + 121 + ### 12. Termination of the Licence 122 + 123 + The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms of the Licence. Such a termination will not terminate the licences of any person who has received the Work from the Licensee under the Licence, provided such persons remain in full compliance with the Licence. 124 + 125 + ### 13. Miscellaneous 126 + 127 + Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the Work. 128 + 129 + If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid and enforceable. 130 + 131 + The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. New versions of the Licence will be published with a unique version number. 132 + 133 + All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take advantage of the linguistic version of their choice. 134 + 135 + ### 14. Jurisdiction 136 + 137 + Without prejudice to specific agreement between parties, 138 + 139 + - any litigation resulting from the interpretation of this License, arising between the European Union institutions, bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, 140 + 141 + - any litigation arising between other parties and resulting from the interpretation of this License, will be subject to the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. 142 + 143 + ### 15. Applicable Law 144 + 145 + Without prejudice to specific agreement between parties, 146 + 147 + - this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, resides or has his registered office, 148 + 149 + - this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside a European Union Member State. 150 + 151 + --- 152 + 153 + ### Appendix 154 + 155 + *'Compatible Licences'* according to Article 5 EUPL are: 156 + 157 + - GNU General Public License (GPL) v. 2, v. 3 158 + 159 + - GNU Affero General Public License (AGPL) v. 3 160 + 161 + - Open Software License (OSL) v. 2.1, v. 3.0 162 + 163 + - Eclipse Public License (EPL) v. 1.0 164 + 165 + - CeCILL v. 2.0, v. 2.1 166 + 167 + - Mozilla Public Licence (MPL) v. 2 168 + 169 + - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 170 + 171 + - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software 172 + 173 + - European Union Public Licence (EUPL) v. 1.1, v. 1.2 174 + 175 + - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+) 176 + 177 + The European Commission may update this Appendix to later versions of the above licences without producing a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the covered Source Code from exclusive appropriation. 178 + 179 + All other changes or additions to this Appendix require the production of a new EUPL version.
+1
README.md
··· 1 + A work in progress attempt to make a dynamic version of my static website.
+5
bin/dune
··· 1 + (executable 2 + (public_name webplats) 3 + (name main) 4 + (libraries webplats dream fpath) 5 + (preprocess (pps lwt_ppx)))
+28
bin/main.ml
··· 1 + open Webplats 2 + 3 + let () = 4 + 5 + let site = Site.of_directory (Fpath.v "/Users/michael/Sites/mynameismwd.org/content") in 6 + 7 + 8 + let toplevel = [ 9 + Dream.get "/" (fun _ -> Renderer.render_index site |> Dream.html); 10 + Dream.get "/css/**" (Dream.static "/Users/michael/Sites/mynameismwd.org/public/css/."); 11 + Dream.get "/face/**" (Dream.static "/Users/michael/Sites/mynameismwd.org/public/face/."); 12 + ] in 13 + 14 + let sections = List.concat_map (fun sec -> 15 + ( 16 + match (Section.title sec) with 17 + | "snapshots" -> Dream.get (Section.url sec) (fun _ -> Snapshots.render_section sec |> Dream.html) 18 + | "posts" -> Dream.get (Section.url sec) (fun _ -> Posts.render_section sec |> Dream.html) 19 + | _ -> Dream.get (Section.url sec) (fun _ -> Renderer.render_section sec |> Dream.html) 20 + ) :: 21 + List.map (fun p -> 22 + Dream.get (Page.url p) (fun _ -> Renderer.render_page p |> Dream.html) 23 + ) (Section.pages sec) 24 + ) (Site.sections site) in 25 + 26 + Dream.run 27 + @@ Dream.logger 28 + @@ Dream.router (toplevel @ sections)
+26
dune-project
··· 1 + (lang dune 3.16) 2 + 3 + (name webplats) 4 + 5 + (generate_opam_files true) 6 + 7 + (source 8 + (github mdales/webplats)) 9 + 10 + (authors "Michael Dales") 11 + 12 + (maintainers "Michael Dales") 13 + 14 + (license LICENSE) 15 + 16 + (documentation https://url/to/documentation) 17 + 18 + (package 19 + (name webplats) 20 + (synopsis "A short synopsis") 21 + (description "A longer description") 22 + (depends ocaml dune) 23 + (tags 24 + (topics "to describe" your project))) 25 + 26 + ; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html
+5
lib/dune
··· 1 + (include_subdirs unqualified) 2 + 3 + (library 4 + (name webplats) 5 + (libraries fpath dream cmarkit astring yaml))
+123
lib/model/page.ml
··· 1 + type image = { 2 + filename : string; 3 + description : string option; 4 + } 5 + 6 + type frontmatter = { 7 + title: string option; 8 + date: Ptime.t; 9 + synopsis: string option; 10 + titleimage: image option; 11 + draft: bool; 12 + } 13 + 14 + type t = { 15 + frontmatter : frontmatter; 16 + url : string; 17 + } 18 + 19 + let yaml_dict_to_string a k = 20 + match List.assoc_opt k a with 21 + | None -> None 22 + | Some v -> ( 23 + match v with 24 + | `String str -> Some str 25 + | _ -> None 26 + ) 27 + 28 + let yaml_dict_to_bool a k = 29 + match List.assoc_opt k a with 30 + | None -> None 31 + | Some v -> ( 32 + match v with 33 + | `Bool b -> Some b 34 + | _ -> None 35 + ) 36 + 37 + let yaml_dict_to_date a k = 38 + match List.assoc_opt k a with 39 + | None -> None 40 + | Some v -> ( 41 + match v with 42 + | `String str -> ( 43 + match (Ptime.of_rfc3339 str) with 44 + | Ok (t, _, _) -> Some t 45 + | _ -> ( 46 + (* Some are not RFC3339, they're '2019-09-30 08:57:22' or such *) 47 + Scanf.sscanf str "%d-%d-%d %d:%d:%d" (fun y m d h i s -> Ptime.of_date_time ((y, m, d), ((h, i, s), 0))) 48 + ) 49 + ) 50 + | _ -> None 51 + ) 52 + 53 + let yaml_dict_to_image a k = 54 + match List.assoc_opt k a with 55 + | None -> None 56 + | Some v -> ( 57 + match v with 58 + | `O assoc -> ( 59 + match yaml_dict_to_string assoc "image" with 60 + | Some filename -> Some { 61 + filename ; 62 + description = yaml_dict_to_string assoc "alt" 63 + } 64 + | None -> None 65 + 66 + ) 67 + | `String filename -> ( 68 + Some { filename ; description=None } 69 + ) 70 + | _ -> None 71 + ) 72 + 73 + let yaml_to_struct y = 74 + match y with 75 + | `O assoc -> ( 76 + { 77 + title = yaml_dict_to_string assoc "title"; 78 + date = (match (yaml_dict_to_date assoc "date") with Some d -> d | None -> Ptime.epoch); 79 + synopsis = yaml_dict_to_string assoc "synopsis"; 80 + titleimage = yaml_dict_to_image assoc "titleimage"; 81 + draft = (match (yaml_dict_to_bool assoc "draft") with Some b -> b | None -> true); 82 + } 83 + ) 84 + | _ -> failwith "malformed yaml" 85 + 86 + let read_frontmatter path = 87 + let raw_frontmatter = In_channel.with_open_text (Fpath.to_string path) (fun ic -> 88 + let parts = In_channel.input_all ic |> Astring.String.cuts ~sep:"---" in 89 + match parts with 90 + | _ :: fm :: _body -> fm 91 + | _ -> failwith (Printf.sprintf "failed to parse %s" (Fpath.to_string path)) 92 + ) in 93 + let frontmatter = String.trim raw_frontmatter |> Yaml.of_string_exn in 94 + yaml_to_struct frontmatter 95 + 96 + 97 + let of_file ~base path = 98 + let url = Fpath.rem_prefix base path in 99 + let frontmatter = try 100 + read_frontmatter path 101 + with 102 + | Not_found | Invalid_argument _ -> failwith (Printf.sprintf "Failed to find key in %s" (Fpath.to_string path)) 103 + in 104 + 105 + match url with 106 + | Some url ->{ frontmatter ; url="/" ^ Fpath.to_string url} 107 + | None -> failwith "base is not parent directory" 108 + 109 + let title t = 110 + match t.frontmatter.title with 111 + | Some t -> t 112 + | None -> "Untitled" 113 + 114 + let url t = t.url 115 + 116 + let date t = t .frontmatter.date 117 + 118 + let synopsis t = t.frontmatter.synopsis 119 + 120 + let titleimage t = t.frontmatter.titleimage 121 + 122 + let draft t = t.frontmatter.draft 123 +
+20
lib/model/page.mli
··· 1 + type image = { 2 + filename : string; 3 + description : string option; 4 + } 5 + 6 + type t 7 + 8 + val of_file : base:Fpath.t -> Fpath.t -> t 9 + 10 + val title : t -> string 11 + 12 + val url : t -> string 13 + 14 + val date : t -> Ptime.t 15 + 16 + val synopsis : t -> string option 17 + 18 + val titleimage : t -> image option 19 + 20 + val draft : t -> bool
+46
lib/model/section.ml
··· 1 + 2 + type t = { 3 + path : Fpath.t; 4 + pages : Page.t list; 5 + url : string; 6 + } 7 + 8 + 9 + let rec find_markdown_files path = 10 + Sys.readdir (Fpath.to_string path) 11 + |> Array.to_list 12 + |> List.map (fun p -> Fpath.append path (Fpath.v p)) 13 + |> List.concat_map (fun p -> 14 + match Sys.is_directory (Fpath.to_string p) with 15 + | true -> find_markdown_files p 16 + | false -> ( 17 + match Fpath.get_ext p with 18 + | ".md" -> [p] 19 + | _ -> [] 20 + ) 21 + ) 22 + 23 + let of_directory ~base path = 24 + 25 + let url = Fpath.rem_prefix base path in 26 + let url = match url with 27 + | Some url -> "/" ^ Fpath.to_string url 28 + | None -> failwith "base is not parent directory" 29 + in 30 + 31 + let paths = find_markdown_files path in 32 + let pages = List.map (Page.of_file ~base:base) paths 33 + |> List.filter (fun p -> not (Page.draft p)) 34 + |> List.sort (fun a b -> 35 + Ptime.compare (Page.date b) (Page.date a) 36 + ) in 37 + { 38 + path ; pages ; url 39 + } 40 + 41 + let title t = 42 + Fpath.basename t.path 43 + 44 + let pages t = t.pages 45 + 46 + let url t = t.url
+10
lib/model/section.mli
··· 1 + type t 2 + 3 + val of_directory : base:Fpath.t -> Fpath.t -> t 4 + 5 + val pages : t -> Page.t list 6 + 7 + val title : t -> string 8 + 9 + val url : t -> string 10 +
+30
lib/model/site.ml
··· 1 + type t = { 2 + path : Fpath.t; 3 + sections : Section.t list; 4 + } 5 + 6 + let of_directory path = 7 + let sections = 8 + Sys.readdir (Fpath.to_string path) 9 + |> Array.to_list 10 + |> List.map (fun p -> Fpath.append path (Fpath.v p)) 11 + |> List.filter_map (fun p -> 12 + match Sys.is_directory (Fpath.to_string p) with 13 + | false -> None 14 + | true -> Some (Fpath.to_dir_path p) 15 + ) 16 + |> List.map (fun p -> Section.of_directory ~base:path p) 17 + |> List.sort (fun a b -> 18 + Ptime.compare (Page.date (List.hd (Section.pages b))) (Page.date (List.hd (Section.pages a))) 19 + ) 20 + in 21 + Dream.log " %d\n" (List.length sections); 22 + { 23 + path ; sections 24 + } 25 + 26 + let sections t = t.sections 27 + 28 + let path t = t.path 29 + 30 + let title t = Fpath.basename t.path
+9
lib/model/site.mli
··· 1 + type t 2 + 3 + val of_directory : Fpath.t -> t 4 + 5 + val sections : t -> Section.t list 6 + 7 + val path : t -> Fpath.t 8 + 9 + val title : t -> string
+15
lib/view/dune
··· 1 + (rule 2 + (targets renderer.ml) 3 + (deps renderer.eml.ml) 4 + (action (run dream_eml %{deps} --workspace %{workspace_root}))) 5 + 6 + (rule 7 + (targets posts.ml) 8 + (deps posts.eml.ml) 9 + (action (run dream_eml %{deps} --workspace %{workspace_root}))) 10 + 11 + (rule 12 + (targets snapshots.ml) 13 + (deps snapshots.eml.ml) 14 + (action (run dream_eml %{deps} --workspace %{workspace_root}))) 15 +
+43
lib/view/posts.eml.ml
··· 1 + 2 + 3 + let months = [| "Jan" ; "Feb" ; "Mar" ; "Apr" ; "May" ; "Jun" ; "Jul" ; "Aug" ; "Sep" ; "Oct" ; "Nov"; "Dec" |] 4 + 5 + let ptime_to_str (t : Ptime.t) : string = 6 + let ((year, month, day), _) = Ptime.to_date_time t in 7 + Printf.sprintf "%d %s %d" day months.(month - 1) year 8 + 9 + let render_section sec = 10 + <html> 11 + <%s! (Renderer.render_head (Section.title sec)) %> 12 + <body> 13 + <div class="almostall"> 14 + <%s! Renderer.render_header (Section.title sec) %> 15 + 16 + <div id="container"> 17 + <div class="content"> 18 + <section role="main"> 19 + <div class="blogcontents"> 20 + % (Section.pages sec) |> List.iter begin fun (page) -> 21 + <div class="blogcontents__item"> 22 + <ul class="leaders"> 23 + <li> 24 + <span><a href="<%s Page.url page %>"><%s Page.title page %></a></span> 25 + <span><%s ptime_to_str (Page.date page) %></span> 26 + </li> 27 + </ul> 28 + <div class="blogcontents__item__inner"> 29 + <div> 30 + <p><%s (match (Page.synopsis page) with None -> "" | Some p -> p) %></p> 31 + </div> 32 + </div> 33 + </div> 34 + % end; 35 + 36 + </div> 37 + </section> 38 + </div> 39 + </div> 40 + </div> 41 + <%s! Renderer.render_footer () %> 42 + </body> 43 + </html>
+102
lib/view/renderer.eml.ml
··· 1 + 2 + let render_head title = 3 + <head> 4 + <link rel="stylesheet" href="/css/base.min.1baad36ee4ee027cab80c240d7d6f3bd25a6b673801984ba90cb19fd0c96c0c35914a8be655c092babd943d87ce43c99874d9415f746837ae01492338478ab7b.css" integrity="sha512-G6rTbuTuAnyrgMJA19bzvSWmtnOAGYS6kMsZ/QyWwMNZFKi+ZVwJK6vZQ9h85DyZh02UFfdGg3rgFJIzhHirew==" type="text/css" media="screen"> 5 + <title><%s title %></title> 6 + </head> 7 + 8 + let render_header title = 9 + <div class="header stripes"> 10 + <header role="banner"> 11 + <a ref="home"> 12 + <h1><%s title %></h1> 13 + <h2>the website of Michael Winston Dales</h2> 14 + </a> 15 + </header> 16 + </div> 17 + 18 + let months = [| "Jan" ; "Feb" ; "Mar" ; "Apr" ; "May" ; "Jun" ; "Jul" ; "Aug" ; "Sept" ; "Oct" ; "Nov"; "Dec" |] 19 + 20 + let ptime_to_str (t : Ptime.t) : string = 21 + let ((year, month, day), _) = Ptime.to_date_time t in 22 + Printf.sprintf "%s %d, %d" months.(month - 1) day year 23 + 24 + let render_footer () = 25 + <div id="foot" class="stripes"> 26 + <nav> 27 + <div id="endlinks"> 28 + </div> 29 + </nav> 30 + </div> 31 + 32 + let render_index site = 33 + <html> 34 + <%s! (render_head (Site.title site)) %> 35 + <body> 36 + <div class="almostall"> 37 + <%s! render_header (Site.title site) %> 38 + 39 + <div id="container"> 40 + <div class="content"> 41 + <section role="main"> 42 + <div class="article"> 43 + <h2>My things here</h2> 44 + <div class="index"> 45 + % (Site.sections site) |> List.iter begin fun (sec) -> 46 + <div> 47 + <a href="<%s Section.url sec %>"> 48 + <div class="homebutton colour-<%s Section.title sec %>"> 49 + <h3><%s Section.title sec %></h3> 50 + <p> 51 + <%d List.length (Section.pages sec) %> <%s Section.title sec %>, 52 + last updated <%s ptime_to_str (Page.date (List.hd (Section.pages sec))) %></p> 53 + </div> 54 + </a> 55 + </div> 56 + % end; 57 + </div> 58 + <h2>My other sites</h2> 59 + <div class="index"> 60 + </div> 61 + </div> 62 + </section> 63 + </div> 64 + </div> 65 + </div> 66 + <%s! render_footer () %> 67 + </body> 68 + </html> 69 + 70 + let render_section sec = 71 + <html> 72 + <%s! (render_head (Section.title sec)) %> 73 + <body> 74 + <div class="almostall"> 75 + <%s! render_header (Section.title sec) %> 76 + 77 + <ul> 78 + % (Section.pages sec) |> List.iter begin fun (page) -> 79 + <li> 80 + <a href="<%s Page.url page %>"> 81 + <%s Page.title page %> 82 + </a> 83 + </li> 84 + % end; 85 + 86 + </ul> 87 + 88 + <%s! render_footer () %> 89 + </body> 90 + </html> 91 + 92 + 93 + let render_page page = 94 + <html> 95 + <head> 96 + <link rel="stylesheet" href="/css/base.min.1baad36ee4ee027cab80c240d7d6f3bd25a6b673801984ba90cb19fd0c96c0c35914a8be655c092babd943d87ce43c99874d9415f746837ae01492338478ab7b.css" integrity="sha512-G6rTbuTuAnyrgMJA19bzvSWmtnOAGYS6kMsZ/QyWwMNZFKi+ZVwJK6vZQ9h85DyZh02UFfdGg3rgFJIzhHirew==" type="text/css" media="screen"> 97 + <title><%s Page.title page %></title> 98 + </head> 99 + <body> 100 + <h1><%s Page.title page %></h1> 101 + </body> 102 + </html>
+42
lib/view/snapshots.eml.ml
··· 1 + 2 + 3 + let render_section sec = 4 + <html> 5 + <%s! (Renderer.render_head (Section.title sec)) %> 6 + <body> 7 + <div class="almostall"> 8 + <%s! Renderer.render_header (Section.title sec) %> 9 + 10 + <div id="container"> 11 + <div class="content"> 12 + <section role="main"> 13 + <div class="tagcontents"> 14 + <h2>Snapshots</h2> 15 + <div class="tagcellholder"> 16 + 17 + % (Section.pages sec) |> List.iter begin fun (page) -> 18 + <div class="tagcell colour-<%s Section.title sec %>"> 19 + <div class="tagcelllabel"> 20 + <span><%s Page.title page %></span> 21 + </div> 22 + <div class="tagcellinner"> 23 + <a href="<%s Page.url page %>"> 24 + <div class="tagcellimg"> 25 + <figure> 26 + <img/> 27 + </figure> 28 + </div> 29 + </a> 30 + </div> 31 + </div> 32 + % end; 33 + 34 + </div> 35 + </div> 36 + </section> 37 + </div> 38 + </div> 39 + </div> 40 + <%s! Renderer.render_footer () %> 41 + </body> 42 + </html>
+2
test/dune
··· 1 + (test 2 + (name test_webplats))
test/test_webplats.ml

This is a binary file and will not be displayed.

+31
webplats.opam
··· 1 + # This file is generated by dune, edit dune-project instead 2 + opam-version: "2.0" 3 + synopsis: "A short synopsis" 4 + description: "A longer description" 5 + maintainer: ["Michael Dales"] 6 + authors: ["Michael Dales"] 7 + license: "LICENSE" 8 + tags: ["topics" "to describe" "your" "project"] 9 + homepage: "https://github.com/mdales/webplats" 10 + doc: "https://url/to/documentation" 11 + bug-reports: "https://github.com/mdales/webplats/issues" 12 + depends: [ 13 + "ocaml" 14 + "dune" {>= "3.16"} 15 + "odoc" {with-doc} 16 + ] 17 + build: [ 18 + ["dune" "subst"] {dev} 19 + [ 20 + "dune" 21 + "build" 22 + "-p" 23 + name 24 + "-j" 25 + jobs 26 + "@install" 27 + "@runtest" {with-test} 28 + "@doc" {with-doc} 29 + ] 30 + ] 31 + dev-repo: "git+https://github.com/mdales/webplats.git"