consistently load the managed images directory from the config file
authorTony Cook <tony@develop-help.com>
Thu, 26 Jul 2012 08:56:18 +0000 (18:56 +1000)
committerTony Cook <tony@develop-help.com>
Thu, 26 Jul 2012 08:59:46 +0000 (18:59 +1000)
Previously it was handled inconsistently.

This also consistently uses the images uri configured in the config file.

You can also configure a separate base uri for the images included with
BSE as [uri].dist_images.

DATADIR is also now configurable as [paths].data

20 files changed:
localinst.perl
site/cgi-bin/admin/imageclean.pl
site/cgi-bin/bse.cfg
site/cgi-bin/modules/BSE/Arrows.pm
site/cgi-bin/modules/BSE/CfgInfo.pm
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/BSE/Formatter.pm
site/cgi-bin/modules/BSE/Index/BSE.pm
site/cgi-bin/modules/BSE/Storage/LocalImages.pm
site/cgi-bin/modules/BSE/SubscriptionType.pm
site/cgi-bin/modules/BSE/TB/Image.pm
site/cgi-bin/modules/BSE/TB/Images.pm
site/cgi-bin/modules/BSE/TB/SiteCommon.pm
site/cgi-bin/modules/BSE/UI/AdminShop.pm
site/cgi-bin/modules/BSE/Util/Tags.pm
site/cgi-bin/modules/Generate.pm
site/cgi-bin/modules/Generate/Article.pm
site/cgi-bin/modules/Generate/Catalog.pm
site/docs/config.pod
site/docs/templates.pod

index 90270a28010516c72bde3e2412459d85f4651f10..780d3c749daecb95be91c7df6230ea8ca9f666a2 100644 (file)
@@ -71,7 +71,7 @@ my $dbpass = BSE::Test::test_dbpass();
 #$con =~ s/(^\$DBCLASS = ')[^']*/$1 . BSE::Test::test_dbclass()/me;
 #$con =~ s/(^\$UN = ')[^']*/$1$dbuser/m;
 #$con =~ s/(^\$PW = ')[^']*/$1$dbpass/m;
