Commits

Shlomi Fish committed 0553824

Generating the fortunes/$id.html.wml files ./gen-helpers.pl.

Comments (0)

Files changed (2)

     die "build-deps failed!";
 }
 
+if (system($^X,
+        '-Ilib', '-MShlomif::Homepage::FortuneCollections',
+        '-e',
+        'Shlomif::Homepage::FortuneCollections->print_all_fortunes_html_wmls()'
+    )
+)
+{
+}
+
 my $generator =
     HTML::Latemp::GenMakeHelpers->new(
         'hosts' =>

lib/Shlomif/Homepage/FortuneCollections.pm

 
 use Carp;
 use Data::Dumper;
+use List::Util qw(max);
 
 use YAML::XS (qw(LoadFile DumpFile));
 
 {
     my ($class) = @_;
 
+    my $deps_mtime_max = max(
+        map { io->file($_)->mtime() }
+        __FILE__ , $yaml_data_fn
+    );
+
     foreach my $r (@{Shlomif::Homepage::FortuneCollections::sorted_fortunes() })
     {
-        io->file("t2/humour/fortunes/@{[$r->id()]}.html.wml")->utf8->print(
-            $class->get_single_fortune_page_html_wml($r),
-        );
+        my $path = "t2/humour/fortunes/@{[$r->id()]}.html.wml";
+        my $fh = io->file($path);
+        if ( (! $fh->exists()) ||  ($deps_mtime_max > $fh->mtime()) )
+        {
+            $fh->utf8->print(
+                $class->get_single_fortune_page_html_wml($r),
+            );
+        }
     }
 }