-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(library | ||
(name generator) | ||
(public_name site.generator) | ||
(libraries yocaml yocaml_yaml yocaml_jingoo yocaml_omd)) | ||
(libraries yocaml yocaml_yaml yocaml_jingoo yocaml_omd yocaml_syndication)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
open Yocaml | ||
|
||
let base_url = "https://gr-im.github.io" | ||
let feed_url = base_url ^ "/" ^ "atom.xml" | ||
|
||
let owner = | ||
Yocaml_syndication.Person.make ~uri:base_url ~email:"[email protected]" "Grim" | ||
|
||
module Page = struct | ||
type t = { title : string; description : string; tags : string list } | ||
|
||
|
@@ -120,6 +126,17 @@ module Article = struct | |
^ Bib.to_string meta.bib )) | ||
|
||
let compare { date = a; _ } { date = b; _ } = Archetype.Datetime.compare a b | ||
|
||
let to_atom_entry (url, { page; date; _ }) = | ||
let open Yocaml_syndication in | ||
let title = page.title in | ||
let url = base_url ^ Path.to_string url in | ||
let updated = Datetime.make date in | ||
let categories = List.map Category.make page.tags in | ||
let summary = Atom.text page.description in | ||
let links = [ Atom.alternate url ~title ] in | ||
Atom.entry ~links ~categories ~summary ~updated ~id:url | ||
~title:(Atom.text title) () | ||
end | ||
|
||
module Articles = struct | ||
|
@@ -178,4 +195,17 @@ module Articles = struct | |
let index path = | ||
let open Task in | ||
lift (fun x -> (x, ())) >>> second (fetch path) >>> from_page | ||
|
||
let to_atom path = | ||
let open Task in | ||
let open Yocaml_syndication in | ||
let id = feed_url in | ||
let title = Atom.text "Grim's web corner" in | ||
let subtitle = Atom.text "Notes, essays and ramblings" in | ||
let links = [ Atom.self feed_url; Atom.link base_url ] in | ||
let updated = Atom.updated_from_entries () in | ||
let authors = Yocaml.Nel.singleton owner in | ||
fetch path | ||
>>> Atom.from ~updated ~title ~subtitle ~id ~links ~authors | ||
Article.to_atom_entry | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters