view debian/patches/19_bins-insert-directory @ 4:c5749e43b1d7

Adding debian files (to original 1.1.29)
author Peter Gervai <grin@grin.hu>
date Wed, 15 Oct 2008 23:35:35 +0200
parents
children
line wrap: on
line source

#! /bin/sh /usr/share/dpatch/dpatch-run
## 19_bins-1.1.29-insert-directory.dpatch by  <rousseau@localhost.localdomain>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
--- bins-1.1.29.orig/bins
+++ bins-1.1.29/bins
@@ -399,6 +399,10 @@
                                            # strings on console and to
                                            # convert strings from .po
                                            # files.
+
+     injectDir      => '',                  # directory to be injected
+                                            # without rebuilding complete
+                                            # album
      );
 
 my $codeset;
@@ -985,7 +989,7 @@
     Getopt::Long::Configure("bundling");
     die "Invalid options\n"
         if (!GetOptions(\%option, "h", "p", "r:s", "e", "o:s", "t=s", "d=s", "s=s",
-                        "c=s", "v:i", "i=s", "n=s", "f=s"));
+                        "c=s", "v:i", "i=s", "n=s", "f=s", "j=s"));
 
     if (defined($option{v})) {
         $verbose = $option{v};
@@ -1146,6 +1150,25 @@
 
         die "albumdir_dir ($albumdir) can't be a subdirectory of picdir_dir ($picdir)"
             if ($albumdir2 =~ m/^$picdir2\//);
+
+        if( defined $option{j} ) {
+            my $injectDir = $option{j};
+            my $injectExists = 1;
+
+            chdir $injectDir or warn "Can't chdir $injectDir: $!" and $injectExists = 0;
+
+            if( $injectExists ) {
+                $injectDir = File::Spec->rel2abs(".") unless -l $option{j};
+                chdir $pwd;
+            }
+
+            die "inject_dir (specified via -j parameter) $option{j} must be a subdirectory of pic_dir ($picdir)"
+                unless $injectDir =~ m#^$picdir2/.*#;
+
+            $configHash->{injectDir}
+                = File::Spec->rel2abs(File::Spec->canonpath($injectDir));
+            $configHash->{injectDir} .= '/';        # add trailing slash
+        }
     }
 
     $picdir = File::Spec->rel2abs(File::Spec->canonpath($picdir));
@@ -2190,6 +2213,16 @@
 
 sub generateImageListPage{
     my ($album, $albumHashRef, $imageDataRef, $xlinksRef, $configHash) = @_;
+    if( $configHash->{injectDir} ne '' ) {
+        my $injectDir = $configHash->{injectDir};
+        my $oneDirUp;
+        # drop the last subdirectory
+        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
+        my $dir = $picdir . $album;
+        # Only generate imagelist page during injection
+        # for 1-level-up or injected album itself
+        return unless $dir =~ m#($oneDirUp|$injectDir)$#;
+    }
     my %albumHash = %{$albumHashRef};
     my @imageData = @{$imageDataRef};
     my $pwd;
@@ -2400,6 +2433,18 @@
 
 sub generateLongSubAlbumPage{
     my ($album, $albumHashRef, $configHash) = @_;
+    if( $configHash->{injectDir} ne '' ) {
+        my $injectDir = $configHash->{injectDir};
+        my( $oneDirUp, $twoDirUp );
+        # drop the last subdirectory
+        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
+        # drop the last subdirectory
+        ( $twoDirUp = $oneDirUp ) =~ s#(.*/).*?/$#$1#o;
+        my $dir = $picdir . $album;
+        # Only generate subalbum page during injection for
+        # 1-level-up or 2-level-up or injected album itself
+        return unless $dir =~ m#($oneDirUp|$twoDirUp|$injectDir)$#;
+    }
     my %albumHash = %{$albumHashRef};
 
     # hash for final subsitutions
@@ -2680,6 +2725,18 @@
     my ($album, $albumHashRef, $firstIsIndex, $configHash,
         $xlinkListRef,
         @imageData) = @_;
+
+    if( $configHash->{injectDir} ne '' ) {
+        my $injectDir = $configHash->{injectDir};
+        my $oneDirUp;
+        # drop the last subdirectory
+        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
+        my $dir = $picdir . $album;
+        # Only generate thumbnail page during injection for
+        # 1-level-up or injected album itself
+        return unless $dir =~ m#($oneDirUp|$injectDir)$#;
+    }
+
     my @xlinkList=@$xlinkListRef;
     my %albumHash = %{$albumHashRef};
     my $numImages = scalar(@imageData); #element count
@@ -3095,6 +3152,13 @@
     my ($album, $albumHashRef, $firstIsIndex,
         $configHash, @imagesToDisplay) = @_;
 
+    my $skipDueToInjection = 0;
+
+    if( $configHash->{injectDir} ne '' ) {
+        # skip processing of images unless processing injected directory
+        $skipDueToInjection = 1 unless $picdir . $album eq $configHash->{injectDir};
+    }
+
     # an array of references to hashes storing information about each image
     my @imageData;
 
@@ -3350,10 +3414,12 @@
         $imageData[$i]{'detailsLink'} =
             generateSecondaryFieldsPage($imageData[$i], $album, $albumHashRef,
                                         $crntImageBase.$crntImageType,
-                                        $configHash);
+                                        $configHash)
+                unless $skipDueToInjection;
         if ( $configHash->{searchEngine}) {
             writeSearchString($imageData[$i], $configHash, $albumHashRef,
-                              $album);
+                              $album)
+                unless $skipDueToInjection;
         }
     }
 
@@ -3361,6 +3427,7 @@
 
     # now generate html
     for ($i=0; $i<$numImages; $i++) {
+        last if $skipDueToInjection;
         for (my $j=0; $j <= $imageData[$i]->{maxSize}; $j++) {
             my $lastImageURL = getHTMLImagePageLink($imageData[$numImages-1],
                                                     $j, $numImages-1);