Samhain 21
Converter - type selection - subdir conversion - htm extension Gemini - index.gmi - topics and latest - gmi.atom feed Add pull (http(s)) operation - peers.pub.conf and peers.priv.conf HTML5 format & fixes by Novaburst Phony target (thanks Gergely) May Basic unit renamed from Note to Text. New modular text-parser, internal to Logarion, for generic notation parsing. The default input format is now a much plainer text. Logarion created texts have part of the UUID in filename. Logarion's index re-written in Messagepack format. Removed `indices` command. They are generated during `convert`. git-svn-id: file:///srv/svn/repo/kosuzu/trunk@2 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
73
cli/gemini.ml
Normal file
73
cli/gemini.ml
Normal file
@@ -0,0 +1,73 @@
|
||||
let page _archive_title text =
|
||||
let open Logarion.Text in
|
||||
"# " ^ text.title
|
||||
^ "\nAuthors: " ^ Logarion.Person.Set.to_string text.authors
|
||||
^ "\nDate: " ^ Logarion.Date.(pretty_date @@ listing text.date)
|
||||
^ let module T = Parsers.Plain_text.Make (Converter.Gemini) in
|
||||
"\n" ^ T.of_string text.body ""
|
||||
|
||||
let date_index title meta_list =
|
||||
List.fold_left
|
||||
(fun a m ->
|
||||
a ^ "=> " ^ Logarion.Text.short_id m ^ ".gmi " ^
|
||||
Logarion.(Date.(pretty_date (listing m.date)) ^ " " ^ m.title) ^ "\n")
|
||||
("# " ^ title ^ "\n\n## Posts by date\n\n") meta_list
|
||||
|
||||
let to_dated_links ?(limit) meta_list =
|
||||
let meta_list = match limit with
|
||||
| None -> meta_list
|
||||
| Some limit->
|
||||
let rec reduced acc i = function
|
||||
| [] -> acc
|
||||
| h::t -> if i < limit then reduced (h::acc) (i+1) t else acc in
|
||||
List.rev @@ reduced [] 0 meta_list
|
||||
in
|
||||
List.fold_left
|
||||
(fun a m ->
|
||||
a
|
||||
^ "=> " ^ Logarion.Text.short_id m ^ ".gmi "
|
||||
^ Logarion.(Date.(pretty_date (listing m.Text.date))) ^ " "
|
||||
^ m.Logarion.Text.title ^ "\n")
|
||||
"" meta_list
|
||||
|
||||
let topic_link root topic =
|
||||
"=> index." ^ root ^ ".gmi " ^ String.capitalize_ascii topic ^ "\n"
|
||||
|
||||
let text_item path meta =
|
||||
let open Logarion in
|
||||
"=> " ^ path ^ Text.short_id meta ^ ".gmi "
|
||||
^ Date.(pretty_date (listing meta.Text.date)) ^ " "
|
||||
^ meta.Text.title ^ "\n"
|
||||
|
||||
let listing_index topic_map topic_roots path metas =
|
||||
let rec item_group topics =
|
||||
List.fold_left (fun acc topic -> acc ^ sub_groups topic ^ items topic) "" topics
|
||||
and sub_groups topic = match Logarion.Topic_set.Map.find_opt topic topic_map with
|
||||
| None -> ""
|
||||
| Some (_, subtopics) -> item_group (Logarion.String_set.elements subtopics)
|
||||
and items topic =
|
||||
let items =
|
||||
let open Logarion in
|
||||
List.fold_left
|
||||
(fun a e ->
|
||||
if String_set.mem topic (String_set.map (Logarion.Topic_set.topic) (Text.set "Topics" e))
|
||||
then text_item path e ^ a else a) "" metas in
|
||||
match items with
|
||||
| "" -> ""
|
||||
| x -> "## " ^ String.capitalize_ascii topic ^ "\n\n" ^ x
|
||||
in
|
||||
item_group topic_roots
|
||||
|
||||
let fold_topic_roots topic_roots =
|
||||
let list_item root t = topic_link root t in
|
||||
List.fold_left (fun a x -> a ^ list_item x x) "" (List.rev topic_roots)
|
||||
|
||||
let topic_main_index title topic_roots metas =
|
||||
"# " ^ title ^ "\n\n"
|
||||
^ (if topic_roots <> [] then ("## Main topics\n\n" ^ fold_topic_roots topic_roots) else "")
|
||||
^ "\n## Latest\n\n" ^ to_dated_links ~limit:10 metas
|
||||
^ "\n=> index.date.gmi More by date\n"
|
||||
|
||||
let topic_sub_index title topic_map topic_root metas =
|
||||
"# " ^ title ^ "\n\n"
|
||||
^ listing_index topic_map [topic_root] "" metas
|
||||
Reference in New Issue
Block a user