- Timestamp:
- Feb 13, 2024, 11:23:38 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/html.ml
r54 r59 32 32 in 33 33 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 (" • " ^ site_title) else "") 36 36 htm.style 37 37 (if feed <> "" then Printf.sprintf "<link rel='alternate' href='%s' type='application/atom+xml'>" feed else "") … … 60 60 let authors = Person.Set.to_string text.authors in 61 61 let header = 62 let time x = Printf.sprintf {|< span class="%s">%s</span>|}62 let time x = Printf.sprintf {|<time datetime="%s">%s</time>|} 63 63 (Date.rfc_string x) (Date.pretty_date x) in 64 64 let topic_links x = … … 73 73 let Rel.{ref_set; rep_set; _} = try Rel.Id_map.find text.id conversion.relations with Not_found -> Rel.empty in 74 74 ref_links ref_set, ref_links rep_set in 75 "< dl>"75 "<article><header><dl>" 76 76 ^ opt_kv "Title:" text.title 77 77 ^ opt_kv "Authors:" authors … … 84 84 ^ opt_kv "Referred by:" references 85 85 ^ opt_kv "Replies:" replies 86 ^ {|</dl>< pre style="white-space:pre-wrap">|} in87 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>") 88 88 89 89 let to_dated_links ?(limit) meta_list = … … 96 96 List.rev @@ reduced [] 0 meta_list in 97 97 List.fold_left 98 (fun a m -> Printf.sprintf "%s <li>%s <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))) 99 99 (Logarion.Text.short_id m) m.Logarion.Text.title) 100 100 "" meta_list … … 107 107 let fold_topic_roots topic_roots = 108 108 let list_item root t = "<li>" ^ topic_link root t in 109 "< h2>Main topics</h2>"109 "<nav><h2>Main topics</h2>" 110 110 ^ List.fold_left (fun a x -> a ^ list_item x x) "<ul>" (List.rev topic_roots) 111 ^ "</ul> "111 ^ "</ul></nav>" 112 112 113 113 let fold_topics topic_map topic_roots metas = … … 124 124 then topic_link root t else String.capitalize_ascii t in 125 125 "<ul><li>" ^ item ^ sub_items root t ^ "</ul>" in 126 "< h2>Topics</h2>"126 "<nav><h2>Topics</h2>" 127 127 ^ List.fold_left (fun a x -> a ^ list_item x x) "<ul>" (List.rev topic_roots) 128 ^ "</ul> "128 ^ "</ul></nav>" 129 129 130 130 let text_item path meta = 131 131 let open Logarion in 132 "< p>" ^ Date.(pretty_date (listing meta.Text.date))133 ^ {|< a href="|} ^ path ^ Text.short_id meta ^ {|.htm">|} ^ meta.Text.title134 ^ "</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>" 135 135 136 136 let listing_index topic_map topic_roots path metas = … … 150 150 | "" -> "" 151 151 | 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>" 153 153 154 154 let topic_main_index conv htm topic_roots metas = 155 155 wrap conv htm "Topics" 156 156 (fold_topic_roots topic_roots 157 ^ "< h1>Latest</h1><ul>" ^ to_dated_links ~limit:10 metas158 ^ {|< 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>|} 159 159 ^ let peers = try Logarion.Store.KV.find "Peers" conv.kv with Not_found -> "" in 160 160 (if peers = "" then "" else
Note:
See TracChangeset
for help on using the changeset viewer.