[Bins] Re: Bug#308317: please support customized date strings

Martin Michlmayr tbm at cyrius.com
Mon May 9 22:13:50 BST 2005


* tbm <tbm at cyrius.com> [2005-05-09 13:36]:
> I just noticed that my request for customized date strings seems like
> a duplicate of bug #146234 (http://bugs.debian.org/146234).  One more

The patch I submitted previously didn't set DATE everywhere where it's
needed.  This one corrects this.  (BTW, this shows that lots of code
is duplicated in bins; the variables are set in many different
functions; it would be good to put all of this in one common
function.)

> occurance of a date string is mentioned there so I'll later try to add
> that to my patch.

Looking at that now.


diff -urN bins-1.1.27~/bins bins-1.1.27/bins
--- bins-1.1.27~/bins	2005-05-09 22:05:59.370115208 +0100
+++ bins-1.1.27/bins	2005-05-09 22:11:24.903626592 +0100
@@ -130,6 +130,9 @@
 			      # static-files directory.
 			      # The name should be unique for the entire album.
 
+   dateString => "%c",        # Specify the format of the date string; this
+                              # accepts all formats supported by date(1).
+
    excludeBackgroundImage => 1, # If set to 1, the image with the name given
                                 # in backgroundImage will be excluded from
 				# the current directory.
@@ -801,32 +804,6 @@
 		  });
 $defaultConfig{colorsSubs} = \%colorsSubs;
 
-# Strings to translate in the HTML template pages (if I18N is used)
-my %intlSubs = (  STRING_THUMBNAILS   => _("thumbnails"),
-		  STRING_IMAGELIST    => _("Image List"),
-		  STRING_HOME => _("Home"),
-		  STRING_UP   => _("Up one album"),
-		  STRING_PREV => _("previous"),
-		  STRING_NEXT => _("next"),
-		  STRING_FIRST => _("first"),
-		  STRING_LAST => _("last"),
-		  STRING_SUBALBUMS => _("Sub Albums"),
-		  STRING_INTHISALBUM => _("In This Album"),
-		  STRING_BACKTOTHEIMAGE => _("Back to the image"),
-		  STRING_IMAGE => _("Image"),
-		  STRING_ALBUMTREE => _("Album Tree"),
-		  STRING_ALBUMGENERATEDBY => _("Album generated by"),
-                  STRING_FEEDBACK => _("Send Feedback"),
-                  STRING_YOURIMAGE => _("Your Image"),
-                  STRING_YOURALBUM => _("Your Album"),
-		  BINS_VERSION             => "1.1.27",
-		  ENCODING                 => $defaultConfig{htmlEncoding},
-		  GENERATED_DATE       => _("on ").
-		                          local2html(strftime("%c", localtime)),
-		  BINS_ID =>
-		  '<!--$Id: bins,v 1.162 2004/10/24 18:04:07 jerome Exp $-->',
-	       );
-
 # @knownImageExtentions defines file extensions that BINS can handle as
 # input image. BINS _should_ handle all input format of ImageMagick
 # (see ImageMagick(1) man page), but there is some formats that cause
@@ -880,6 +857,7 @@
 sub trimWhiteSpace;
 sub stringToBool;
 sub ignoreSet;
+sub getIntlSubs;
 
 sub generateThumbnailPages;
 sub generateThumbEntry;
@@ -1314,6 +1292,7 @@
     $subsHash{HOME_LINK} = $configHash->{homeURL};
     $subsHash{ALBUM_THUMB} = $configHash->{treePreview};
     $subsHash{PATH_SHOW_ICON} = $configHash->{pathShowIcon};
+    $subsHash{DATE} = strftime($configHash->{dateString}, localtime);
 
     renderTemplate("tree", $albumdir."tree.html",
 		 \%subsHash, $configHash);
@@ -2059,6 +2038,7 @@
     $finalsubs{HOME_LINK} = $configHash->{homeURL};
     $finalsubs{FEEDBACK_LINK} = $configHash->{feedbackMail};
     $finalsubs{PATH_SHOW_ICON} = $configHash->{pathShowIcon};
+    $finalsubs{DATE} = strftime($configHash->{dateString}, localtime);
 
     renderTemplate("imagelist", $albumdir.$album."imagelist.html",
 		 \%finalsubs, $configHash);
@@ -2263,12 +2243,45 @@
     $templateParameters{HOME_LINK} = $configHash->{homeURL};
     $templateParameters{FEEDBACK_LINK} = $configHash->{feedbackMail};
     $templateParameters{PATH_SHOW_ICON} = $configHash->{pathShowIcon};
+    $templateParameters{DATE} = strftime($configHash->{dateString}, localtime);
 
     renderTemplate("subalbum", $albumdir.$album."index.html",
 		   \%templateParameters, $configHash);
 }
 
 
