fixed scope warnings
This commit is contained in:
parent
d12da26055
commit
2f446e0abd
@ -42,7 +42,7 @@ let article_link entry =
|
||||
let module E = Logarion.Entry in
|
||||
let u = "/text/" ^ Filename.(entry.E.filepath |> basename |> chop_extension) in
|
||||
li [a ~a:[a_href (uri_of_string u)]
|
||||
[Unsafe.data (Ymd.(entry.meta.title) ^ Ymd.Date.(pretty_date @@ last entry.meta.date)) ]
|
||||
[Unsafe.data (Ymd.(entry.E.meta.Ymd.title) ^ Ymd.Date.(pretty_date @@ last entry.E.meta.Ymd.date)) ]
|
||||
]
|
||||
|
||||
let of_entries ?(header_tpl=None) ?(listing_tpl=None) ?(entry_tpl=None) blog_url lgrn =
|
||||
|
@ -107,8 +107,8 @@ module Archive = struct
|
||||
let dir = titledir archive_path in
|
||||
begin try
|
||||
let entry = List.find (fun entry -> entry.Entry.meta.uuid = ymd.meta.uuid) archive in
|
||||
if slug_of_filename entry.filepath <> (Ymd.filename ymd) then
|
||||
let found_filepath = dir ^ entry.filepath in
|
||||
if slug_of_filename entry.Entry.filepath <> (Ymd.filename ymd) then
|
||||
let found_filepath = dir ^ entry.Entry.filepath in
|
||||
Lwt_unix.rename found_filepath (next_semantic_filepath dir ymd);
|
||||
else Lwt.return ()
|
||||
with Not_found ->
|
||||
@ -124,7 +124,7 @@ module Archive = struct
|
||||
if not (List.exists p ts) then unique_entry (List.cons h ts) t else unique_entry ts t
|
||||
| [] -> ts
|
||||
in
|
||||
let unique_topics ts x = unique_entry ts x.Entry.meta.topics in
|
||||
let unique_topics ts x = unique_entry ts x.Entry.meta.Ymd.topics in
|
||||
List.fold_left unique_topics [] archive
|
||||
end
|
||||
|
||||
@ -134,11 +134,11 @@ let latest_entry config fragment =
|
||||
let repo = Configuration.(config.repository) in
|
||||
let latest p entry' =
|
||||
let open Entry in
|
||||
if not @@ BatString.exists (entry'.meta.title) fragment then None
|
||||
if not @@ BatString.exists (entry'.Entry.meta.Ymd.title) fragment then None
|
||||
else
|
||||
match p with
|
||||
| Some entry ->
|
||||
if entry.meta.date.Ymd.Date.published < entry'.meta.date.Ymd.Date.published
|
||||
if entry.meta.Ymd.date.Ymd.Date.published < entry'.meta.Ymd.date.Ymd.Date.published
|
||||
then Some entry' else p
|
||||
| None -> Some entry' in
|
||||
ListLabels.fold_left ~f:latest ~init:(None) (Archive.of_repo repo)
|
||||
|
@ -45,9 +45,10 @@ let fold_text ymd =
|
||||
Mustache.fold ~string ~section ~escaped ~unescaped ~partial ~comment ~concat
|
||||
|
||||
let fold_entry (entry : Logarion.Entry.t) =
|
||||
let open Logarion.Entry in
|
||||
let meta = entry.meta in
|
||||
let escaped e = match e with
|
||||
| "url" -> "/text/" ^ Filename.(entry.Logarion.Entry.filepath |> basename |> chop_extension)
|
||||
| "url" -> "/text/" ^ Filename.(entry.filepath |> basename |> chop_extension)
|
||||
| "title" -> meta.title
|
||||
| "abstract" -> meta.abstract
|
||||
| "author_name" -> meta.author.Author.name
|
||||
@ -72,8 +73,9 @@ let fold_header blog_url title =
|
||||
Mustache.fold ~string ~section ~escaped ~unescaped ~partial ~comment ~concat
|
||||
|
||||
let fold_index ?(entry_tpl=None) lgrn =
|
||||
let open Logarion.Entry in
|
||||
let simple entry =
|
||||
"<li><a href=\"/text/" ^ Filename.(entry.Logarion.Entry.filepath |> basename |> chop_extension) ^ "\">"
|
||||
"<li><a href=\"/text/" ^ Filename.(entry.filepath |> basename |> chop_extension) ^ "\">"
|
||||
^ entry.meta.title ^ " ~ " ^ Ymd.Date.(pretty_date @@ last entry.meta.date) ^ "</a></li>" in
|
||||
let fold_entry tpl entry = fold_entry entry tpl in
|
||||
let entry = match entry_tpl with Some (Listing_entry e) -> fold_entry e | None -> simple in
|
||||
|
@ -75,7 +75,11 @@ let () =
|
||||
let (>>=) = Lwt.(>>=)
|
||||
and (>|=) = Lwt.(>|=) in
|
||||
let module L = Logarion in
|
||||
let ymd f = L.Entry.of_file f |> (fun entry -> if Ymd.(CategorySet.categorised [Category.Published]) entry.meta.categories then entry else unpublished_entry) in
|
||||
let ymd f =
|
||||
L.Entry.of_file f
|
||||
|> (fun entry -> if Ymd.(CategorySet.categorised [Category.Published]) entry.L.Entry.meta.Ymd.categories
|
||||
then entry else unpublished_entry)
|
||||
in
|
||||
let ymdpath title = Lwt.return @@ Logarion.title_path lgrn.L.Configuration.repository title in
|
||||
let ret_param name req = Lwt.return (param req name) in
|
||||
let option_load tpl o = match o with Some f -> Some (tpl f) | None -> None in
|
||||
@ -96,6 +100,6 @@ let () =
|
||||
|> get "/new" (fun _ -> Lwt.return (Ymd.blank_ymd ()) >|= form_of_ymd >>= html_response)
|
||||
|> get "/text/:ttl" (fun req -> ret_param "ttl" req >>= ymdpath >|= ymd >|= L.Entry.to_ymd >|= page_of_ymd >>= html_response)
|
||||
|> get "/!/:ttl" (fun req -> ret_param "ttl" req >|= L.latest_entry lgrn >|= entry_option >|= L.Entry.to_ymd >|= page_of_ymd >>= html_response)
|
||||
|> get "/feed.atom" (fun _ -> Lwt.return L.Archive.(of_repo ~bodies:true repo) >|= L.latest_listed_entries >|= List.map L.Entry.to_ymd >|= Atom.feed webcfg.url lgrn >>= html_response)
|
||||
|> get "/feed.atom" (fun _ -> Lwt.return L.Archive.(of_repo ~bodies:true repo) >|= L.latest_listed_entries >|= List.map L.Entry.to_ymd >|= Atom.feed webcfg.Configuration.url lgrn >>= html_response)
|
||||
|> get "/" (fun _ -> Lwt.return list_of_ymds >>= html_response)
|
||||
|> App.run_command
|
||||
|
Loading…
x
Reference in New Issue
Block a user