From adrian_r at teleline.es Thu Nov 18 15:00:31 2004 From: adrian_r at teleline.es (Adrian Rossiter) Date: Thu Nov 18 14:57:49 2004 Subject: [Bins] A quick and easy way of creating basic albums Message-ID: Hi I have been trying to streamline album creation and management, and thought I would mention what I am doing in it is of interest. I build a dirctory tree of image albums as normal, but in each album directory I create an include_images.txt file containing a list of the album images in the order I want them. I get bins to only consider the images in the include_images.txt files by setting the excludeFiles parameter in binsrc to exclude all files (.*). I then add comment lines to the include_images.txt files which I process with a basic Perl script (below) to set up the album. At the beginning I add the album details, then after each image I add the title and description. The Perl script simply calls the bins_edit program with the various details as arguments. This is working out reasonably well as I can easily change the album, image text, order of images, etc just by editing one text file. I've included the script below (with some minimal instructions!) Adrian. -- Adrian Rossiter Email: adrian_r@teleline.es Web Site: http://www.terra.es/personal/adrian_r Here is an example include_images.txt file for a one image album - #Some Album Title (1 line) #Long description of Some Album #(can be many #lines) #|Short description of Some Album (starts after the pipe symbol) #can be many lines, then put another pipe symbol and this is followed #by the sample album image) #|some_image.gif some_image.gif #Some Image Title (1 line) #Description of Some Image #can be many lines #and include html
#but you may have to escape certain symbols for the command line e.g. #Some Site I call the script bins_addtext. It just takes a list of directories where it looks for include_images.txt and processes it. You can use a different file by passing the name with the -f option. e.g Process include_images.txt in the current directory - bin_addtext ./ Process album_desc.txt in directories some_album1 and some_album2 bin_addtext -f album_desc.txt some_album1 some_album2 #!/usr/bin/perl -w sub process_file { my ($dir, $file, $title, $desc) = @_; chomp $desc; #print "File: $file\n\tTitle: $title\n\tDesc: $desc\n"; #print "\n$file\n"; if($file eq "album") { ($longdesc, $shortdesc, $sample) = split /\|/, $desc; if($sample) { $cmd_str = "bins_edit -a -m --sample \"$sample\" $dir"; print "$cmd_str\n"; `$cmd_str`; } if($shortdesc) { $cmd_str = "bins_edit -a -m --shortdesc \"$shortdesc\" $dir"; print "$cmd_str\n"; `$cmd_str`; } if($longdesc) { $cmd_str = "bins_edit -a -m --longdesc \"$longdesc\" $dir"; print "$cmd_str\n"; `$cmd_str`; } #print "\t$cmd_str\n"; $cmd_str = "bins_edit -a -m --title \"$title\" $dir"; print "$cmd_str\n"; `$cmd_str`; } else { $cmd_str = "bins_edit -m -t \"$title\" $dir/$file"; print "$cmd_str\n"; `$cmd_str`; #print "\t$cmd_str\n"; $cmd_str = "bins_edit -m -d \"$desc\" $dir/$file"; print "$cmd_str\n"; `$cmd_str`; #print "\t$cmd_str\n\n"; } } $inc_file = "include_images.txt"; for($i=0; $i<=$#ARGV; $i++) { $dir = $ARGV[$i]; if($dir eq "-f" && $i<$#ARGV ) { $i++; $inc_file=$ARGV[$i]; next; } open(FILE, "$dir/$inc_file") or die "Could not open: $dir/$inc_file"; $title = ""; $desc = ""; $img_file = "album"; $section = 1; while() { chomp; $line=$_; if(substr($line, 0 , 1) eq "") { next; } if(substr($line, 0 , 1) ne "#") { process_file($dir, $img_file, $title, $desc); $img_file = $line; $title = ""; $desc = ""; $section = 1; } else { if ($section == 1) { $title = substr($line, 1); $section++; } elsif ($section == 2) { $desc .= substr($line, 1)."\n"; } } } if($section) { process_file($dir, $img_file, $title, $desc); } close(FILE) ; }