Change output date format & use <ul> for latest
This commit is contained in:
parent
bf031ac6ae
commit
6689127d06
2 changed files with 10 additions and 7 deletions
10
cli/html.ml
10
cli/html.ml
|
@ -83,9 +83,9 @@ let to_dated_links ?(limit) meta_list =
|
|||
List.rev @@ reduced [] 0 meta_list
|
||||
in
|
||||
List.fold_left
|
||||
(fun a m ->
|
||||
a ^ Logarion.(Date.(pretty_date (listing m.Text.date)) ^ " ")
|
||||
^ {|<a href="|} ^ Logarion.Text.short_id m ^ {|.htm">|} ^ m.Logarion.Text.title ^ "</a><br>")
|
||||
(fun a m -> Printf.sprintf "%s<li> %s <a href=\"%s.htm\">%s</a>" a
|
||||
Logarion.(Date.(pretty_date (listing m.Text.date)))
|
||||
(Logarion.Text.short_id m) m.Logarion.Text.title)
|
||||
"" meta_list
|
||||
|
||||
let date_index ?(limit) conv htm meta_list =
|
||||
|
@ -146,8 +146,8 @@ let listing_index topic_map topic_roots path metas =
|
|||
let topic_main_index conv htm topic_roots metas =
|
||||
wrap conv htm "Topics"
|
||||
(fold_topic_roots topic_roots
|
||||
^ "<nav><h1>Latest</h1>" ^ to_dated_links ~limit:10 metas
|
||||
^ {|<a href="index.date.htm">More by date</a></nav>|} )
|
||||
^ "<nav><h1>Latest</h1><ul>" ^ to_dated_links ~limit:8 metas
|
||||
^ {|</ul><a href="index.date.htm">More by date</a></nav>|} )
|
||||
|
||||
let topic_sub_index conv htm topic_map topic_root metas =
|
||||
wrap conv htm topic_root
|
||||
|
|
|
@ -3,9 +3,12 @@ let compare = compare
|
|||
let rfc_string date = date
|
||||
let of_string (rfc : string) = rfc
|
||||
let listing date = if date.edited <> "" then date.edited else date.created
|
||||
let months = [|"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"|]
|
||||
let pretty_date date =
|
||||
try Scanf.sscanf date "%4s-%2s-%2s" (fun y m d -> Printf.sprintf "%s %s %s" y m d)
|
||||
with Scanf.Scan_failure s as e -> Printf.fprintf stderr "%s for %s\n" s date; raise e
|
||||
try Scanf.sscanf date "%4s-%d-%2s" (fun y m d -> Printf.sprintf "%s %s, %s" d (months.(m-1)) y)
|
||||
with
|
||||
| Scanf.Scan_failure s as e -> Printf.fprintf stderr "%s for %s\n" s date; raise e
|
||||
| Invalid_argument _s as e -> Printf.fprintf stderr "Parsing %s" date; raise e
|
||||
let now () = Unix.time () |> Unix.gmtime |>
|
||||
(fun t -> Printf.sprintf "%4d-%02d-%02dT%02d:%02d:%02dZ"
|
||||
(t.tm_year+1900) (t.tm_mon+1) t.tm_mday t.tm_hour t.tm_min t.tm_sec)
|
||||
|
|
Loading…
Reference in a new issue