From e928904b18e2dbe608d012f0426b020092d37283 Mon Sep 17 00:00:00 2001 From: gr-im Date: Tue, 13 Aug 2024 22:41:17 +0200 Subject: [PATCH 1/2] Merge every CSS file into once --- lib/action/css.ml | 9 ++++++++- lib/resolver.ml | 2 +- static/templates/layout.html | 2 -- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/action/css.ml b/lib/action/css.ml index 0b325a9..e639c7e 100644 --- a/lib/action/css.ml +++ b/lib/action/css.ml @@ -1,2 +1,9 @@ let run (module R : Sigs.RESOLVER) = - Batch_copy.run ~extension:[ "css" ] ~source:R.Source.css ~target:R.Target.css + Yocaml.Action.Static.write_file R.Target.css + (Yocaml.Pipeline.pipe_files ~separator:"\n" + Yocaml.Path. + [ + R.Source.css / "fonts.css"; + R.Source.css / "reset.css"; + R.Source.css / "style.css"; + ]) diff --git a/lib/resolver.ml b/lib/resolver.ml index 88c75bb..78afeed 100644 --- a/lib/resolver.ml +++ b/lib/resolver.ml @@ -29,7 +29,7 @@ module Make (R : Sigs.RESOLVABLE) = struct let atom = Path.(R.target / "atom.xml") let ring_opml = Path.(opml / "ring.opml") let members = Path.(R.target / "u") - let css = Path.(R.target / "css") + let css = Path.(R.target / "css" / "style.css") let fonts = Path.(R.target / "fonts") let index = Path.(R.target / "index.html") let images = Path.(R.target / "images") diff --git a/static/templates/layout.html b/static/templates/layout.html index 220a60a..d37f7f7 100644 --- a/static/templates/layout.html +++ b/static/templates/layout.html @@ -9,8 +9,6 @@ ring.muhokama.fun{%- if has_page_title %} - {{ page_title }}{%- endif -%} - - From d5ae4a6661e64dad289f21af11cdaedaebca2fbc Mon Sep 17 00:00:00 2001 From: gr-im Date: Tue, 13 Aug 2024 22:45:48 +0200 Subject: [PATCH 2/2] Simplify Action using Static mod --- lib/action/articles.ml | 7 +++---- lib/action/atom.ml | 2 +- lib/action/chain.ml | 10 ++++------ lib/action/index.ml | 5 ++--- lib/action/opml.ml | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/action/articles.ml b/lib/action/articles.ml index 7b30c6c..40b1393 100644 --- a/lib/action/articles.ml +++ b/lib/action/articles.ml @@ -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")) diff --git a/lib/action/atom.ml b/lib/action/atom.ml index ffbf3a2..934d448 100644 --- a/lib/action/atom.ml +++ b/lib/action/atom.ml @@ -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 diff --git a/lib/action/chain.ml b/lib/action/chain.ml index 9646592..774c81f 100644 --- a/lib/action/chain.ml +++ b/lib/action/chain.ml @@ -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 @@ -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 diff --git a/lib/action/index.ml b/lib/action/index.ml index 5694d1e..4b81f4d 100644 --- a/lib/action/index.ml +++ b/lib/action/index.ml @@ -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 @@ -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")) diff --git a/lib/action/opml.ml b/lib/action/opml.ml index 943e0d4..706e2ac 100644 --- a/lib/action/opml.ml +++ b/lib/action/opml.ml @@ -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