Changeset 5 in code for trunk


Ignore:
Timestamp:
Jun 13, 2022, 4:34:20 PM (3 years ago)
Author:
fox
Message:

Change output date format & use <ul> for latest

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/html.ml

    r3 r5  
    8484  in
    8585  List.fold_left
    86     (fun a m ->
    87       a ^ Logarion.(Date.(pretty_date (listing m.Text.date)) ^ " ")
    88       ^ {|<a href="|} ^ Logarion.Text.short_id m ^ {|.htm">|} ^ m.Logarion.Text.title ^ "</a><br>")
     86    (fun a m -> Printf.sprintf "%s<li> %s <a href=\"%s.htm\">%s</a>" a
     87      Logarion.(Date.(pretty_date (listing m.Text.date)))
     88      (Logarion.Text.short_id m) m.Logarion.Text.title)
    8989    "" meta_list
    9090
     
    147147  wrap conv htm "Topics"
    148148    (fold_topic_roots topic_roots
    149      ^ "<nav><h1>Latest</h1>" ^ to_dated_links ~limit:10 metas
    150      ^ {|<a href="index.date.htm">More by date</a></nav>|} )
     149     ^ "<nav><h1>Latest</h1><ul>" ^ to_dated_links ~limit:8 metas
     150     ^ {|</ul><a href="index.date.htm">More by date</a></nav>|} )
    151151
    152152let topic_sub_index conv htm topic_map topic_root metas =
  • trunk/lib/date.ml

    r3 r5  
    44let of_string (rfc : string) = rfc
    55let listing date = if date.edited <> "" then date.edited else date.created
     6let months = [|"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"|]
    67let pretty_date date =
    7         try Scanf.sscanf date "%4s-%2s-%2s" (fun y m d -> Printf.sprintf "%s %s %s" y m d)
    8         with Scanf.Scan_failure s as e -> Printf.fprintf stderr "%s for %s\n" s date; raise e
     8        try Scanf.sscanf date "%4s-%d-%2s" (fun y m d -> Printf.sprintf "%s %s, %s" d (months.(m-1)) y)
     9        with
     10        | Scanf.Scan_failure s as e -> Printf.fprintf stderr "%s for %s\n" s date; raise e
     11        | Invalid_argument _s as e -> Printf.fprintf stderr "Parsing %s" date; raise e
    912let now () = Unix.time () |> Unix.gmtime |>
    1013        (fun t -> Printf.sprintf "%4d-%02d-%02dT%02d:%02d:%02dZ"
Note: See TracChangeset for help on using the changeset viewer.