chiark / gitweb /
media-scraper: Provide local-build scraper (is actually for oxymoron)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Mar 2021 20:53:32 +0000 (20:53 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Mar 2021 20:55:16 +0000 (20:55 +0000)
This is not as general as its name, but this is how I wrote it.  It
will be renamed in a later commit.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README.md
library/cards-oxymoron/.gitignore
media-scraper

index 82e917f76a2eefd7a0465b630a432d3e48d87f0e..195101bf80e587fdf2cd303ddc538159d08428a6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -126,7 +126,7 @@ Setup
      sudo apt install build-essential cpio git curl     \
                       pkg-config libssl-dev             \
                       node-typescript inkscape bubblewrap \
-                      netpbm
+                      netpbm imagemagick
 ```
 
 2. Install Rust.  This is most easily done with [rustup](https://rustup.rs)):
index 8c2b7dd43c8da773720bb805d02cfcfe5c64f1a1..3c4215f347c4d95914c53497f6ceeee536ac20c9 100644 (file)
@@ -1,2 +1,3 @@
+*.svg
 cards/src/*.gif
 cards/src/make-cards.massaged
index 7861b74516c0a7b032194ab8d0c1f190323950ca..27c54af2901474ea12b093eee975b7577c58e038 100755 (executable)
@@ -142,6 +142,28 @@ sub method_wikimedia ($$$) {
 
 sub methodisoffline_wikimedia { 0 }
 
+sub method_local_build {
+  my ($scraper, $methname) = @_;
+  return sub {
+    my ($lbase, $ldest, $rstem) = @_;
+    my $lgif = $lbase;
+    $lgif =~ m{/card-oxymoron-(\w+)-(\w+)$} or die "$lbase ?";
+    my $basename = $`;
+    $lgif = "$basename/cards/src/\l$1\E$2.gif";
+
+    if (stat $lgif) {
+    } elsif ($! != ENOENT) {
+      die "$lgif $!";
+    } else {
+      print STDERR "\nbuilding $basename...\n";
+      $!=$?=0; system "$basename/build" and die "$! $?";
+    }
+    $!=$?=0; system qw(convert), $lgif, $ldest and die "$! $?";
+  }
+}
+sub methodlic_local_build { undef }
+sub methodisoffline_local_build ($$) { 1 }
+
 our $offline;
 
 while (@ARGV && $ARGV[0] =~ m/^-/) {