+sub getIntlSubs{
+    my $configHash = shift;
+    # Strings to translate in the HTML template pages (if I18N is used)
+    my %intlSubs = (  STRING_THUMBNAILS   => _("thumbnails"),
+		  STRING_IMAGELIST    => _("Image List"),
+		  STRING_HOME => _("Home"),
+		  STRING_UP   => _("Up one album"),
+		  STRING_PREV => _("previous"),
+		  STRING_NEXT => _("next"),
+		  STRING_FIRST => _("first"),
+		  STRING_LAST => _("last"),
+		  STRING_SUBALBUMS => _("Sub Albums"),
+		  STRING_INTHISALBUM => _("In This Album"),
+		  STRING_BACKTOTHEIMAGE => _("Back to the image"),
+		  STRING_IMAGE => _("Image"),
+		  STRING_ALBUMTREE => _("Album Tree"),
+		  STRING_ALBUMGENERATEDBY => _("Album generated by"),
+                  STRING_FEEDBACK => _("Send Feedback"),
+                  STRING_YOURIMAGE => _("Your Image"),
+                  STRING_YOURALBUM => _("Your Album"),
+		  BINS_VERSION             => "1.1.27",
+		  ENCODING                 => $defaultConfig{htmlEncoding},
+		  GENERATED_DATE       => _("on ").
+		                          local2html(strftime($configHash->{dateString},
+		                          localtime)),
+		  BINS_ID =>
+		  '<!--$Id: bins,v 1.162 2004/10/24 18:04:07 jerome Exp $-->',
+	       );
+    return \%intlSubs;
+}
+
+
 sub getAlbumInfo{
     my $album      = shift(@_);
     my $configHash = shift(@_);
@@ -2563,6 +2576,7 @@
   $subsHash{HOME_LINK} = $configHash->{homeURL};
   $subsHash{FEEDBACK_LINK} = $configHash->{feedbackMail};
   $subsHash{PATH_SHOW_ICON} = $configHash->{pathShowIcon};
+  $subsHash{DATE} = strftime($configHash->{dateString}, localtime);
   if ($albumHashRef->{numSubAlbums} == 0){
     $subsHash{FIRST_PAGE} = "index.html";
   }else{
@@ -2701,10 +2715,11 @@
   $subs_hash{HOME_LINK} = $configHash->{homeURL};
   $subs_hash{FEEDBACK_LINK} = $configHash->{feedbackMail};
   $subs_hash{PATH_SHOW_ICON} = $configHash->{pathShowIcon};
+  $subs_hash{DATE} = strftime($configHash->{dateString}, localtime);
   $subs_hash{CUSTOM_CSS} = $configHash->{customStyleSheet};
 
   my @array;
-  push @array, {NAV_NAME => $intlSubs{STRING_BACKTOTHEIMAGE},
+  push @array, {NAV_NAME => getIntlSubs($configHash)->{STRING_BACKTOTHEIMAGE},
                 NAV_LINK => "javascript:history.back();",
                 NAV_ICON => "back.png",
 		NAV_ID => "back"};
@@ -3295,6 +3310,7 @@
     getRootDir($album)."static.".$configHash->{templateStyle};
   $subs_hash{HOME_LINK} = $configHash->{homeURL};
   $subs_hash{FEEDBACK_LINK} = $configHash->{feedbackMail};
+  $subs_hash{DATE} = strftime($configHash->{dateString}, localtime);
   if ($configHash->{backgroundImage}) {
       # Do not set this if not configured, so that template
       # can check for whether defined.
@@ -3474,7 +3490,7 @@
   %{$templateParameters} =
     (%{$templateParameters},
      %{$configHash->{colorsSubs}{$configHash->{colorStyle}}},
-     %intlSubs,
+     %{getIntlSubs($configHash)},
     );
 
   # open the html template
diff -urN bins-1.1.27~/doc/bins.sgml bins-1.1.27/doc/bins.sgml
--- bins-1.1.27~/doc/bins.sgml	2005-05-09 22:05:59.374114600 +0100
+++ bins-1.1.27/doc/bins.sgml	2005-05-09 22:09:21.014460608 +0100
@@ -430,6 +430,15 @@
 	    </varlistentry>
 
 	    <varlistentry>
+	      <term>dateString</term>
+	      <listitem>
+		<para>Specify the format of the date string.  This variable
+		accepts all formats supported by <command>date(1)</command>.
+		</para>
+	      </listitem>
+	    </varlistentry>
+
+	    <varlistentry>
 	      <term>defaultSize</term>
 	      <listitem>
 		<para>Size to use when user clicks directly on the

-- 
Martin Michlmayr
http://www.cyrius.com/


More information about the Bins mailing list