-$con =~ s/(^\$BASEDIR = ')[^']+/$1 . BSE::Test::base_dir/me;
+#$con =~ s/(^\$BASEDIR = ')[^']+/$1 . BSE::Test::base_dir/me;
 #$con =~ s/(^\$URLBASE = ["'])[^'"]+/$1 . BSE::Test::base_url/me;
 #$con =~ s/(^\$SECURLBASE = ["'])[^'"]+/$1 . BSE::Test::test_securl/me;
 $con =~ s/(^\$SESSION_CLASS = [\"\'])[^\'\"]+/$1 . BSE::Test::test_sessionclass()/me;
@@ -87,11 +87,12 @@ my $conffile = BSE::Test::test_conffile();
 my %conf;
 $conf{site}{url} = BSE::Test::base_url();
 $conf{site}{secureurl} = BSE::Test::base_securl();
-my $uploads = "$instbase/uploads";
-$conf{paths}{downloads} = $uploads;
-my $templates = "$instbase/templates";
-$conf{paths}{templates} = $templates;
-$conf{paths}{public_html} = "$instbase/htdocs";
+$conf{paths}{siteroot} = $instbase;
+#my $uploads = "$instbase/uploads";
+#$conf{paths}{downloads} = $uploads;
+#my $templates = "$instbase/templates";
+#$conf{paths}{templates} = $templates;
+#$conf{paths}{public_html} = "$instbase/htdocs";
 open TESTCONF, "< $conffile"
   or die "Could not open config file $conffile: $!";
 while (<TESTCONF>) {
@@ -100,7 +101,7 @@ while (<TESTCONF>) {
   $conf{lc $1}{lc $2} = $3;
 }
 
-$uploads = $conf{paths}{downloads};
+#$uploads = $conf{paths}{downloads};
 # create installation config
 
 $conf{db}{class} = BSE::Test::test_dbclass();
@@ -123,9 +124,9 @@ for my $section_name (keys %conf) {
 
 close CFG;
 
--d $uploads 
-  or mkdir $uploads, 0777 
-  or die "Cannot find or create upload directory: $!";
+#-d $uploads 
+#  or mkdir $uploads, 0777 
+#  or die "Cannot find or create upload directory: $!";
 
 
 # build the database
index 924d63dd1d32ab3bbb695a4c6bfb8fb085e8fc1c..7b0c4bfc7a8c8991827f1b8172e03262c9b3a67d 100755 (executable)
@@ -2,9 +2,13 @@
 use strict;
 use FindBin;
 use lib "$FindBin::Bin/../modules";
+use BSE::API qw(bse_init);
 use BSE::TB::Images;
 use Articles;
-use Constants qw($IMAGEDIR);
+use BSE::CfgInfo qw(cfg_image_dir);
+use File::Spec::Functions qw(catfile);
+
+bse_init("..");
 
 my %articleIds = ( -1 => 1 );
 my $images = BSE::TB::Images->new;
@@ -54,16 +58,17 @@ for my $id (@articleids) {
 
 print "\nRemoving unused images\n";
 
-opendir IMG, $IMAGEDIR
-  or do { print "Cannot open $IMAGEDIR: $!\n"; exit };
+my $image_dir = cfg_image_dir();
+opendir IMG, $image_dir
+  or do { print "Cannot open $image_dir: $!\n"; exit };
 while (defined(my $file = readdir IMG)) {
   if ($file =~ /^\d{8}/) {
     print ".";
-    unless ($names{$file} || !-f "$IMAGEDIR$file") {
+    unless ($names{$file} || !-f catfile($image_dir, $file)) {
       print "x";
-      
-      unlink $IMAGEDIR.$file
-       or print "\nCould not remove $IMAGEDIR$file: $!\n";
+
+      unlink catfile($image_dir, $file)
+       or print "\nCould not remove $image_dir$file: $!\n";
     }
   }
 }
@@ -82,12 +87,13 @@ imageclean.pl - clean up the images directory and image records
 
 =head1 WARNING
 
-This will remove B<any> images in $IMAGEDIR that have names starting
-with 8 or more digits if they don't exist in the C<image> table as a
-record with a current article number.
+This will remove B<any> images in the configured managed images
+directory that have names starting with 8 or more digits if
+they don't exist in the C<image> table as a record with a current
+article number.
 
 If you need image names of this form, put them elsewhere, or
-reconfigure $IMAGEDIR.
+reconfigure the managed images directory.
 
 =head1 DESCRIPTION
 
@@ -109,7 +115,8 @@ older versions didn't remove the image files when images were removed
 
 =item
 
-you may have deleted articles with images under an older version, which would have left the image records (and the image files)
+you may have deleted articles with images under an older version,
+which would have left the image records (and the image files)
 
 =back
 
index 4f3b008b4a9bcec68f015dd40b1573819ffe57b7..83332d5d261dd0ccfe3f382043ee342fc20d8f44 100644 (file)
@@ -13,11 +13,19 @@ preload_template=preload.tmpl
 
 [paths]
 ; the following needs to be set to a path writable by the BSE processes
-downloads = /somewhere
-siteuser_images = $(paths/downloads)
-dynamic_cache=$(paths/downloads)/../cache
-backgroundlogs=$(downloads)/../backlogs
+; set [paths].siteroot
+downloads = $(siteroot)/uploads
+siteuser_images = $(downloads)
+dynamic_cache=$(siteroot)/cache
+backgroundlogs=$(siteroot)/backlogs
+public_html=$(siteroot)/htdocs
 public_files=$(public_html)/managed_assets
+images=$(public_html)/managed_assets
+data=($siteroot)/data
+templates=$(siteroot)/templates
+
+[uri]
+images=/managed_assets
 
 [pregenerate]
 
index a001d4559eada120481baee4c43a54bcb9c3703e..19254c818a45967ccfd501364ac2ebe53fcfc869 100644 (file)
@@ -1,8 +1,9 @@
 package BSE::Arrows;
 use strict;
 use BSE::Util::HTML;
+use BSE::CfgInfo qw(cfg_dist_image_uri);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 use base 'Exporter';
 
@@ -16,7 +17,7 @@ sub make_arrows {
   my $section = $type ? "$type arrows" : "arrows";
   my $prefix = $cfg->entry($section, "prefix", $type);
 
-  my $images_uri = $cfg->entry('uri', 'images', '/images');
+  my $images_uri = cfg_dist_image_uri();
   my $html = '';
   my $want_xhtml = $cfg->entryBool('basic', 'xhtml', 1);
   my $extra_attr = "";
@@ -31,7 +32,7 @@ sub make_arrows {
     $extra_attr .= qq(width="$image_width" height="$image_height" );
   }
 
-  my $nomove = qq'<img src="/images/trans_pixel.gif" alt="" $extra_attr/>';
+  my $nomove = qq'<img src="$images_uri/trans_pixel.gif" alt="" $extra_attr/>';
   if ($down_url) {
     my $down_img = $cfg->entry($section, "downimg", "$images_uri/admin/${prefix}move_down.gif");
     $down_url .= "&r=".escape_uri($refresh) if $refresh;
index 73d12ee07012945aadc65a15b625ddb75fdb28f7..d2d03a69ece1b68bcadda058b10c6de86b4895f1 100644 (file)
@@ -1,12 +1,12 @@
 package BSE::CfgInfo;
 use strict;
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 use vars qw(@ISA @EXPORT_OK);
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT_OK = qw(custom_class admin_base_url cfg_image_dir credit_card_class product_options bse_default_country);
+@EXPORT_OK = qw(custom_class admin_base_url cfg_image_dir cfg_image_uri cfg_dist_image_uri cfg_data_dir credit_card_class product_options bse_default_country);
 
 =head1 NAME
 
@@ -79,10 +79,74 @@ sub admin_base_url {
   return $base;
 }
 
+=item cfg_image_dir()
+
+Return the directory configured for storage of managed images.
+
+=cut
+
 sub cfg_image_dir {
   my ($cfg) = @_;
 
-  $cfg->entry('paths', 'images', $Constants::IMAGEDIR);
+  $cfg ||= BSE::Cfg->single;
+
+  return $cfg->entryIfVar('paths', 'images', $Constants::IMAGEDIR);
+}
+
+=item cfg_image_uri()
+
+Return the configured base URI for managed images.
+
+This should correspond to the directory specified by [paths].images
+
+Configured with [uri].images
+
+=cut
+
+sub cfg_image_uri {
+  my ($cfg) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  require Constants;
+  return $cfg->entryIfVar('uri', 'images', $Constants::IMAGES_URI);
+}
+
+=item cfg_dist_image_uri()
+
+Return the configured base URI for images distributed with BSE.
+
+This imcludes images such as F<trans_pixel.gif> and C<admin/error.gif>.
+
+Must not include a trailing C</>.
+
+Configured with [uri].dist_images
+
+=cut
+
+sub cfg_dist_image_uri {
+  my ($cfg) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  return $cfg->entryIfVar('uri', 'dist_images', "/images");
+}
+
+=item cfg_data_dir()
+
+Returns the directory configured for storage of files such as
+F<stopwords.txt>.
+
+Configured with [paths].data
+
+=cut
+
+sub cfg_data_dir {
+  my ($cfg) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  return $cfg->entryIfVar('paths', 'data', $Constants::DATADIR);
 }
 
 =item credit_card_class
index e1a61021514abb15421a7bed4fec65634360ab4c..01c5f6f03fa93dbd9ba94793427a22cfb0710b2e 100644 (file)
@@ -6,7 +6,7 @@ use BSE::Util::SQL qw(now_sqldate now_sqldatetime);
 use BSE::Permissions;
 use BSE::Util::HTML qw(:default popup_menu);
 use BSE::Arrows;
-use BSE::CfgInfo qw(custom_class admin_base_url cfg_image_dir);
+use BSE::CfgInfo qw(custom_class admin_base_url cfg_image_dir cfg_dist_image_uri cfg_image_uri);
 use BSE::Util::Iterate;
 use BSE::Template;
 use BSE::Util::ContentType qw(content_type);
@@ -15,7 +15,7 @@ use DevHelp::Date qw(dh_parse_date dh_parse_sql_date);
 use List::Util qw(first);
 use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
 
-our $VERSION = "1.026";
+our $VERSION = "1.027";
 
 =head1 NAME
 
@@ -704,7 +704,7 @@ sub tag_move_stepparent {
   $urladd = '' unless defined $urladd;
 
   my $cgi_uri = $self->{cfg}->entry('uri', 'cgi', '/cgi-bin');
-  my $images_uri = $self->{cfg}->entry('uri', 'images', '/images');
+  my $images_uri = cfg_dist_image_uri();
   my $html = '';
   my $url = $ENV{SCRIPT_NAME} . "?id=$article->{id}";
   if ($cgi->param('_t')) {
@@ -813,7 +813,7 @@ sub tag_movechild {
   $urladd = '' unless defined $urladd;
 
   my $cgi_uri = $self->{cfg}->entry('uri', 'cgi', '/cgi-bin');
-  my $images_uri = $self->{cfg}->entry('uri', 'images', '/images');
+  my $images_uri = cfg_dist_image_uri();
   my $urlbase = admin_base_url($req->cfg);
   my $refresh_url = "$urlbase$ENV{SCRIPT_NAME}?id=$article->{id}";
   my $t = $req->cgi->param('_t');
@@ -2966,7 +2966,7 @@ sub save_image_changes {
 
            $changes{$id}{image} = $image_name;
            $changes{$id}{storage} = 'local';
-           $changes{$id}{src} = "/images/$image_name";
+           $changes{$id}{src} = cfg_image_uri() . "/" . $image_name;
            $changes{$id}{width} = $width;
            $changes{$id}{height} = $height;
            $changes{$id}{ftype} = $self->_image_ftype($type);
@@ -3257,7 +3257,7 @@ sub do_add_image {
      displayOrder=>time,
      name => $imageref,
      storage => 'local',
-     src => '/images/' . $filename,
+     src => cfg_image_uri() . '/' . $filename,
      ftype => $self->_image_ftype($type),
     );
   require BSE::TB::Images;
@@ -3392,7 +3392,6 @@ sub remove_img {
   }
 
   my $imagedir = cfg_image_dir($req->cfg);
-  unlink "$imagedir$image->{image}";
   $image->remove;
 
   generate_article($articles, $article) if $Constants::AUTO_GENERATE;
@@ -3475,7 +3474,7 @@ sub req_thumb {
     my $geometry_id = $cgi->param('g');
     defined $geometry_id or $geometry_id = 'editor';
     my $geometry = $cfg->entry('thumb geometries', $geometry_id, 'scale(200x200)');
-    my $imagedir = $cfg->entry('paths', 'images', $Constants::IMAGEDIR);
+    my $imagedir = cfg_image_dir();
     
     my $error;
     ($data, $type) = $thumb_obj->thumb_data
@@ -3505,7 +3504,7 @@ sub req_thumb {
   }
   else {
     # grab the nothumb image
-    my $uri = $cfg->entry('editor', 'default_thumbnail', '/images/admin/nothumb.png');
+    my $uri = $cfg->entry('editor', 'default_thumbnail', cfg_dist_image_uri() . '/admin/nothumb.png');
     my $filebase = $cfg->content_base_path;
     if (open IMG, "<$filebase/$uri") {
       binmode IMG;
@@ -3686,7 +3685,7 @@ sub req_save_image {
          $image->{width} = $width;
          $image->{height} = $height;
          $image->{storage} = 'local'; # not on the remote store yet
-         $image->{src} = '/images/' . $image_name;
+         $image->{src} = cfg_image_uri() . '/' . $image_name;
          $image->{ftype} = $self->_image_ftype($type);
        }
        else {
index 617e965c2cdc2442349ca8f92055a6d4180061b5..61fa67351ee6e3b17140e24d0ac8bca94bed7220 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use BSE::Util::HTML;
 use Carp 'confess';
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 use base 'DevHelp::Formatter';
 
@@ -51,7 +51,12 @@ sub new {
 sub image_url {
   my ($self, $im) = @_;
 
-  $im->{src} || "/images/$im->{image}"
+  return $im->{src}
+    if $im->src;
+
+  require BSE::CfgInfo;
+
+  return BSE::CfgInfo::cfg_image_uri() . "/" . $im->{image};
 }
 
 sub _image {
index 0de50055c62776fce4be7d30ee48e2474df3faf3..1b9497d4dea26c24df95bf47656b5377c2c2d4c8 100644 (file)
@@ -2,9 +2,10 @@ package BSE::Index::BSE;
 use strict;
 use base 'BSE::Index::Base';
 use BSE::DB;
-use Constants qw($DATADIR $MAXPHRASE);
+use Constants qw($MAXPHRASE);
+use BSE::CfgInfo qw(cfg_data_dir);
 
-our $VERSION = "1.001";
+our $VERSION = "1.002";
 
 sub new {
   my ($class, %opts) = @_;
@@ -50,7 +51,8 @@ sub new {
 sub start_index {
   my $self = shift;
 
-  my $stopwords = "$DATADIR/stopwords.txt";
+  my $data_dir = cfg_data_dir();
+  my $stopwords = "$data_dir/stopwords.txt";
 
   # load the stop words
   open STOP, "< $stopwords"
index 695a8eb6138a60a906f3c3e6e8295350ca2c2445..8ce309e66643510005e38bb275f99bfe087b682b 100644 (file)
@@ -2,19 +2,21 @@ package BSE::Storage::LocalImages;
 use strict;
 use BSE::Storage::LocalBase;
 our @ISA = qw(BSE::Storage::LocalBase);
+use BSE::CfgInfo qw(cfg_image_uri);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 sub store {
   my ($self, $path, $basename) = @_;
   # nothing to do
 
-  return '/images/' . $basename;
+  return cfg_image_uri() . '/' . $basename;
 }
 
 sub url {
   my ($self, $basename) = @_;
-  '/images/' . $basename;
+
+  return cfg_image_uri() . '/' . $basename;
 }
 
 1;
index 182e9ac33d484b6ab9fc2975963a91d047a1096b..1aa0fad7e7fb2b7ec7c181eb463971a0d53947cb 100644 (file)
@@ -5,7 +5,7 @@ use Squirrel::Row;
 use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row/;
 
-our $VERSION = "1.001";
+our $VERSION = "1.002";
 
 sub columns {
   return qw/id name title description frequency keyword archive 
@@ -404,7 +404,7 @@ sub send {
     my @cols = Article->columns;
     shift @cols;
     my $article = Articles->add(@article{@cols});
-    use Constants qw(:edit $CGI_URI $IMAGES_URI $ARTICLE_URI $LINK_TITLES);
+    use Constants qw(:edit $CGI_URI $ARTICLE_URI $LINK_TITLES);
     my $link = "$ARTICLE_URI/$article->{id}.html";
     if ($LINK_TITLES) {
       (my $extra = lc $article->{title}) =~ tr/a-z0-9/_/sc;
index 068e39d940f3f67316c76a82abe2a949be8bfac3..4ba05909c69bc8b5e24292c93fefc884c788aff0 100644 (file)
@@ -7,7 +7,7 @@ use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row BSE::ThumbCommon/;
 use Carp qw(confess);
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 sub columns {
   return qw/id articleId image alt width height url displayOrder name
@@ -114,6 +114,13 @@ sub article {
   }
 }
 
+sub remove {
+  my ($self) = @_;
+
+  unlink $self->full_filename;
+  return $self->SUPER::remove();
+}
+
 sub update {
   my ($image, %opts) = @_;
 
index f02820bd186c43e5c00d63658217449363286c93..07419494908b89b666267f7cc8f172e92ab85d8d 100644 (file)
@@ -5,7 +5,7 @@ use vars qw(@ISA $VERSION);
 @ISA = qw(Squirrel::Table);
 use BSE::TB::Image;
 
-our $VERSION = "1.002";
+our $VERSION = "1.003";
 
 sub rowClass {
   return 'BSE::TB::Image';
@@ -27,10 +27,13 @@ Return the base URI for images stored in the image_dir().
 
 Traditionally C</images/>, but it's meant to be configurable.
 
+This includes a trailing C</> unlike L<BSE::CfgInfo/cfg_image_uri()>.
+
 =cut
 
 sub base_uri {
-  return BSE::Cfg->single->entryIfVar("site", "images", "/images/");
+  require BSE::CfgInfo;
+  return BSE::CfgInfo::cfg_image_uri() . "/";
 }
 
 =item get_ftype($is_type)
index 428767182329eba35d31f690c7de3eec5b08ff1c..314c5d060b3d8e79b1d95b08a08e1b09d41fd559 100644 (file)
@@ -2,7 +2,7 @@ package BSE::TB::SiteCommon;
 use strict;
 use Carp qw(confess);
 
-our $VERSION = "1.005";
+our $VERSION = "1.006";
 
 =head1 NAME
 
@@ -173,9 +173,11 @@ sub files {
 sub remove_images {
   my ($self, $cfg) = @_;
 
+  $cfg ||= BSE::Cfg->single;
   my @images = $self->images;
   my $mgr;
-  my $imagedir = $cfg->entry('paths', 'images', $Constants::IMAGEDIR);
+  require BSE::CfgInfo;
+  my $imagedir = BSE::CfgInfo::cfg_image_dir($cfg);
   for my $image (@images) {
     if ($image->{storage} ne 'local') {
       unless ($mgr) {
@@ -185,7 +187,6 @@ sub remove_images {
       $mgr->unstore($image->{image}, $image->{storage});
     }
 
-    unlink("$imagedir/$image->{image}");
     $image->remove();
   }
 }
index c883d3ac2f3a97406d347bbd14be000f9ae2182c..de96e221cc52fee59c43f2a3e0fbbec6a31ba0ff 100644 (file)
@@ -6,9 +6,8 @@ use Product;
 use BSE::TB::Orders;
 use BSE::TB::OrderItems;
 use BSE::Template;
-#use Squirrel::ImageEditor;
 use Constants qw(:shop $SHOPID $PRODUCTPARENT 
-                 $SHOP_URI $CGI_URI $IMAGES_URI $AUTO_GENERATE);
+                 $SHOP_URI $CGI_URI $AUTO_GENERATE);
 use BSE::TB::Images;
 use Articles;
 use BSE::Sort;
@@ -18,8 +17,9 @@ use BSE::WebUtil 'refresh_to_admin';
 use BSE::Util::HTML qw(:default popup_menu);
 use BSE::Arrows;
 use BSE::Shop::Util qw(:payment order_item_opts nice_options payment_types);
+use BSE::CfgInfo qw(cfg_dist_image_uri);
 
-our $VERSION = "1.015";
+our $VERSION = "1.016";
 
 my %actions =
   (
@@ -84,7 +84,8 @@ sub embedded_catalog {
     grep $_->{generator} eq 'Generate::Catalog', 
     Articles->children($catalog->{id});
 
-  my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+  my $image_uri = cfg_dist_image_uri();
+  my $blank = qq!<img src="$image_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
 
   my %acts;
   %acts =
@@ -201,7 +202,8 @@ sub req_product_list {
     $products->getBy(parentid => $shopid);
   my $product_index;
 
-  my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+  my $image_uri = cfg_dist_image_uri();
+  my $blank = qq!<img src="$image_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
 
   my $it = BSE::Util::Iterate->new;
 
@@ -354,7 +356,8 @@ sub product_form {
 #      if $product->{id};
   my $image_index;
 
-  my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+  my $image_uri = cfg_dist_image_uri();
+  my $blank = qq!<img src="$image_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
 
   my %acts;
   %acts =
index b415b92c709f967a34649b6b0c6f748d25496c02..9bf23af5da362a20756bbf227a6b844eae08407b 100644 (file)
@@ -8,7 +8,7 @@ use vars qw(@EXPORT_OK @ISA);
 @ISA = qw(Exporter);
 require Exporter;
 
-our $VERSION = "1.021";
+our $VERSION = "1.022";
 
 sub _get_parms {
   my ($acts, $args) = @_;
@@ -964,7 +964,7 @@ sub tag_error_img {
     return '' unless @$msg > $num && $msg->[$num];
     $msg = $msg->[$num];
   }
-  my $images_uri = $cfg->entry('uri', 'images', '/images');
+  my $images_uri = BSE::CfgInfo::cfg_dist_image_uri($cfg);
   my $image = $cfg->entry('error_img', 'image', "$images_uri/admin/error.gif");
   my $width = $cfg->entry('error_img', 'width', 16);
   my $height = $cfg->entry('error_img', 'height', 16);
index f6a9bfa047aff86c76fc7e381e7fa31e6c6a72b4..8e29a4573e679c4b37ee9ef1340feb4bf43773b9 100644 (file)
@@ -1,19 +1,19 @@
 package Generate;
 use strict;
 use Articles;
-use Constants qw($IMAGEDIR $LOCAL_FORMAT $BODY_EMBED 
+use Constants qw($LOCAL_FORMAT $BODY_EMBED 
                  $EMBED_MAX_DEPTH $HAVE_HTML_PARSER);
 use DevHelp::Tags;
 use BSE::Util::HTML;
 use BSE::Util::Tags qw(tag_article);
-use BSE::CfgInfo qw(custom_class);
+use BSE::CfgInfo qw(custom_class cfg_image_dir cfg_image_uri);
 use BSE::Util::Iterate;
 use BSE::TB::Site;
 use BSE::Variables;
 use base 'BSE::ThumbLow';
 use base 'BSE::TagFormats';
 
-our $VERSION = "1.009";
+our $VERSION = "1.010";
 
 my $excerptSize = 300;
 
@@ -922,8 +922,11 @@ sub baseActs {
      titleImage=>
      sub {
        my ($image, $text) = split ' ', $_[0];
-       if (-e $IMAGEDIR."/titles/".$image) {
-         return qq!<img src="/images/titles/!.$image .qq!" border=0>!
+
+       my $image_dir = cfg_image_dir();
+       if (-e "$image_dir/titles/$image") {
+        my $image_uri = cfg_image_uri();
+         return qq!<img src="$image_uri/titles/!.$image .qq!" border=0>!
        }
        else {
          return escape_html($text);
@@ -1450,8 +1453,8 @@ Conditional tag, true if the given item can appear in a menu.
 =item titleImage I<imagename> I<text>
 
 Generates an IMG tag if the given I<imagename> is in the title image
-directory ($IMAGEDIR/titles).  If it doesn't exists, produces the
-I<text>.
+directory (F<titles> in the managed images directory).  If it doesn't
+exist, produce I<text>.
 
 =item embed I<which>
 
index fd621f4a59c9d72c370321d8721c59da743ec01f..dacda23b45aab091c585540c8a86574b04ccd72e 100644 (file)
@@ -1,7 +1,7 @@
 package Generate::Article;
 use strict;
 use BSE::Template;
-use Constants qw(%LEVEL_DEFAULTS $CGI_URI $ADMIN_URI $IMAGES_URI 
+use Constants qw(%LEVEL_DEFAULTS $CGI_URI $ADMIN_URI
                  $UNLISTED_LEVEL1_IN_CRUMBS);
 use BSE::TB::Images;
 use vars qw(@ISA);
@@ -14,8 +14,9 @@ use BSE::Util::HTML;
 use BSE::Arrows;
 use Carp 'confess';
 use BSE::Util::Iterate;
+use BSE::CfgInfo qw(cfg_dist_image_uri);
 
-our $VERSION = "1.005";
+our $VERSION = "1.006";
 
 my $excerptSize = 300;
 
@@ -110,7 +111,7 @@ sub tag_title {
   }
 
   if ($im) {
-    my $src = $im->{src} || "/images/$im->{image}";
+    my $src = $im->image_url;
     $src = escape_html($src);
     return qq!<img src="$src" width="$im->{width}"!
       . qq! height="$im->{height}" alt="$title" class="bse_image_title" />!;
@@ -409,7 +410,8 @@ sub baseActs {
     BSE::TB::ArticleFiles->getBy(articleId=>$article->{id});
   my @files = grep !$_->{hide_from_list}, @all_files;
   
-  my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif"  width="17" height="13" border="0" align="absbottom" alt="" />!;
+  my $image_uri = cfg_dist_image_uri();
+  my $blank = qq!<img src="$image_uri/trans_pixel.gif"  width="17" height="13" border="0" align="absbottom" alt="" />!;
 
   my $top = $self->{top} || $article;
   my $abs_urls = $self->abs_urls($article);
@@ -454,7 +456,8 @@ sub baseActs {
           (my $image = $templater->perform($acts, $which, 'thumbImage'))) {
         my $width = $templater->perform($acts, $which, 'thumbWidth');
         my $height = $templater->perform($acts, $which, 'thumbHeight');
-         my $result = '<img src="/images/'.$image
+        my $image_uri = cfg_image_uri();
+         my $result = qq(<img src="$image_uri/$image")
            .'" width="'.$width
              .'" height="'.$height.'"';
          $result .= qq! class="$class"! if $class;
@@ -532,7 +535,7 @@ sub baseActs {
        @children > 1 or return '';
        if ($self->{admin} && $child_index < $#children) {
          my $html = <<HTML;
-<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&amp;d=down"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="bottom" /></a>
+<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&amp;d=down"><img src="$image_uri/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="bottom" /></a>
 HTML
         chop $html;
         return $html;
@@ -545,7 +548,7 @@ HTML
        @children > 1 or return '';
        if ($self->{admin} && $child_index > 0) {
          my $html = <<HTML;
-<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&amp;d=up"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="bottom" /></a>
+<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&amp;d=up"><img src="$image_uri/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="bottom" /></a>
 HTML
         chop $html;
         return $html;
index 90d02223f0f34728a130da382c6a79fa04aa8c88..604dc6d8d1762b2c63c966b0197a43d15046618c 100644 (file)
@@ -1,18 +1,19 @@
 package Generate::Catalog;
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 use strict;
 use Generate;
 use Products;
 use base 'Generate::Article';
 use BSE::Template;
-use Constants qw($CGI_URI $IMAGES_URI $ADMIN_URI);
+use Constants qw($CGI_URI $ADMIN_URI);
 use BSE::Regen qw(generate_button);
 use OtherParents;
 use DevHelp::HTML;
 use BSE::Arrows;
 use BSE::Util::Iterate;
+use BSE::CfgInfo qw(cfg_dist_image_uri);
 
 sub _default_admin {
   my ($self, $article, $embedded) = @_;
@@ -160,6 +161,7 @@ sub baseActs {
   my $it = BSE::Util::Iterate->new;
   my $cfg = $self->{cfg};
   my $art_it = BSE::Util::Iterate::Article->new(cfg => $cfg);
+  my $image_uri = cfg_dist_image_uri();
   my %work =
     (
      $self->SUPER::baseActs($articles, $acts, $article, $embedded),
@@ -172,7 +174,7 @@ sub baseActs {
      sub {
        if ($self->{admin} && $product_index < $#products) {
         my $html = <<HTML;
- <a href="$CGI_URI/admin/move.pl?id=$products[$product_index]{id}&amp;d=down"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom" /></a>
+ <a href="$CGI_URI/admin/move.pl?id=$products[$product_index]{id}&amp;d=down"><img src="$image_uri/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom" /></a>
 HTML
         chop $html;
         return $html;
@@ -185,7 +187,7 @@ HTML
      sub {
        if ($self->{admin} && $product_index > 0) {
         my $html = <<HTML;
- <a href="$CGI_URI/admin/move.pl?id=$products[$product_index]{id}&amp;d=up"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom" /></a>
+ <a href="$CGI_URI/admin/move.pl?id=$products[$product_index]{id}&amp;d=up"><img src="$image_uri/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom" /></a>
 HTML
         chop $html;
         return $html;
@@ -214,7 +216,7 @@ HTML
        my $can_move_up = $allprod_index > 0;
        my $can_move_down = $allprod_index < $#allprods;
        return '' unless $can_move_up || $can_move_down;
-       my $blank = '<img src="/images/trans_pixel.gif" width="17" height="13" border="0" align="absbotton" alt="" />';
+       my $blank = qq(<img src="$image_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbotton" alt="" />);
        my $myid = $allprods[$allprod_index]{id};
        my $top = $self->{top} || $article;
        my $refreshto = "$CGI_URI/admin/admin.pl?id=$top->{id}$urladd";
index c2c9874481752526770db7cb08674bbb44876291..732de4b272899f64200f72d8968122e8d938d537 100644 (file)
@@ -1,4 +1,3 @@
-
 =head1 NAME
 
 config.pod - documents BSE configuration file options
@@ -1140,17 +1139,28 @@ This is underused, so don't rely on it yet.
 
 =over
 
+=item articles
+
 =item cgi
 
 The URI to the CGI directory.  Default: /cgi-bin
 
+=item dist_images
+
+The URI where images included with BSE can be found.
+
+This includes images such as F<trans_pixel.gif> and C<admin/error.gif>.
+
+Default: C</images>
+
 =item images
 
-The URI where images are kept.  Default: /images
+The URI where managed images are kept which should correspond to
+C<images> in C<[paths]>.
 
-=item shop
+Default: C</images> (from C<$Constants::IMAGES_URI>)
 
-=item articles
+=item shop
 
 =back
 
index 457711168f7b9fad8a2af87089ca7c9b04f175eb..a441fb39e47f7ed52ad68e207ab27de7cb58a16c 100644 (file)
@@ -871,8 +871,8 @@ Conditional tag, true if the given item can appear in a menu.
 =item titleImage I<imagename> I<text>
 
 Generates an IMG tag if the given I<imagename> is in the title image
-directory ($IMAGEDIR/titles).  If it doesn't exists, produces the
-I<text>.
+directory (F<titles> in the configured image directory).  If it
+doesn't exists, produces the I<text>.
 
 =item embed I<which>