Skip to content

Commit

Permalink
Simplify Action using Static mod
Browse files Browse the repository at this point in the history
  • Loading branch information
gr-im committed Aug 13, 2024
1 parent e928904 commit d5ae4a6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
7 changes: 3 additions & 4 deletions lib/action/articles.ml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
let run (module R : Sigs.RESOLVER) chain =
Yocaml.Action.write_static_file R.Target.blog
Yocaml.Action.Static.write_file_with_metadata R.Target.blog
(let open Yocaml.Task in
R.track_common_dependencies
>>> Yocaml.Pipeline.track_file R.Source.articles
>>> Yocaml_yaml.Pipeline.read_file_with_metadata
(module Model.Page)
R.Source.blog
>>> first @@ Model.Articles.index chain R.Source.articles
>>> Static.on_metadata @@ Model.Articles.index chain R.Source.articles
>>> Yocaml_omd.content_to_html ()
>>> Yocaml_jingoo.Pipeline.as_template
(module Model.Articles)
(R.Source.template "blog.html")
>>> Yocaml_jingoo.Pipeline.as_template
(module Model.Articles)
(R.Source.template "layout.html")
>>> drop_first ())
(R.Source.template "layout.html"))
2 changes: 1 addition & 1 deletion lib/action/atom.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let run (module R : Sigs.RESOLVER) chain =
Yocaml.Action.write_static_file R.Target.atom
Yocaml.Action.Static.write_file R.Target.atom
(let open Yocaml.Task in
R.track_common_dependencies
>>> Yocaml.Pipeline.track_file R.Source.articles
Expand Down
10 changes: 4 additions & 6 deletions lib/action/chain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ let member (module R : Sigs.RESOLVER) pred_or_succ current_member target_member
~id:(Model.Member.id current_member)
pred_or_succ
in
Yocaml.Action.write_static_file target
Yocaml.Action.Static.write_file_with_metadata target
(let open Yocaml.Task in
R.track_common_dependencies
>>> const target_member
>>> empty_body ()
>>> Yocaml_jingoo.Pipeline.as_template
(module Model.Member)
(R.Source.template "redirect.html")
>>> drop_first ())
(R.Source.template "redirect.html"))

let index (module R : Sigs.RESOLVER) current_member pred succ =
let target = R.Target.member ~id:(Model.Member.id current_member) in
Yocaml.Action.write_static_file target
Yocaml.Action.Static.write_file_with_metadata target
(let open Yocaml.Task in
R.track_common_dependencies
>>> Yocaml.Pipeline.track_file R.Source.members
Expand All @@ -28,8 +27,7 @@ let index (module R : Sigs.RESOLVER) current_member pred succ =
(R.Source.template "member.html")
>>> Yocaml_jingoo.Pipeline.as_template
(module Model.Member_page)
(R.Source.template "layout.html")
>>> drop_first ())
(R.Source.template "layout.html"))

let run (module R : Sigs.RESOLVER) chain =
let member = member (module R) in
Expand Down
5 changes: 2 additions & 3 deletions lib/action/index.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let run (module R : Sigs.RESOLVER) chain =
Yocaml.Action.write_static_file R.Target.index
Yocaml.Action.Static.write_file_with_metadata R.Target.index
(let open Yocaml.Task in
R.track_common_dependencies
>>> Yocaml.Pipeline.track_file R.Source.members
Expand All @@ -13,5 +13,4 @@ let run (module R : Sigs.RESOLVER) chain =
(R.Source.template "index.html")
>>> Yocaml_jingoo.Pipeline.as_template
(module Model.Index)
(R.Source.template "layout.html")
>>> drop_first ())
(R.Source.template "layout.html"))
2 changes: 1 addition & 1 deletion lib/action/opml.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let run (module R : Sigs.RESOLVER) chain =
Yocaml.Action.write_static_file R.Target.ring_opml
Yocaml.Action.Static.write_file R.Target.ring_opml
(let open Yocaml.Task in
R.track_common_dependencies
>>> Yocaml.Pipeline.track_file R.Source.members
Expand Down

0 comments on commit d5ae4a6

Please sign in to comment.