Changeset 59 in code for trunk


Ignore:
Timestamp:
Feb 13, 2024, 11:23:38 PM (14 months ago)
Author:
yakumo.izuru
Message:

Reverse all the HTML changes, add a generator meta tag, and a To-do

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/html.ml

    r54 r59  
    3232        in
    3333        let footer = match htm.templates.footer with None -> "" | Some x -> replace x in
    34         Printf.sprintf "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n<link rel=\"icon\" href=\"/favicon.png\">\n<title>%s%s</title>\n%s\n%s\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">\n</head>\n<body>\n%s%s%s</body>\n</html>"
    35         text_title (if site_title <> "" then (" " ^ site_title) else "")
     34        Printf.sprintf "<!DOCTYPE HTML>\n<html>\n<head>\n<link rel=\"icon\" href=\"/favicon.png\">\n<title>%s%s</title>\n%s\n%s\n<meta name=\"generator\" content=\"Logarion\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n</head>\n<body>\n%s%s%s</body>\n</html>"
     35        text_title (if site_title <> "" then (" &bull; " ^ site_title) else "")
    3636        htm.style
    3737        (if feed <> "" then Printf.sprintf "<link rel='alternate' href='%s' type='application/atom+xml'>" feed else "")
     
    6060        let authors = Person.Set.to_string text.authors in
    6161        let header =
    62                 let time x = Printf.sprintf {|<span class="%s">%s</span>|}
     62                let time x = Printf.sprintf {|<time datetime="%s">%s</time>|}
    6363(Date.rfc_string x) (Date.pretty_date x) in
    6464                let topic_links x =
     
    7373                let Rel.{ref_set; rep_set; _} = try Rel.Id_map.find text.id conversion.relations with Not_found -> Rel.empty in
    7474                ref_links ref_set, ref_links rep_set in
    75                 "<dl>"
     75                "<article><header><dl>"
    7676                ^ opt_kv "Title:" text.title
    7777                ^ opt_kv "Authors:" authors
     
    8484                ^ opt_kv "Referred by:" references
    8585                ^ opt_kv "Replies:" replies
    86                 ^ {|</dl><pre style="white-space:pre-wrap">|} in
    87         wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre>")
     86                ^ {|</dl></header><pre style="white-space:pre-wrap">|} in
     87        wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre></article>")
    8888
    8989let to_dated_links ?(limit) meta_list =
     
    9696                        List.rev @@ reduced [] 0 meta_list in
    9797        List.fold_left
    98         (fun a m -> Printf.sprintf "%s<li>%s&ensp;<a href=\"%s.htm\">%s</a></li>" a Logarion.(Date.(pretty_date (listing m.Text.date)))
     98        (fun a m -> Printf.sprintf "%s <li> %s <a href=\"%s.htm\">%s</a>" a Logarion.(Date.(pretty_date (listing m.Text.date)))
    9999        (Logarion.Text.short_id m) m.Logarion.Text.title)
    100100        "" meta_list
     
    107107let fold_topic_roots topic_roots =
    108108        let list_item root t = "<li>" ^ topic_link root t in
    109         "<h2>Main topics</h2>"
     109        "<nav><h2>Main topics</h2>"
    110110        ^ List.fold_left (fun a x -> a ^ list_item x x) "<ul>" (List.rev topic_roots)
    111         ^ "</ul>"
     111        ^ "</ul></nav>"
    112112
    113113let fold_topics topic_map topic_roots metas =
     
    124124                then topic_link root t else String.capitalize_ascii t in
    125125        "<ul><li>" ^ item ^ sub_items root t ^ "</ul>" in
    126         "<h2>Topics</h2>"
     126        "<nav><h2>Topics</h2>"
    127127        ^ List.fold_left (fun a x -> a ^ list_item x x) "<ul>" (List.rev topic_roots)
    128         ^ "</ul>"
     128        ^ "</ul></nav>"
    129129
    130130let text_item path meta =
    131131        let open Logarion in
    132         "<p>" ^ Date.(pretty_date (listing meta.Text.date))
    133         ^ {|<a href="|} ^ path ^ Text.short_id meta ^ {|.htm">|} ^ meta.Text.title
    134         ^ "</a></p><br>"
     132        "<time>" ^ Date.(pretty_date (listing meta.Text.date))
     133        ^ {|</time> <a href="|} ^ path ^ Text.short_id meta ^ {|.htm">|} ^ meta.Text.title
     134        ^ "</a><br>"
    135135
    136136let listing_index topic_map topic_roots path metas =
     
    150150        | "" -> ""
    151151        | x -> {|<h2 id="|} ^ topic ^ {|">|} ^ String.capitalize_ascii topic ^ "</h2>" ^ x in
    152         "<h1>Texts</h1>" ^ item_group topic_roots ^ ""
     152        "<nav><h1>Texts</h1>" ^ item_group topic_roots ^ "</nav>"
    153153
    154154let topic_main_index conv htm topic_roots metas =
    155155        wrap conv htm "Topics"
    156156        (fold_topic_roots topic_roots
    157         ^ "<h1>Latest</h1><ul>" ^ to_dated_links ~limit:10 metas
    158         ^ {|<p><a href="index.date.htm">More by date</a></p>|}
     157        ^ "<nav><h1>Latest</h1><ul>" ^ to_dated_links ~limit:10 metas
     158        ^ {|</ul></nav><hr><a href="index.date.htm">More by date</a>|}
    159159^ let peers = try Logarion.Store.KV.find "Peers" conv.kv with Not_found -> "" in
    160160(if peers = "" then "" else
Note: See TracChangeset for help on using the changeset viewer.