]> git.imager.perl.org - bse.git/commitdiff
0.14_09 commit r0_14_09
authorTony Cook <tony@develop-help.com>
Thu, 16 Oct 2003 00:18:55 +0000 (00:18 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Thu, 16 Oct 2003 00:18:55 +0000 (00:18 +0000)
Makefile
site/cgi-bin/admin/subs.pl
site/cgi-bin/modules/BSE/SubscriptionType.pm
site/cgi-bin/modules/DevHelp/Formatter.pm
site/cgi-bin/modules/Squirrel/Template.pm
site/docs/bse.pod
site/templates/admin/subs/list.tmpl
site/templates/admin/subs/send_form.tmpl
t/t010template.t
t/t050format.t

index 25fb630c582b448d55c462c684563395df07285e..5b15c9ee9417dbc261da8ff5e582884e048b2b77 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.14_08
+VERSION=0.14_09
 DISTNAME=bse-$(VERSION)
 DISTBUILD=$(DISTNAME)
 DISTTAR=../$(DISTNAME).tar
index e3be2bae284b412e1af86aeb7118c34c1f9e696e..d0ac8e915853f4a213fa63b95959dfb0a23e4fee 100755 (executable)
@@ -52,7 +52,7 @@ else {
   refresh_to($req->url('logon'));
 }
 
-sub tag_recipient_count {
+sub tag_list_recipient_count {
   my ($subs, $subindex) = @_;
 
   $$subindex >= 0 && $$subindex < @$subs
@@ -75,7 +75,7 @@ sub list {
                                    \$subindex),
      BSE::Util::Tags->secure($req),
      message => sub { CGI::escapeHTML($message) },
-     recipient_count => [ \&tag_recipient_count, \@subs, \$subindex ],
+     recipient_count => [ \&tag_list_recipient_count, \@subs, \$subindex ],
     );
   BSE::Template->show_page('admin/subs/list', $cfg, \%acts);
 }
@@ -139,16 +139,27 @@ sub _parent_popup {
   my @all = grep($req->user_can('edit_add_child', $_)
                 || $sub->{parentId} == $_->{id},
                 Articles->all());
-  @all = grep 
+  @all = 
+    grep 
     {
       my $type = ($_->{generator} =~ /(\w+)$/)[0] || 'Article';
 
       $valid_types{$type} && $_->{id} != $shopid
     } @all;
   my %labels = map { $_->{id}, "$_->{title} ($_->{id})" } @all;
+  @all = sort { lc $labels{$a->{id}} cmp lc $labels{$b->{id}} } @all;
   my @extras;
-  if ($sub && !$old) {
-    @extras = ( -default=>$sub->{parentId} );
+  unless ($old) {
+    if ($sub) {
+      @extras = ( -default=>$sub->{parentId} );
+    }
+    else {
+      # use the highest id, presuming the most recent article created
+      # was created to store subscriptions
+      my $max = -1;
+      $max < $_->{id} and $max = $_->{id} for @all;
+      @extras = ( -default=>$max );
+    }
   }
   return CGI::popup_menu(-name=>'parentId',
                         -values=> [ map $_->{id}, @all ],
@@ -362,6 +373,14 @@ sub start_send {
   BSE::Template->show_page('admin/subs/start_send', $cfg, \%acts);
 }
 
+sub tag_recipient_count {
+  my ($sub, $rcount_cache) = @_;
+
+  defined $$rcount_cache or $$rcount_cache = $sub->recipient_count;
+
+  $$rcount_cache;
+}
+
 sub send_form {
   my ($q, $req, $cfg) = @_;
 
@@ -373,6 +392,7 @@ sub send_form {
     or return _refresh_list($q, $cfg, $msgs->(startnoid=>"No id supplied to be edited"));
   my $sub = BSE::SubscriptionTypes->getByPkey($id)
     or return _refresh_list($q, $cfg, $msgs->(startnosub=>"Cannot find record $id"));
+  my $count_cache;
   my %acts;
   %acts =
     (
@@ -384,6 +404,7 @@ sub send_form {
      old => sub { CGI::escapeHTML(defined $sub->{$_[0]} ? $sub->{$_[0]} : '') },
      template => sub { return _template_popup($cfg, $q, $sub, 0, $_[0]) },
      parent=> sub { _parent_popup($req, $sub)  },
+     recipient_count => [ \&tag_recipient_count, $sub, \$count_cache ],
     );
   BSE::Template->show_page('admin/subs/send_form', $cfg, \%acts);
 }
index 30b661ed25244682151c99c9ce91f7012e50ef99..66a49f5868dbf5dbef0f9808ff3ed6795e665dd4 100644 (file)
@@ -208,6 +208,11 @@ sub send {
 
   my @recipients = $sub->recipients;
 
+  unless (@recipients) {
+    $callback->('error', undef, 'This subscription has no recipients, no action taken');
+    return;
+  }
+
   my %article;
   $sub->_send($cfg, $opts, $callback, \@recipients, \%article);
 
index d181db9bf091a41dd0f40599a6b53ad2b34c02f0..5751c2e9c827c182eabc36144455ffe708f8d3f3 100644 (file)
@@ -197,7 +197,8 @@ sub format {
          and next TRY;
        $part =~ s#image\[([^\]\[]+)\]# $self->image($1) #ige
            and next TRY;
-       $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#<span class="$1">$2</span>#ig
+       $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#
+         _fix_spanned(qq/<span class="$1">/, "</span>", $2)#eig
           and next TRY;
        last;
       }
index 0946ad75956e86abd888332f1ddb011097c1ec9e..637fabb414ea00732d5301a8d1fb7fd5dec328e5 100644 (file)
@@ -274,7 +274,7 @@ sub switch {
   print STDERR "** switch\n" if DEBUG;
 
   my @cases = split /(?=<:\s*case\s)/gs, $content;
-  shift @cases; # drop the loser at the front
+  shift @cases if @cases && $cases[0] !~ /<:\s*case\s/;
   my $case;
   while ($case = shift @cases) {
     my ($cond, $data) = $case =~ /<:\s*case\s+(.*?):>(.*)/s;
index 39d3a0ab81996ec50432d6308876c4a0cf14f54f..dc19f56aa38eeebc0927640567b4920d67aeba5b 100644 (file)
@@ -10,6 +10,44 @@ Maybe I'll add some other bits here.
 
 =head1 CHANGES
 
+=head2 0.14_09
+
+=over
+
+=item *
+
+the <:switch:> template construct had required there be some text
+between "<:switch:>" and the first case, this is no longer necessary.
+You still might want to keep a newline there to make it easier to pick
+out cases
+
+=item *
+
+the list of possible archive parents for subscriptions is now sorted
+by title (#295) We now select the highest id article by default when
+creating a new subscription, presuming it was created to store an
+archive.
+
+=item *
+
+the <:recipient_count:> tag is now available on the subscription send
+form, and the Send link is now always available on the subscriptions
+list. (#269)
+
+=item *
+
+the subscription send action, if it somehow is submitted with no users
+subcribed, will no longer archive an article and update the most
+recent send date.  This can happen if the last user unsubscribes while
+the administrator is composing their newsletter.
+
+=item *
+
+the class[] body text tag now nests correctly when spanning over
+paragraphs
+
+=back
+
 =head2 0.14_08
 
 =over
index 99fb43ec9496d9cfba2d6e3be55ab125ce3d5dee..44aadc9c3c8d52fefb09053a194817d309d29362 100644 (file)
@@ -1,20 +1,10 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-
-  <title>Administration - Subscriptions Manager</title>
-
-  <link rel="stylesheet" type="text/css" href="/css/admin.css" />
-
-</head>
-
-<body>
-
+<:wrap admin/xbase.tmpl title=>"Subscriptions List":>
 <h1>Subscriptions List</h1>
 
 <:ifMessage:><p><b><:message:></b></p><:or:><:eif:>
 
-<p>| <a href="/cgi-bin/admin/menu.pl">Admin menu</a> |</p>
+<p>| <a href="/cgi-bin/admin/menu.pl">Admin menu</a> |<:ifUserCan subs_add:>
+<a href="<:script:>?add=1">Add Subscription</a> |<:or:><:eif:></p>
 
 <table border="0" cellspacing="0" cellpadding="0" bgcolor="#000000" class="table">
     <tr>
@@ -40,7 +30,7 @@
       <td align="center"><:recipient_count:></td>
           <td nowrap> <:ifUserCan subs_edit:><a href="<:script:>?edit=1&id=<:subscription id:>"><b>Edit</b></a> <:or:><:eif:>
             <:ifUserCan subs_delete:><a href="<:script:>?delconfirm=1&id=<:subscription id:>"><b>Delete</b></a>  <:or:><:eif:>
-            <:ifAnd [ifUserCan subs_send] [recipient_count]:><a href="<:script:>?start_send=1&id=<:subscription id:>"><b>Send</b></a>  <:or:><:eif:>
+            <:ifUserCan subs_send:><a href="<:script:>?start_send=1&id=<:subscription id:>"><b>Send</b></a><:or:><:eif:>
           </td>
     </tr>
 <:iterator end subscriptions:>
 </td>
 </tr>
 </table>
-<:ifUserCan subs_add:>
-<form name="form1" method="post" action="<:script:>">
-  <p><input type="submit" name="add" value="Add Subscription">
-  </p>
-</form><:or:><:eif:>
-<p><font size="-1">BSE Release <:release:></font></p>
-</body>
-</html>
index e96f45fe16c47821dec1196536b98af9ca3bec25..f7549abb3c5e2c4cf74eea71a55fb65992075dfc 100644 (file)
 </tr>
 </table>
 <p>
-    <input type="submit" name="send" value="Send Subscription">
-    <:help subssend send:> 
+    <:ifRecipient_count:><input type="submit" name="send" value="Send Subscription">
+    <:help subssend send:> <:or:><:eif:>
     <:ifCfg subscriptions testing 1:> <input type="submit" name="send_test" value="Send Test">
     <:help subssend sendtest:> <:or:><:eif:>
     <input type="submit" name="html_preview" value="HTML Preview">
index c8a0ddf596ca07d3b495690b4faa33172e07610e..4ae7d9602b55ea6ec2b957b78853c9a322a60dd4 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 # Basic tests for Squirrel::Template
 use strict;
-use Test::More tests => 16;
+use Test::More tests => 17;
 
 sub template_test($$$$;$);
 
@@ -57,6 +57,13 @@ IN
   $str = "DEF";
   template_test($switch, "DEF", "switch def", \%acts, "both");
 
+  my $switch2 = <<IN;
+<:switch:><:case Eq [strref] "ABC":>ONE<:case Eq [strref] "XYZ":>TWO<:
+case default:>DEF<:endswitch:>
+IN
+  $str = "ABC";
+  template_test($switch2, "ONE", "switch without ignored", \%acts, "both");
+
   template_test("<:with begin upper:>Alpha<:with end upper:>", "ALPHA", "with", \%acts);
   template_test("<:include doesnt/exist optional:>", "", "optional include", \%acts);
   template_test("<:include doesnt/exist:>", "** cannot find include doesnt/exist in path **", "failed include", \%acts);
index 497477b5782c38c422a7292dcfd1d07acae18e53..b577fed933c5d17fd30851064d5cc86bd0107294 100644 (file)
@@ -1,13 +1,13 @@
 #!perl -w
 use strict;
-use Test::More tests => 37;
+use Test::More tests => 38;
 
 sub format_test($$$;$);
 
 my $gotmodule = require_ok('DevHelp::Formatter');
 
 SKIP: {
-  skip "couldn't load module", 35 unless $gotmodule;
+  skip "couldn't load module", 37 unless $gotmodule;
 
   format_test <<IN, <<OUT, 'bold', 'both';
 b[hello]
@@ -139,6 +139,10 @@ OUT
   format_test 'image[foo]', '', 'image';
 
   format_test 'class[xxx|yyy]', '<span class="xxx">yyy</span>', 'class';
+  format_test "class[xxx|yy\n\nzz]", <<EOS, 'class2', 'out';
+<span class="xxx">yy</span></p>
+<p><span class="xxx">zz</span>
+EOS
 }
 
 sub format_test ($$$;$) {