0.14_34 commit r0_14_34
authorTony Cook <tony@develop-help.com>
Wed, 22 Sep 2004 02:23:43 +0000 (02:23 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Wed, 22 Sep 2004 02:23:43 +0000 (02:23 +0000)
15 files changed:
Makefile
site/cgi-bin/admin/admin.pl
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/BSE/Edit/Site.pm
site/cgi-bin/modules/BSE/Util/Tags.pm
site/cgi-bin/modules/DevHelp/HTML.pm
site/cgi-bin/modules/SiteUser.pm
site/cgi-bin/search.pl
site/cgi-bin/shop.pl
site/docs/bse.pod
site/docs/config.pod
site/templates/search_base.tmpl
t/t20gen.t
test-imager.cfg [new file with mode: 0644]
test.cfg

index 1ee4fb7a3487f0d9f5359a2f17d2c19687ddc529..c016d3cd32e902515a5800366b24e6913a13f01c 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.14_33
+VERSION=0.14_34
 DISTNAME=bse-$(VERSION)
 DISTBUILD=$(DISTNAME)
 DISTTAR=../$(DISTNAME).tar
index 553e64adf5c823ddebf0cbc206281ebe12f51e72..d6d2393844b3c8b0d1b210534b01d066b5751f3c 100755 (executable)
@@ -23,17 +23,24 @@ if ($req->check_admin_logon()) {
   #my $articles = Articles->new;
   my $articles = 'Articles';
   
-  my $article = $articles->getByPkey($id)
-    or die "Cannot find article ",$id;
-  
-  eval "use $article->{generator}";
-  die $@ if $@;
-  my $generator = $article->{generator}
-    ->new(admin=>$admin, articles=>$articles, cfg=>$cfg, request=>$req, 
-         top=>$article);
-  
-  print "Content-Type: text/html\n\n";
-  print $generator->generate($article, $articles);
+  my $article;
+  $article = $articles->getByPkey($id) if $id =~ /^\d+$/;
+
+  if ($article) {
+    eval "use $article->{generator}";
+    die $@ if $@;
+    my $generator = $article->{generator}
+      ->new(admin=>$admin, articles=>$articles, cfg=>$cfg, request=>$req, 
+           top=>$article);
+    
+    print "Content-Type: text/html\n\n";
+    print $generator->generate($article, $articles);
+  }
+  else {
+    # display a message on the admin menu
+    refresh_to_admin($req->cfg,
+                    $req->url(menu =>{ 'm' => "No such article '${id}'"} ));
+  }
 }
 else {
   refresh_to_admin($cfg, "/cgi-bin/admin/logon.pl");
index 4089026f36b13e60232b5c54f7768228b0ed3e05..70bcce795fc2b35ae7eb39433bde68ffa535440c 100644 (file)
@@ -958,6 +958,8 @@ sub _get_thumbs_class {
 sub tag_thumbimage {
   my ($cfg, $thumbs_obj, $current_image, $args) = @_;
 
+  $thumbs_obj or return '';
+
   $$current_image or return '** no current image **';
 
   my $imagedir = cfg_image_dir($cfg);
@@ -2199,7 +2201,7 @@ sub req_thumb {
   my $im_id = $cgi->param('im');
   my $image;
   if (defined $im_id && $im_id =~ /^\d+$/) {
-    ($image) = grep $_->{id} == $im_id, $article->images;
+    ($image) = grep $_->{id} == $im_id, $self->get_images($article);
   }
   my $thumb_obj = $self->_get_thumbs_class();
   my ($data, $type);
@@ -2267,70 +2269,84 @@ sub table_object {
 my %types =
   (
    qw(
-   pdf  application/pdf
-   txt  text/plain
+   bash text/plain
+   css  text/css
+   csv  text/plain
+   diff text/plain
    htm  text/html
    html text/html
+   ics  text/calendar
+   patch text/plain
+   pl   text/plain
+   pm   text/plain
+   pod  text/plain
+   py   text/plain
    sgm  text/sgml
    sgml text/sgml
-   xml  text/xml
+   sh   text/plain
+   tcsh text/plain
+   text text/plain
    tsv  text/tab-separated-values
-   csv  text/plain
+   txt  text/plain
+   vcf  text/x-vcard
+   vcs  text/x-vcalendar
+   xml  text/xml
+   zsh  text/x-script.zsh
+   bmp  image/bmp 
    gif  image/gif
-   jpg  image/jpeg
-   jpeg image/jpeg
    jp2  image/jpeg2000
+   jpeg image/jpeg
+   jpg  image/jpeg   
+   pct  image/pict 
+   pict image/pict
    png  image/png
-   bmp  image/bmp
    tif  image/tiff
    tiff image/tiff
-   pct  image/pict
-   pict image/pict
+   Z    application/x-compress
+   dcr  application/x-director
+   dir  application/x-director
+   doc  application/msword
+   dxr  application/x-director
    eps  application/postscript
+   fla  application/x-shockwave-flash
+   gz   application/gzip
+   hqx  application/mac-binhex40
+   js   application/x-javascript
+   lzh  application/x-lzh
+   pdf  application/pdf
+   pps  application/ms-powerpoint
+   ppt  application/ms-powerpoint
    ps   application/postscript
-   doc  application/msword
    rtf  application/rtf
-   zip  application/zip
-   gz   application/gzip
+   sit  application/x-stuffit
+   swf  application/x-shockwave-flash
    tar  application/x-tar
    tgz  application/gzip
-   hqx  application/mac-binhex40
-   bin  application/macbinary
-   sit  application/x-stuffit
-   Z    application/x-compress
    xls  application/ms-excel
-   ppt  application/ms-powerpoint
-   swf  application/x-shockwave-flash
-   fla  application/x-shockwave-flash
-   dxr  application/x-director
-   dcr  application/x-director
-   dir  application/x-director
-   mov  video/quicktime
+   zip  application/zip
+   asf  video/x-ms-asf
+   avi  video/avi
+   flc  video/flc
    moov video/quicktime
-   mpg  video/mpeg
+   mov  video/quicktime
    mp4  video/mp4
    mpeg video/mpeg
-   avi  video/avi
-   flc  video/flc
+   mpg  video/mpeg
    wmv  video/x-ms-wmv
-   asf  video/x-ms-asf
-   mp2  audio/x-mpeg
-   mp3  audio/x-mpeg
-   m4a  audio/m4a
-   3gp  audio/3gpp
+   aa   audio/audible
    aif  audio/aiff
    aiff audio/aiff
-   aa   audio/audible
+   m4a  audio/m4a
+   mid  audio/midi
+   mp2  audio/x-mpeg
+   mp3  audio/x-mpeg
    ra   audio/x-realaudio
    ram  audio/x-pn-realaudio
    rm   audio/vnd.rm-realmedia
+   swa  audio/mp3
    wav  audio/wav
    wma  audio/x-ms-wma
-   mid  audio/midi
-   swa  audio/mp3
-   diff text/plain
-   patch text/plain
-   css  text/css
+   3gp  audio/3gpp
    )
   );
 
index ad1cdcc0388b77d6e49fe0622e98a680647a3021..7442f2725c2e9c56ef0cb26e930bdf1238eb4500 100644 (file)
@@ -25,7 +25,7 @@ sub edit_sections {
 }
 
 my @site_actions =
-  qw(edit artimg process addimg removeimg moveimgup moveimgdown);
+  qw(edit artimg process addimg removeimg moveimgup moveimgdown a_thumb);
 
 sub article_actions {
   my ($self) = @_;
index 093b3a9007e19e3d17c97f7edaf8b80c3d43ca14..db41974e749aa86e4feaefdb6cb5bd78eba1c62e 100644 (file)
@@ -277,15 +277,26 @@ sub tag_arithmetic {
 
   my $prefix;
 
-  if ($arg =~ s/^\s*([^:\s]+)://) {
+  if ($arg =~ s/^\s*([^:\s]*)://) {
     $prefix = $1;
   }
   else {
     $prefix = '';
   }
-
-  $arg =~ s/\[\s*(\w+)(\s+\S[^\[\]]*)?\s*\]/
-    $templater->perform($acts, $1, $2)/ge;
+  
+  my $not_found;
+  $arg =~ s/(\[\s*(\w+)(\s+\S[^\[\]]*)?\s*\])/
+    exists $acts->{$2} ? $templater->perform($acts, $2, $3) 
+      : (++$not_found, $1)/ge;
+
+  if ($not_found) {
+    if ($prefix eq '') {
+      return "<:arithmetic $arg:>";
+    }
+    else {
+      return "<:arithmetic $prefix: $arg:>";
+    }
+  }
 
   # this may be made more restrictive
   my $result = eval $arg;
@@ -657,8 +668,11 @@ sub tag_error_img {
     $msg = $msg->[$num];
   }
   my $images_uri = $cfg->entry('uri', 'images', '/images');
+  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);
   my $encoded = escape_html($msg);
-  return qq!<img src="$images_uri/admin/error.gif" alt="$encoded" title="$encoded" border="0" align="top" />!; 
+  return qq!<img src="$image" alt="$encoded" title="$encoded" width="$width" height="$height" border="0" align="top" />!; 
 }
 
 sub tag_replace {
index 4b88e765a3819cb76099204cd9468ce24e353ccd..11eda462f85f39d56bedcda28c5b8726176ea85d 100644 (file)
@@ -32,7 +32,7 @@ sub escape_uri {
   # older versions of uri_escape() acted differently without the
   # second argument, so supply one to make sure we escape what
   # needs escaping
-  URI::Escape::uri_escape(shift, "^A-Za-z0-9\-_.!~*'()");
+  URI::Escape::uri_escape(shift, "^A-Za-z0-9\-_.!~*()");
 }
 
 sub unescape_uri {
index 9c02cb1b2151e59e678a0bada809ddcccac34086..35ceb689dd9f5929f16c838bc633d20bf6f50663 100644 (file)
@@ -142,6 +142,11 @@ sub subscriptions {
 
 sub send_conf_request {
   my ($user, $cgi, $cfg, $rcode, $rmsg) = @_;
+
+  if ($user->is_disabled) {
+    $$rmsg = "User is disabled";
+    return;
+  }
       
   my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
   
@@ -373,4 +378,10 @@ sub subscribed_services {
   BSE::DB->query(siteuserSubscriptions => $self->{id});
 }
 
+sub is_disabled {
+  my ($self) = @_;
+
+  return $self->{disabled};
+}
+
 1;
index a553ecc4ee5c706557e3e3acdea6207c8ee4a189..03043507172ef108b13955cb74e928f18b1f30f0 100755 (executable)
@@ -255,6 +255,11 @@ sub getSearchResult {
                    ." and expire <= $now";
        last SWITCH;
       };
+    /^m(\d+)$/ # modified in last N days
+      && do {
+       $sql .= " and lastModified > " . _sql_date(time - $oneday * $1);
+       last SWITCH;
+      };
     $_ eq 'ae'
       && do {
        $sql .= " and expire < $now";
index c80058db5bcec5e441c880b99dcd85d33dd25e91..1d81fbe3dda546ccfc5d06f58eff1d8db7f2b4a4 100755 (executable)
@@ -135,7 +135,7 @@ sub add_item {
   # used to refresh if a logon is needed
   my $r = $securlbase . $ENV{SCRIPT_NAME} . "?add=1&id=$addid";
   for my $opt_index (0..$#opt_names) {
-    $r .= "&$opt_names[$opt_index]=".ecape_uri($options[$opt_index]);
+    $r .= "&$opt_names[$opt_index]=".escape_uri($options[$opt_index]);
   }
   
   my $user = get_siteuser(\%session, $cfg, $CGI::Q);
index fce5343dbab5183eadbc9ad33e632428dd2478b7..1028c66242dfed72382d91935fe701821dd90db8 100644 (file)
@@ -10,6 +10,71 @@ Maybe I'll add some other bits here.
 
 =head1 CHANGES
 
+=head2 0.14_34
+
+=over
+
+=item *
+
+thumbnails weren't implemented for the site view/global image manager,
+they are now available there
+
+=item *
+
+you can now supply a new date selection code to the search engine,
+'mI<number>' will now only list articles that have been modified
+within the last I<number> days.  The supplied search_base.tmpl has
+been modified to include this. (#136)
+
+=item *
+
+updated internal file extension to MIME types based on a list from
+Adrian, types which are basicly text files (like
+C<text/x-script.bash>) have been changed to C<text/plain> so browsers
+don't need to know about obscure aliases for text file types.
+
+=item *
+
+doing a refresh due to failure in adding a product to the cart (due to
+subscription restrictions for example) when the product had options
+would cause a 500 error (#438)
+
+=item *
+
+the arithmetic tag should handle double generated pages where tags
+needed on the second generation are used in the expression.
+
+=item *
+
+we now URI escape apostrophe C<'> when we're URI escaping in general,
+since a trailing unescaped C<'> could confuse some browsers in a
+Refresh header.
+
+=item *
+
+cgi-bin/admin/admin.pl now refreshes to the menu with an error message
+rather than causing a 500 error if it cannot find the article
+specified by C<id>. (#424)
+
+=item *
+
+saving a disabled user from the member admin page will no longer send
+the user a confirmation message if they are unconfirmed and have
+subscriptions selected. (#393)
+
+=item *
+
+a change not listed for 0.14_05 - the delivery instructions entered
+during checkout are now included on the encrypted order emailed to the
+site admin. (#354)
+
+=item *
+
+the validation error icon image can now be configured, see [error_img]
+in config.pod. (#230)
+
+=back
+
 =head2 0.14_33
 
 =over
@@ -22,7 +87,7 @@ user to be displayed.
 
 =item *
 
-affiliate.pl will no longer display pages for disabled users
+affiliate.pl will no longer display pages for disabled users (#437)
 
 =item *
 
index 1e3fef813292bfd220fe89b48f2eaa28846f92f6..21b68111d06a3b461312ffc17c800e5d80a6821f 100644 (file)
@@ -1101,6 +1101,25 @@ read alphabetically as above.
 
 =back
 
+=head2 [error_img]
+
+This is used to configure the error icon displayed next to fields that
+fail validation.
+
+=over
+
+=item image
+
+URI to the image file.
+
+=item width
+
+=item height
+
+The width and height of the error icon image.
+
+=back
+
 =head1 AUTHOR
 
 Tony Cook <tony@develop-help.com>
index 0b0f099419fc51ba81a4ebedaf9fb47d990e4348..9cf7d9ab373381a16bd3d8be6136998bca350e81 100644 (file)
@@ -33,6 +33,8 @@
         <b>Date:&nbsp;&nbsp;</b></font> 
         <select name="d">
           <option value="ar" <:dateSelected ar:>>All Current</option>
+          <option value="m7" <:dateSelected m7:>>Modified within last 7 days</option>
+          <option value="m30" <:dateSelected m30:>>Modified within last 30 days</option>
           <option value="r1" <:dateSelected r1:>>Released Today</option>
           <option value="r7" <:dateSelected r7:>>Released within last 7 days</option>
           <option value="e7" <:dateSelected e7:>>Archived within last 7 days</option>
index dca6fd68a02016c25538dc3b1ae5fae20c3b03a7..ef1d34df8ccbd5eb96daceb5a0af80c512b65147 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 use strict;
 use BSE::Test ();
-use Test::More tests=>49;
+use Test::More tests=>52;
 use File::Spec;
 use FindBin;
 my $cgidir = File::Spec->catdir(BSE::Test::base_dir, 'cgi-bin');
@@ -167,6 +167,16 @@ ABc123 xyz
 Alpha Beta Gamma
 EXPECTED
 
+template_test "arithmetic", $top, <<'TEMPLATE', <<EXPECTED;
+<:arithmetic 2+2:>
+<:arithmetic 2+[add 1 1]:>
+<:arithmetic 2+[add 1 2]+[undefinedtag x]+[add 1 1]+[undefinedtag2]:>
+TEMPLATE
+4
+4
+<:arithmetic 2+3+[undefinedtag x]+2+[undefinedtag2]:>
+EXPECTED
+
 BSE::Admin::StepParents->del($parent, $parent);
 for my $kid (reverse @kids) {
   my $name = $kid->{title};
diff --git a/test-imager.cfg b/test-imager.cfg
new file mode 100644 (file)
index 0000000..c13835f
--- /dev/null
@@ -0,0 +1,20 @@
+# where to install the site
+base_url = http://imager.perl.org
+securl = http://imager.perl.org
+# where to install the site
+base_dir = /var/www/httpd/imager.perl.org
+# the database user/password/dsn
+dbuser = bseimager
+dbpass = bseimager
+dsn = dbi:mysql:bseimager
+dbclass = BSE::DB::Mysql
+sessionclass = Apache::Session::MySQL
+# the location of mysql
+mysql = mysql
+basic.access_control=1
+#basic.htusers = /home/httpd/bsetest/htdocs/images/.htusers
+#paths.libraries=/home/tony/dev/bse/tryandbyte/modules
+#paths.local_templates=/home/tony/dev/bse/tryandbyte/templates
+#tryandbyte.aufreight=500
+shop.to_email=tony@develop-help.com
+site.name=Imager
index 62b89461deba128ff7fbd8ad713927db10cda194..f5ff5a594237d52a43472be3ba2f7255e24160cb 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -91,3 +91,4 @@ affiliate.subscription_required=affiliatepage
 
 editor.allow_thumb=1
 editor.thumbs_class=BSE::Thumb::Imager
+