From 5880e12b82c98ba96e74bdfdafe2f6bca26463c4 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 12 Jul 2025 01:25:08 -0400 Subject: [PATCH] Progress reporting for render command --- blog | 2 +- lib/DB.rakumod | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/blog b/blog index 3f5a5ed..d321741 100755 --- a/blog +++ b/blog @@ -155,7 +155,7 @@ multi MAIN( IO::Path(Str) :$site-dir = $default-site-dir, ) { my $db = read-db $db-dir; - $db.render: $site-dir; + $db.render: $site-dir, :report; } #| Provide a table of posts, in newest to oldest order diff --git a/lib/DB.rakumod b/lib/DB.rakumod index 4373000..bc49d94 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -96,7 +96,9 @@ class PostDB { } #| Render the site to the provided output directory - method render(IO::Path:D $out-dir, Config:D :$config = Config.new) { + method render(IO::Path:D $out-dir, + Config:D :$config = Config.new, + Bool :$report) { ## Consistency checks # Check to make sure all the slugs are unique my @all-the-slugs = %!posts.values.map(*.all-slugs).flat; @@ -113,6 +115,7 @@ class PostDB { mkdir $by-slug unless $by-slug.e; # Render all the posts and make symlinks for %!posts.kv -> $id, $post { + say "Generating post $id: {$post.title}" when $report; my $html = $config.generate-post: $id, $post, self; my $id-path = $by-id.add: "$id.html"; $id-path.spurt: $html; @@ -124,10 +127,13 @@ class PostDB { } } # Render the index + say "Rendering index" when $report; $out-dir.add('index.html').spurt: $config.generate-index(self); # Render the archive + say "Rendering archive" when $report; $out-dir.add('archive.html').spurt: $config.generate-archive(self); # Symlink the about article + say "Rendering the about article" when $report; my $about-path = $out-dir.add('about.html'); $about-path.unlink if $about-path.l; $by-id.add("{$!meta.about-id}.html").symlink: $about-path; @@ -137,6 +143,7 @@ class PostDB { my $tags-dir = $out-dir.add('tags/'); mkdir $tags-dir unless $tags-dir.e; for @tags -> $tag { + say "Rendering tags page: $tag" when $report; $tags-dir.add("$tag.html").spurt: $config.generate-tag-page(self, $tag); } @@ -144,17 +151,21 @@ class PostDB { my $series-dir = $out-dir.add('series/'); mkdir $series-dir unless $series-dir.e; for %!series.kv -> $key, $value { + say "Rendering series page: $key" when $report; $series-dir.add("$key.html").spurt: series-page($key, self); } # Generate the main series page + say "Rendering main series list" when $report; $out-dir.add('series.html').spurt: series-list-page self; # Render the rss/atom feed + say "Rendering atom feed" when $report; my $atom-path = $out-dir.add('atom.xml'); my $atom = posts-to-atom self; $atom-path.spurt: format-xml(~$atom); # Create the resources folder and copy over our style sheets + say "Creating resources folder" when $report; my $res-dir = $out-dir.add('resources/'); mkdir $res-dir unless $res-dir.e; # symlink the resources directory to make "interactive" styling eaiser @@ -164,6 +175,7 @@ class PostDB { %?RESOURCES.IO.symlink: $res-dir.add('code.css') unless $res-dir.add('code.css').e; %?RESOURCES.IO.symlink: $res-dir.add('admonitions.css') unless $res-dir.add('admonitions.css').e; %?RESOURCES.IO.symlink: $res-dir.add('cactus.css') unless $res-dir.add('cactus.css').e; + say "Done" when $report; } #| Get a list of posts sorted by date