Compare commits
No commits in common. "0153d20b89765f0481b5258eff6af5ccd587864f" and "f10a30f29c388d6f4527da83a6f85cd92da77529" have entirely different histories.
0153d20b89
...
f10a30f29c
1 changed files with 55 additions and 1 deletions
56
bin/blog.ml
56
bin/blog.ml
|
@ -311,6 +311,7 @@ module Article = struct
|
||||||
|
|
||||||
let title p = p#title
|
let title p = p#title
|
||||||
let description p = p#description
|
let description p = p#description
|
||||||
|
let tags p = p#tags
|
||||||
let date p = p#date
|
let date p = p#date
|
||||||
|
|
||||||
let neutral =
|
let neutral =
|
||||||
|
@ -502,7 +503,9 @@ struct
|
||||||
let target_root = S.target
|
let target_root = S.target
|
||||||
let pages = target_root
|
let pages = target_root
|
||||||
let articles = Path.(target_root / "articles")
|
let articles = Path.(target_root / "articles")
|
||||||
|
let rss1 = Path.(target_root / "rss1.xml")
|
||||||
let rss2 = Path.(target_root / "feed.xml")
|
let rss2 = Path.(target_root / "feed.xml")
|
||||||
|
let atom = Path.(target_root / "atom.xml")
|
||||||
|
|
||||||
let as_html into file =
|
let as_html into file =
|
||||||
file |> Path.move ~into |> Path.change_extension "html"
|
file |> Path.move ~into |> Path.change_extension "html"
|
||||||
|
@ -612,6 +615,25 @@ struct
|
||||||
~compute_link:(Target.as_html @@ Path.abs [ "articles" ])
|
~compute_link:(Target.as_html @@ Path.abs [ "articles" ])
|
||||||
Source.articles
|
Source.articles
|
||||||
|
|
||||||
|
let rss1 =
|
||||||
|
let from_articles ~title ~site_url ~description ~feed_url () =
|
||||||
|
let open Yocaml_syndication in
|
||||||
|
Rss1.from ~title ~url:feed_url ~link:site_url ~description
|
||||||
|
@@ fun (path, article) ->
|
||||||
|
let title = Article.title article in
|
||||||
|
let link = site_url ^ Yocaml.Path.to_string path in
|
||||||
|
let description = Article.description article in
|
||||||
|
Rss1.item ~title ~link ~description
|
||||||
|
in
|
||||||
|
let open Task in
|
||||||
|
Action.write_static_file Target.rss1
|
||||||
|
begin
|
||||||
|
fetch_articles
|
||||||
|
>>> from_articles ~title:feed_title ~site_url
|
||||||
|
~description:feed_description
|
||||||
|
~feed_url:"https://blog.robur.coop/rss1.xml" ()
|
||||||
|
end
|
||||||
|
|
||||||
let rss2 =
|
let rss2 =
|
||||||
let open Task in
|
let open Task in
|
||||||
let from_articles ~title ~site_url ~description ~feed_url () =
|
let from_articles ~title ~site_url ~description ~feed_url () =
|
||||||
|
@ -661,12 +683,44 @@ struct
|
||||||
~feed_url:"https://blog.robur.coop/feed.xml" ()
|
~feed_url:"https://blog.robur.coop/feed.xml" ()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let atom =
|
||||||
|
let open Task in
|
||||||
|
let open Yocaml_syndication in
|
||||||
|
let authors = Yocaml.Nel.singleton @@ Person.make "The Robur Team" in
|
||||||
|
let from_articles ?(updated = Atom.updated_from_entries ()) ?(links = [])
|
||||||
|
?id ~site_url ~authors ~title ~feed_url () =
|
||||||
|
let id = Option.value ~default:feed_url id in
|
||||||
|
let feed_url = Atom.self feed_url in
|
||||||
|
let base_url = Atom.link site_url in
|
||||||
|
let links = base_url :: feed_url :: links in
|
||||||
|
Atom.from ~links ~updated ~title ~authors ~id
|
||||||
|
begin
|
||||||
|
fun (path, article) ->
|
||||||
|
let title = Article.title article in
|
||||||
|
let content_url = site_url ^ Yocaml.Path.to_string path in
|
||||||
|
let updated =
|
||||||
|
Datetime.make (Date.to_archetype_date_time (Article.date article))
|
||||||
|
in
|
||||||
|
let categories = List.map Category.make (Article.tags article) in
|
||||||
|
let summary = Atom.text (Article.description article) in
|
||||||
|
let links = [ Atom.alternate content_url ~title ] in
|
||||||
|
Atom.entry ~links ~categories ~summary ~updated ~id:content_url
|
||||||
|
~title:(Atom.text title) ()
|
||||||
|
end
|
||||||
|
in
|
||||||
|
Action.write_static_file Target.atom
|
||||||
|
begin
|
||||||
|
fetch_articles
|
||||||
|
>>> from_articles ~site_url ~authors ~title:(Atom.text feed_title)
|
||||||
|
~feed_url:"https://blog.robur.coop/atom.xml" ()
|
||||||
|
end
|
||||||
|
|
||||||
let process_all ~host =
|
let process_all ~host =
|
||||||
let open Eff in
|
let open Eff in
|
||||||
Action.restore_cache ~on:`Source Source.cache
|
Action.restore_cache ~on:`Source Source.cache
|
||||||
>>= process_css_files >>= process_js_files >>= process_images_files
|
>>= process_css_files >>= process_js_files >>= process_images_files
|
||||||
>>= process_tags ~host
|
>>= process_tags ~host
|
||||||
>>= process_articles ~host >>= process_index ~host >>= rss2
|
>>= process_articles ~host >>= process_index ~host >>= rss1 >>= rss2 >>= atom
|
||||||
>>= Action.store_cache ~on:`Source Source.cache
|
>>= Action.store_cache ~on:`Source Source.cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue