]> mj.ucw.cz Git - gallery.git/commitdiff
Cleaned up MJ's hacks
authorMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 21:01:32 +0000 (22:01 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 21:01:32 +0000 (22:01 +0100)
The obsolete ones have been deleted, the rest has been "documented".

README
bin/gal-mj-digikam
bin/gal-mj-init
bin/gal-mj-map [deleted file]
bin/gal-mj-migrate-check [deleted file]
bin/gal-mj-upgrade [deleted file]
bin/gal-mj-upload

diff --git a/README b/README
index 5fbcd6d682b1ffb01dd142281e956e69f775a08e..fd868dd70a3da8582009d9ea8dd01f37838a3824 100644 (file)
--- a/README
+++ b/README
@@ -89,3 +89,12 @@ Workflow
        - When you modify existing images, run "gal scan --update".
 
    o  See example/* for an example web front-end.
+
+Various notes
+~~~~~~~~~~~~~
+
+   o  When you want to re-generate all galleries at once, you can use
+      "gal --all -p4 gen". This will run "gal gen" on all subdirectories
+      containing "gallery.cf", 4 of them in parallel.
+
+   o  See bin/gal-mj-* for various hacks I wrote for myself.
index 3598573d2f4f026d7043fa08004857ccc0f940ab..7a1a3317aacaecd043ba89a8c4825f80af4aa68e 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+# This is a hack, which takes a Digikam album, finds all photos
+# possessing a "web" tag and imports them to UCW::Gallery.
 
 use common::sense;
 
index 4f932f8fbff8cc4f63cb66ff51c1cbf0046d48fb..adceebe6e18678a0827679d35bd19b239023f75f 100755 (executable)
@@ -1,4 +1,6 @@
 #!/bin/sh
+# This creates a gallery with MJ's default configuration
+
 set -e
 
 if [ -f gallery.cf ] ; then
diff --git a/bin/gal-mj-map b/bin/gal-mj-map
deleted file mode 100755 (executable)
index aedd974..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/perl
-
-use common::sense;
-
-use Digest::SHA;
-use File::Find;
-
-STDOUT->autoflush(1);
-
-find({
-       wanted => sub {
-               my $name = $File::Find::name;
-               $name =~ s{^\./}{};
-               $name =~ m{^\d} or return;
-               $name =~ m{\.jpe?g$}i or return;
-               -f $name or return;
-               print "$name\t";
-
-               my $sha = Digest::SHA->new(1);
-               $sha->addfile($name) or die "Cannot hash $name\n";
-               my $id = substr($sha->hexdigest, 0, 16);
-               print "$id\n";
-       },
-       no_chdir => 1,
-}, ".");
diff --git a/bin/gal-mj-migrate-check b/bin/gal-mj-migrate-check
deleted file mode 100755 (executable)
index e7762a6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/perl
-# Check that thumbnail aspect ratios match pre-migration data
-
-use common::sense;
-
-use UCW::Gallery;
-
-my $gal = UCW::Gallery->load_config;
-my $meta = $gal->read_meta($gal->cache_meta_name);
-
-open T, "gallery.thumb" or die "Cannot read gallery.thumb\n";
-my @thumbs = ();
-while (<T>) {
-       chomp;
-       my ($name, $tw, $th) = split /\s+/;
-       push @thumbs, [ $tw, $th ];
-}
-close T;
-
-for my $id (@{$meta->{sequence}}) {
-       my ($tw, $th) = @{shift @thumbs} or die;
-       my $ta = $tw / $th;
-       my $m = $meta->{photo}->{$id} or die;
-       my $pw = $m->{w};
-       my $ph = $m->{h};
-       my $pa = $pw / $ph;
-       if (abs($ta - $pa) > 0.05) {
-               if (abs($ta - 1/$pa) > 0.05) {
-                       print STDERR "$id: Mismatched aspect ratio: orig $ta (${tw}x${th}) new $pa (${pw}x${ph})\n";
-               } else {
-                       print STDERR "$id: Mismatched rotation\n";
-               }
-       }
-}
diff --git a/bin/gal-mj-upgrade b/bin/gal-mj-upgrade
deleted file mode 100755 (executable)
index da019f6..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/perl
-
-use common::sense;
-
-use UCW::Gallery;
-use File::Spec;
-use Image::Magick;
-
-my $photos_root = $ENV{HOME} . '/photos';
-
-my $album = $ARGV[0] // die "Usage: gal mj-upgrade <album>\n";
-print "### $album ###\n";
-
-### Scan photos.map ###
-
-my $year = $album;
-$year =~ s{/.*}{};
-if ($album eq '2009/Fireworks') { $year = 2008; }
-print "Loading map for $year\n";
-open M, "$photos_root/photos.map" or die "No map file found\n";
-my %map = ();
-while (<M>) {
-       chomp;
-       m{^$year} or next;
-       my ($path, $hash) = split /\t/;
-       my $name = $path;
-       $name =~ s{.*/}{};
-       if (defined $map{$name}) {
-               my $prev = $map{$name};
-               if ($prev->{hash} ne $hash) {
-                       print STDERR "Collision for $name: ", $prev->{path}, " vs. ", $path, "\n";
-               } else {
-                       # print STDERR "Harmless collision for $name: ", $prev->{path}, " vs. ", $path, "\n";
-               }
-       } else {
-               $map{$name} = { path => $path, hash => $hash };
-       }
-}
-close M;
-
-### Scan static list (if any) ###
-
-my @src = ();
-if (open S, "../static/photos/$album/x") {
-       print "Found static list\n";
-       while (<S>) {
-               chomp;
-               my @fields = split /\t/;
-               if (@fields == 4) {
-                       push @src, { name => $fields[0], rotate => $fields[2], xform => $fields[3] };
-               } elsif (@fields == 2) {
-                       push @src, { name => $fields[0], rotate => $fields[1], xform => '.' };
-               } else {
-                       die "Error parsing gallery list: $_\n";
-               }
-       }
-       close S;
-}
-
-### Parse index.cgi and produce gallery.new ###
-
-open I, "$album/index.cgi" or die "Cannot find $album/index.cgi\n";
-open W, ">$album/gallery.new" or die "Cannot create $album/gallery.new\n";
-open T, ">$album/gallery.thumb" or die "Cannot create $album/gallery.thumb\n";
-my %opt = ();
-my %found_dirs = ();
-my @items = ();
-while (<I>) {
-       chomp;
-       if (/^\s+"(\w+)" => "(.*)",?$/) {
-               $opt{$1} = $2;
-               print "Option: $1 = $2\n";
-       } elsif (/^img\("([^"]+)(\.jpe?g)", "([^"]*)"\);\s*# (\S+)/) {
-               my $nr = $1;
-               my $ext = $2;
-               my $title = $3;
-               my $file = $4;
-               $file =~ s{^.*/}{}g;
-
-               my $map = $map{$file};
-               if (!$map) {
-                       print STDERR "$album: No match for $file\n";
-                       next;
-               }
-               my $path = $map->{path};
-               my ($vv, $dd, $ff) = File::Spec->splitpath($path);
-               $found_dirs{$dd} = 1;
-
-               print "Image: $nr $path [$title]\n";
-               my $src;
-               if (@src) {
-                       if ($nr =~ m{^\d+$} && $nr <= @src) {
-                               $src = $src[$nr-1];
-                       } else {
-                               print STDERR "$album: Crooked refs ($nr)\n";
-                       }
-               }
-
-               print W join("\t",
-                       "$photos_root/$path",
-                       $map->{hash},
-                       ($src ? $src->{rotate} : '-'),
-                       ($src ? $src->{xform} : '.'),
-                       ($title ne "" ? $title : '-'),
-                       ), "\n";
-
-
-               my $thumb = "../static/photos/$album/$nr-thumb.jpg";
-               if (!-f $thumb) {
-                       print STDERR "$album: Cannot find thumbnail for photo $nr ($thumb)\n";
-                       print T "1 1\n";
-               } else {
-                       my $im = new Image::Magick;
-                       my ($thumb_w, $thumb_h, $thumb_size, $thumb_format) = $im->PingImage($thumb) or die "Error reading $thumb\n";
-                       print T "$thumb $thumb_w $thumb_h\n";
-               }
-       } elsif (/^($|#|require|SetOptions|\)|Start|Finish)/) {
-               # Nothing important
-       } else {
-               print STDERR "$album/index.cgi: Parse error at line $.: $_\n";
-       }
-}
-close T;
-close W;
-close I;
-
-if (scalar keys %found_dirs != 1) {
-       print STDERR "$album: Photos in multiple directories\n";
-}
-
-### Create gallery.cf ###
-
-open CF, ">$album/gallery.cf" or die "Cannot create $album/gallery.cf";
-print CF <<'AMEN' ;
-use common::sense;
-
-my $gal = require '../../default.cf';
-$gal->set(
-AMEN
-
-for my $cf (reverse sort keys %opt) {
-       print CF "\t$cf => \"", $opt{$cf}, "\",\n";
-}
-
-print CF <<'AMEN' ;
-);
-
-return $gal;
-AMEN
-
-close CF;
index 67aae53a51b750415fc4e6143c4b93ba0adac904..e7fce29f80017bdd143cfc7c6d5ec7e1433355d1 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+# This is a hack to upload a locally generated gallery to MJ's web.
 
 use common::sense;