-VERSION=0.12_21
+VERSION=0.12_22
DISTNAME=bse-$(VERSION)
DISTBUILD=$(DISTNAME)
DISTTAR=../$(DISTNAME).tar
Installation documentation can be found in INSTALL.* and plenty of
other documentation can be found in site/docs/
+LICENSE
+=======
+
BSE is distributed under your choice of either the Artistic or GNU
Public License, just as Perl is.
+HELP
+====
+
+Try the bse-users mailing list for volunteer help:
+
+ http://lists.develop-help.com/mailman/listinfo/bse-users
+
+Please keep discussion on the mailing list, private emails are likely
+to result in quotes of hourly rates.
+
+If you want to be notifed about each release of BSE, subscribe to the
+bse-announce mailing list:
+
+ http://lists.develop-help.com/mailman/listinfo/bse-announce
+
+Only announcements are sent to this list, though it's possible
+spammers will figure out how to bypass its protection, in which case
+I'll make it tougher to do so.
+
Tony Cook <tony@develop-help.com>
$conf{site}{secureurl} = BSE::Test::base_securl();
my $uploads = "$instbase/uploads";
$conf{paths}{downloads} = $uploads;
+my $templates = "$instbase/templates";
+$conf{paths}{templates} = $templates;
open TESTCONF, "< $conffile"
or die "Could not open config file $conffile: $!";
while (<TESTCONF>) {
use Order;
use OrderItems;
use OrderItem;
-use Constants qw($TMPLDIR);
-use Squirrel::Template;
+use BSE::Template;
#use Squirrel::ImageEditor;
use Constants qw(:shop $SHOPID $PRODUCTPARENT
$SHOP_URI $CGI_URI $IMAGES_URI $AUTO_GENERATE);
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 %acts;
%acts =
(
sub {
$req->user_can(edit_reorder_children => $catalog)
or return '';
+ @list > 1 or return '';
# links to move products up/down
my $html = '';
my $refreshto = CGI::escape($ENV{SCRIPT_NAME}."#cat".$catalog->{id});
HTML
}
}
+ else {
+ $html .= $blank;
+ }
if ($list_index > 0) {
if ($session->{showstepkids}) {
$html .= <<HTML;
HTML
}
}
+ else {
+ $html .= $blank;
+ }
return $html;
},
script=>sub { $ENV{SCRIPT_NAME} },
sub {
$req->user_can(edit_reorder_children => $catalog)
or return '';
+ @subcats > 1 or return '';
# links to move catalogs up/down
my $html = '';
my $refreshto = CGI::escape($ENV{SCRIPT_NAME});
<a href="$CGI_URI/admin/move.pl?id=$subcats[$subcat_index]{id}&d=swap&other=$subcats[$subcat_index+1]{id}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($subcat_index > 0) {
$html .= <<HTML;
<a href="$CGI_URI/admin/move.pl?id=$subcats[$subcat_index]{id}&d=swap&other=$subcats[$subcat_index-1]{id}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
},
);
- my $tmplt = Squirrel::Template->new;
- return $tmplt->show_page($TMPLDIR, 'admin/'.$template, \%acts);
+ return BSE::Template->get_page('admin/'.$template, $cfg, \%acts);
}
sub product_list {
$session->{showstepkids} = $cgi->param('showstepkids');
}
exists $session->{showstepkids} or $session->{showstepkids} = 1;
+
+ my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+
my %acts;
%acts =
(
sub {
$req->user_can(edit_reorder_children => $shopid)
or return '';
+ @catalogs > 1 or return '';
# links to move catalogs up/down
my $html = '';
my $refreshto = CGI::escape($ENV{SCRIPT_NAME});
<a href="$CGI_URI/admin/move.pl?id=$catalogs[$catalog_index]{id}&d=swap&other=$catalogs[$catalog_index+1]{id}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($catalog_index > 0) {
$html .= <<HTML;
<a href="$CGI_URI/admin/move.pl?id=$catalogs[$catalog_index]{id}&d=swap&other=$catalogs[$catalog_index-1]{id}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
},
ifShowStepKids => sub { $session->{showstepkids} },
my @templates;
push(@templates, "shopitem.tmpl")
- if -e "$TMPLDIR/shopitem.tmpl";
- if (opendir PROD_TEMPL, "$TMPLDIR/products") {
- push @templates, map "products/$_",
- grep -f "$TMPLDIR/products/$_" && /\.tmpl$/i, readdir PROD_TEMPL;
- closedir PROD_TEMPL;
+ if grep -e "$_/shopitem.tmpl", BSE::Template->template_dirs($cfg);
+ for my $dir (BSE::Template->template_dirs($cfg)) {
+ if (opendir PROD_TEMPL, "$dir/products") {
+ push @templates, map "products/$_",
+ grep -f "$dir/products/$_" && /\.tmpl$/i, readdir PROD_TEMPL;
+ closedir PROD_TEMPL;
+ }
}
+ my %seen_templates;
+ @templates = sort { lc($a) cmp lc($b) }
+ grep !$seen_templates{$_}++, @templates;
+
my $stepcat_index;
use OtherParents;
# ugh
# 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 %acts;
%acts =
(
my $html = '';
my $refreshto = CGI::escape($ENV{SCRIPT_NAME}
."?id=$product->{id}&$template=1#step");
+ @stepcats > 1 or return '';
if ($stepcat_index < $#stepcats) {
$html .= <<HTML;
<a href="$CGI_URI/admin/move.pl?stepchild=$product->{id}&id=$stepcats[$stepcat_index]{parentId}&d=swap&other=$stepcats[$stepcat_index+1]{parentId}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($stepcat_index > 0) {
$html .= <<HTML;
<a href="$CGI_URI/admin/move.pl?stepchild=$product->{id}&id=$stepcats[$stepcat_index]{parentId}&d=swap&other=$stepcats[$stepcat_index-1]{parentId}&refreshto=$refreshto&all=1"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
},
ifStepcatPossibles => sub { @stepcat_possibles },
sub page {
my ($which, $acts, $iter) = @_;
- my $templ = Squirrel::Template->new;
-
- print "Content-Type: text/html\n\n";
- print $templ->show_page($TMPLDIR, 'admin/' . $which . ".tmpl", $acts, $iter);
+ BSE::Template->show_page('admin/'.$which, $cfg, $acts);
}
sub shop_url {
use BSE::DB;
use BSE::Util::Tags;
use BSE::Template;
-use Constants qw($TMPLDIR);
use Articles;
use Util qw/refresh_to/;
use BSE::Message;
$base = $cfg->entry('subscriptions', "${type}_templates")
|| $type;
}
- if (opendir TEMPL, "$TMPLDIR/$base") {
- push(@templates, sort map "$base/$_",
- grep -f "$TMPLDIR/$base/$_" && /\.tmpl$/i, readdir TEMPL);
- closedir TEMPL;
- @templates or push(@templates, "Could not find templates in $base");
- }
- else {
- push(@templates, "Cannot open dir $TMPLDIR/$base");
+ for my $dir (BSE::Template->template_dirs($cfg)) {
+ if (opendir TEMPL, "$dir/$base") {
+ push(@templates, sort map "$base/$_",
+ grep -f "$dir/$base/$_" && /\.tmpl$/i, readdir TEMPL);
+ closedir TEMPL;
+ }
}
+ my %seen_templates;
+ @templates = sort grep !$seen_templates{$_}, @templates;
+ @templates or push(@templates, "Could not find templates in $base");
my $def = $old ? $q->param($name) :
$sub ? $sub->{$name} : $templates[0];
my %labels;
if ($value =~ /\.\./) {
push(@$errors, [ $field, "Template $value is invalid, contains .." ]);
}
- elsif (!-f "$TMPLDIR/$value") {
+ elsif (!BSE::Template->find_source($value, $cfg)) {
push(@$errors, [ $field, "Template $value does not exist" ]);
}
}
ifError => sub { 0 },
old => sub { CGI::escapeHTML(defined $sub->{$_[0]} ? $sub->{$_[0]} : '') },
template => sub { return _template_popup($cfg, $q, $sub, 0, $_[0]) },
- parent=> sub { _parent_popup($sub, {}) },
+ parent=> sub { _parent_popup($sub) },
);
BSE::Template->show_page('admin/subs/send_form', $cfg, \%acts);
}
}
}
-# sub _text_format {
-# my ($cfg, $article, $user, $template) = @_;
-
-# my %acts;
-# %acts =
-# (
-# article=>sub { $article->{$_[0]} },
-# ifUser => sub { $user },
-# user =>
-# sub {
-# $user or return '';
-# defined $user->{$_[0]} or return '';
-# $user->{$_[0]}
-# },
-# body =>
-# sub {
-# _format_body($cfg, $article->{body});
-# },
-# );
-# my $base = $cfg->entry('paths', 'templates')
-# || $TMPLDIR;
-# my $obj = Squirrel::Template->new(template_dir=>$base);
-# return $obj->show_page($base, $template, \%acts);
-# }
-
sub _dummy_user {
my %user;
$user{id} = 0;
sub all_visible_kids {
my ($self) = @_;
- require 'OtherParents.pm';
-
- my @otherlinks = OtherParents->getBy(parentId=>$self->{id});
- my @normalkids = Articles->listedChildren($self->{id});
- my %order = (
- (map { $_->{id}, $_->{displayOrder} } @normalkids ),
- (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
- );
- my @stepkids = $self->visible_stepkids;
- my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
-
- return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };
+ Articles->all_visible_kids($self->{id});
}
sub images {
}
}
+sub visible_stepkids {
+ my ($self, $id) = @_;
+
+ use BSE::Util::SQL qw/now_sqldate/;
+ my $today = now_sqldate();
+
+ return Articles->getSpecial('visibleStepKids', $id, $today);
+}
+
+sub all_visible_kids {
+ my ($self, $id) = @_;
+
+ require 'OtherParents.pm';
+
+ my @otherlinks = OtherParents->getBy(parentId=>$id);
+ my @normalkids = Articles->listedChildren($id);
+ my %order = (
+ (map { $_->{id}, $_->{displayOrder} } @normalkids ),
+ (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
+ );
+ my @stepkids = $self->visible_stepkids($id);
+ my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
+
+ return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };
+}
+
+
1;
my @dirs = $self->template_dirs($article);
my @templates;
- my $basedir = $self->{cfg}->entry('paths', 'templates', $Constants::TMPLDIR);
+ my $basedir = $self->{cfg}->entryVar('paths', 'templates');
for my $dir (@dirs) {
my $path = File::Spec->catdir($basedir, $dir);
if (-d $path) {
sub extra_templates {
my ($self, $article) = @_;
- my $basedir = $self->{cfg}->entry('paths', 'templates', $Constants::TMPLDIR);
+ my $basedir = $self->{cfg}->entryVar('paths', 'templates');
my @templates;
if (my $id = $article->{id}) {
push @templates, 'index.tmpl'
$req->user_can(edit_reorder_children => $article)
or return '';
+ @$allkids > 1 or return '';
+
my $cgi_uri = $self->{cfg}->entry('uri', 'cgi', '/cgi-bin');
my $images_uri = $self->{cfg}->entry('uri', 'images', '/images');
my $html = '';
}
$url .= "#step";
my $refreshto = CGI::escape($url);
+ my $blank = qq!<img src="$images_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
if ($$rallkids_index < $#$allkids) {
$html .= <<HTML;
<a href="$cgi_uri/admin/move.pl?stepparent=$article->{id}&d=swap&id=$allkids->[$$rallkids_index]{id}&other=$allkids->[$$rallkids_index+1]{id}&refreshto=$refreshto"><img src="$images_uri/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($$rallkids_index > 0) {
$html .= <<HTML;
<a href="$cgi_uri/admin/move.pl?stepparent=$article->{id}&d=swap&id=$allkids->[$$rallkids_index]{id}&other=$allkids->[$$rallkids_index-1]{id}&refreshto=$refreshto"><img src="$images_uri/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
}
$req->user_can(edit_reorder_stepparents => $article)
or return '';
+ @$stepparents > 1 or return '';
+
my $cgi_uri = $self->{cfg}->entry('uri', 'cgi', '/cgi-bin');
my $images_uri = $self->{cfg}->entry('uri', 'images', '/images');
my $html = '';
$url .= "&_t=".$cgi->param('_t');
}
$url .= "#stepparents";
+ my $blank = qq!<img src="$images_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
my $refreshto = CGI::escape($url);
if ($$rindex < $#$stepparents) {
$html .= <<HTML;
<a href="$cgi_uri/admin/move.pl?stepchild=$article->{id}&id=$stepparents->[$$rindex]{parentId}&d=swap&other=$stepparents->[$$rindex+1]{parentId}&refreshto=$refreshto&all=1"><img src="$images_uri/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($$rindex > 0) {
$html .= <<HTML;
<a href="$cgi_uri/admin/move.pl?stepchild=$article->{id}&id=$stepparents->[$$rindex]{parentId}&d=swap&other=$stepparents->[$$rindex-1]{parentId}&refreshto=$refreshto&all=1"><img src="$images_uri/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
}
$req->user_can('edit_reorder_children', $article)
or return '';
+ @$kids > 1 or return '';
+
$$rindex >=0 && $$rindex < @$kids
or return '** movechild can only be used in the children iterator **';
$req->user_can(edit_images_reorder => $article)
or return '';
+ @$images > 1 or return '';
+
$$rindex >= 0 && $$rindex < @$images
or return '** imgmove can only be used in image iterator **';
$req->user_can('edit_files_reorder', $article)
or return '';
+ @$files > 1 or return '';
+
my $html = '';
$$rindex >= 0 && $$rindex < @$files
use base 'BSE::Edit::Article';
use Products;
use HTML::Entities;
+use BSE::Template;
my %money_fields =
(
my ($self, $article) = @_;
my @extras = $self->SUPER::extra_templates($article);
- my $basedir = $self->{cfg}->entry('paths', 'templates', $Constants::TMPLDIR);
- push @extras, 'shopitem.tmpl' if -f "$basedir/shopitem.tmpl";
+ push @extras, 'shopitem.tmpl'
+ if grep -f "$_/shopitem.tmpl",
+ BSE::Template->template_dirs($self->{cfg});
return @extras;
}
my @files = $self->_getfiles($article);
+ my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+
my $message = $self->{cgi}->param('message') || '';
my $file_index;
my %acts;
move =>
sub {
my $html = '';
+ @files > 1 or return '';
if ($file_index > 0) {
$html .= <<HTML;
<a href="$ENV{SCRIPT_NAME}?fileswap=1&id=$article->{id}&file1=$files[$file_index]{id}&file2=$files[$file_index-1]{id}"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($file_index < $#files) {
$html .= <<HTML;
<a href="$ENV{SCRIPT_NAME}?fileswap=1&id=$article->{id}&file1=$files[$file_index]{id}&file2=$files[$file_index+1]{id}"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
$html;
},
);
},
sub => sub { $sub->{$_[0]} },
);
- my $base = $cfg->entry('paths', 'templates')
- || $Constants::TMPLDIR;
- my $obj = Squirrel::Template->new(template_dir=>$base);
- return $obj->show_page($base, $template, \%acts);
+
+ return BSE::Template->get_page($template, $cfg, \%acts);
}
sub text_format {
package BSE::Template;
use strict;
-use Constants qw/$TMPLDIR/;
use Squirrel::Template;
+use Carp 'confess';
sub get_page {
my ($class, $template, $cfg, $acts) = @_;
- my $base = $cfg->entry('paths', 'templates')
- || $TMPLDIR;
- my $file = $cfg->entry('templates', $template) || "$template.tmpl";
+ my @dirs = $class->template_dirs($cfg);
+ my $file = $cfg->entry('templates', $template) || $template;
+ $file =~ /\.\w+$/ or $file .= ".tmpl";
- my $obj = Squirrel::Template->new(template_dir => $base);
+ my $obj = Squirrel::Template->new(template_dir => \@dirs);
- $obj->show_page($base, $file, $acts);
+ $obj->show_page(undef, $file, $acts);
+}
+
+sub replace {
+ my ($class, $source, $cfg, $acts) = @_;
+
+ my @dirs = $class->template_dirs($cfg);
+ my $obj = Squirrel::Template->new(template_dir => \@dirs);
+
+ $obj->replace_template($source, $acts);
}
sub html_type {
sub show_page {
my ($class, $template, $cfg, $acts) = @_;
+ $class->show_literal($class->get_page($template, $cfg, $acts), $cfg);
+}
+
+sub show_replaced {
+ my ($class, $source, $cfg, $acts) = @_;
+
+ $class->show_literal($class->replace($source, $cfg, $acts), $cfg);
+}
+
+sub show_literal {
+ my ($class, $text, $cfg) = @_;
+
my $type = $class->html_type($cfg);
print "Content-Type: $type\n\n";
- print $class->get_page($template, $cfg, $acts);
+ print $text;
}
sub get_response {
};
}
+sub template_dirs {
+ my ($class, $cfg) = @_;
+
+ ref($cfg) eq 'BSE::Cfg'
+ or confess "Invalid cfg supplied\n";
+
+ my $base = $cfg->entryVar('paths', 'templates');
+ my $local = $cfg->entry('paths', 'local_templates');
+ my @dirs = ( $base );
+ unshift @dirs, $local if $local;
+
+ @dirs;
+}
+
+sub find_source {
+ my ($class, $template, $cfg) = @_;
+
+ my @dirs = $class->template_dirs($cfg);
+
+ my $file = $cfg->entry('templates', $template) || $template;
+ $file =~ /\.\w+$/ or $file .= ".tmpl";
+
+ for my $dir (@dirs) {
+ return "$dir/$file" if -f "$dir/$file";
+ }
+
+ return;
+}
+
+sub get_source {
+ my ($class, $template, $cfg) = @_;
+
+ my $path = $class->find_source($template, $cfg)
+ or confess "Cannot find template $template";
+ open SOURCE, "< $path"
+ or confess "Cannot open template $path: $!";
+ binmode SOURCE;
+ my $html = do { local $/; <SOURCE> };
+ close SOURCE;
+
+ $html;
+}
+
1;
my $value = $templater->perform($acts, $func, $args);
defined $value
or return '';
+ $value =~ /\d/
+ or print STDERR "Result '$value' from [$func $args] not a number\n";
sprintf("%.02f", $value/100.0);
},
bodytext =>
use vars qw(@EXPORT_OK %EXPORT_TAGS @ISA $VERSION
$DSN $DBOPTS $DBCLASS $UN $PW $D_00 $D_99 $D_XX
$SESSION_CLASS $SESSION_REQUIRE
-$TMPLDIR $IMAGEDIR $SEP %LEVEL_DEFAULTS $BASEDIR
+$IMAGEDIR $SEP %LEVEL_DEFAULTS $BASEDIR
$MAXPHRASE $CONTENTBASE $SHOPID $PRODUCTPARENT $DATADIR $LINK_TITLES
@SEARCH_EXCLUDE @SEARCH_INCLUDE $SEARCH_LEVEL $SEARCH_ALL
$SEARCH_WILDCARD_MIN $SEARCH_AUTO_WILDCARD $SEARCH_TITLE $SEARCH_TITLE_IMAGE
-%TEMPLATE_OPTS @NO_DELETE
+@NO_DELETE
$SHOP_MAIL_SUBJECT $SHOP_PASSPHRASE $SHOP_CRYPTO $SHOP_SIGNING_ID
$SHOP_GPG $SHOP_PGP $SHOP_FROM $SHOP_TO_NAME $SHOP_TO_EMAIL
$SHOP_PGPE $SHOP_EMAIL_ORDER %SHOP_PRODUCT_OPTS
require Exporter;
@ISA = qw/Exporter/;
-@EXPORT_OK = qw/$DSN $DBOPTS $DBCLASS $UN $PW $D_00 $D_99 $D_XX $TMPLDIR $SEP
+@EXPORT_OK = qw/$DSN $DBOPTS $DBCLASS $UN $PW $D_00 $D_99 $D_XX $SEP
$SESSION_CLASS $SESSION_REQUIRE
$IMAGEDIR %LEVEL_DEFAULTS $BASEDIR $MAXPHRASE
$CONTENTBASE $SHOPID $PRODUCTPARENT $DATADIR $LINK_TITLES
@SEARCH_EXCLUDE @SEARCH_INCLUDE $SEARCH_LEVEL $SEARCH_ALL
$SEARCH_WILDCARD_MIN $SEARCH_AUTO_WILDCARD $SEARCH_TITLE $SEARCH_TITLE_IMAGE
-%TEMPLATE_OPTS @NO_DELETE
+@NO_DELETE
$SHOP_MAIL_SUBJECT $SHOP_PASSPHRASE $SHOP_CRYPTO
$SHOP_SIGNING_ID $SHOP_GPG $SHOP_PGP $SHOP_FROM %SHOP_PRODUCT_OPTS
$SHOP_TO_NAME $SHOP_TO_EMAIL $SHOP_EMAIL_ORDER $SHOP_PGPE
$SHOP_SIGNING_ID $SHOP_GPG $SHOP_PGP $SHOP_FROM
$SHOP_TO_NAME $SHOP_TO_EMAIL $SHOP_PGPE
$SHOP_EMAIL_ORDER $SHOP_URI %SHOP_PRODUCT_OPTS/ ],
- edit=> [ qw/$TMPLDIR $IMAGEDIR $D_00 $D_99 @NO_DELETE
+ edit=> [ qw/$IMAGEDIR $D_00 $D_99 @NO_DELETE
$ARTICLE_URI $CGI_URI $SHOP_URI $ROOT_URI
$AUTO_GENERATE $REPARENT_UPDOWN/ ],
- search => [ qw/$TMPLDIR @SEARCH_EXCLUDE @SEARCH_INCLUDE $SEARCH_ALL
+ search => [ qw/@SEARCH_EXCLUDE @SEARCH_INCLUDE $SEARCH_ALL
$SEARCH_WILDCARD_MIN $SEARCH_AUTO_WILDCARD/ ],
session => [ qw/$SESSION_CLASS $SESSION_REQUIRE/ ],
#email => [ qw/$SMTP_SERVER $SMTP_HELO $SHOP_SENDMAIL/ ],
#$BASEDIR = 'c:/your_site';
# where we keep templates
-$TMPLDIR = $BASEDIR.'/templates/';
+# $TMPLDIR = $BASEDIR.'/templates/';
# where the html is kept
$CONTENTBASE = $BASEDIR.'/htdocs/';
use POSIX qw/strftime/;
$D_XX = sub { strftime "%Y-%m-%d %H:%M:%S" => (localtime)[0..5] };
-%TEMPLATE_OPTS = ( template_dir => $TMPLDIR );
+# %TEMPLATE_OPTS = ( template_dir => $TMPLDIR );
1;
use strict;
use Articles;
use CGI ();
-use Constants qw($IMAGEDIR $LOCAL_FORMAT $TMPLDIR $BODY_EMBED
+use Constants qw($IMAGEDIR $LOCAL_FORMAT $BODY_EMBED
$EMBED_MAX_DEPTH $HAVE_HTML_PARSER);
use BSE::Custom;
use DevHelp::Tags;
$text = qq!<img src="/images/$im->{image}" width="$im->{width}"!
. qq! height="$im->{height}" alt="! . CGI::escapeHTML($im->{alt}).'"'
. qq! border="0"!;
- $text .= qq! align="$align"! if $align;
+ $text .= qq! align="$align"! if $align && $align ne 'center';
$text .= qq! />!;
+ $text = qq!<div align="center">$text</div>!
+ if $align && $align eq 'center';
if (!$url && $im->{url}) {
$url = $im->{url};
}
and next TRY;
$part =~ s#i\[([^\]\[]+)\]#<i>$1</i>#ig
and next TRY;
+ $part =~ s#tt\[([^\]\[]+)\]#<tt>$1</tt>#ig
+ and next TRY;
+ $part =~ s#pre\[([^\]\[]+)\]#<pre>$1</pre>#ig
+ and next TRY;
+ $part =~ s#h([1-6])\[\|([^\[\]]+)\](?:\r?\n)?#<h$1>$2</h$1>#ig
+ and next TRY;
+ $part =~ s#h([1-6])\[([^\[\]\|]+)\|([^\[\]]+)\](?:\r?\n)?#<h$1 class="$2">$3</h$1>#ig
+ and next TRY;
$part =~ s#align\[([^|\]\[]+)\|([^\]\[]+)\]#<div align="$1">$2</div>#ig
and next TRY;
$part =~ s#font\[([^|\]\[]+)\|([^\]\[]+)\]#<font size="$1">$2</font>#ig
and next TRY;
$part =~ s#image\[([^\]\[]+)\]#($auto_images = 0), _make_img($1, \$imagePos, \@images)#ige
and next TRY;
+ $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#<span class="$1">$2</span>#ig
+ and next TRY;
+
last;
}
- $part =~ s/\n([ \r]*\n)+/<p>/g;
+ $part =~ s!\n([ \r]*\n)+!</p><p>!g;
$part =~ s/\n/<br \/>/g;
$out .= $part;
}
unless defined($template) && $template =~ /\S/;
}
- open SOURCE, "< $TMPLDIR$template"
- or die "Cannot open template $template: $!";
- my $html = do { local $/; <SOURCE> };
- close SOURCE;
+ my $html = BSE::Template->get_source($template, $self->{cfg});
# the template will hopefully contain <:embed start:> and <:embed end:>
# tags
map Articles->listedChildren($_), @ids;
}
+sub iter_all_kids_of {
+ my ($args, $acts, $name, $templater) = @_;
+
+ my @ids = split ' ', $args;
+ for my $id (@ids) {
+ unless ($id =~ /^\d+$|^-1$/) {
+ $id = $templater->perform($acts, $id, "id");
+ }
+ }
+ @ids = grep /^\d+$|^-1$/, @ids;
+ map Articles->all_visible_kids($_), @ids;
+}
+
sub iter_inlines {
my ($args, $acts, $name, $templater) = @_;
DevHelp::Tags->make_iterator2
( \&iter_kids_of, 'ofchild', 'children_of' ),
DevHelp::Tags->make_iterator2
+ ( \&iter_all_kids_of, 'ofallkid', 'allkids_of' ),
+ DevHelp::Tags->make_iterator2
( \&iter_inlines, 'inline', 'inlines' ),
);
}
package Generate::Article;
use strict;
-use Squirrel::Template;
-use Constants qw($TMPLDIR %TEMPLATE_OPTS %LEVEL_DEFAULTS
- $CGI_URI $ADMIN_URI $IMAGES_URI $UNLISTED_LEVEL1_IN_CRUMBS);
+use BSE::Template;
+use Constants qw(%LEVEL_DEFAULTS $CGI_URI $ADMIN_URI $IMAGES_URI
+ $UNLISTED_LEVEL1_IN_CRUMBS);
use Images;
use vars qw(@ISA);
use Generate;
my %acts;
%acts = $self -> baseActs($articles, \%acts, $article, $embedded);
-
- return Squirrel::Template->new(%TEMPLATE_OPTS)
- ->replace_template($template, \%acts);
+ return BSE::Template->replace($template, $self->{cfg}, \%acts);
}
sub baseActs {
my @files = sort { $b->{displayOrder} <=> $a->{displayOrder} }
ArticleFiles->getBy(articleId=>$article->{id});
+ my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
+
my @stepkids;
my @allkids;
my @stepparents;
# for rearranging order in admin mode
moveDown=>
sub {
+ @children > 1 or return '';
if ($self->{admin} && $child_index < $#children) {
return <<HTML;
<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&d=down"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
} else {
- return '';
+ return $blank;
}
},
moveUp=>
sub {
+ @children > 1 or return '';
if ($self->{admin} && $child_index > 0) {
return <<HTML;
<a href="$CGI_URI/admin/move.pl?id=$children[$child_index]{id}&d=up"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
} else {
- return '';
+ return $blank;
}
},
movestepkid =>
sub {
my $html = '';
return '' unless $self->{admin};
+ return '' unless @allkids > 1;
my $refreshto = CGI::escape($ENV{SCRIPT_NAME}
."?id=$article->{id}");
if ($allkids_index < $#allkids) {
<a href="$CGI_URI/admin/move.pl?stepparent=$article->{id}&d=swap&id=$allkids[$allkids_index]{id}&other=$allkids[$allkids_index+1]{id}&refreshto=$refreshto"><img src="$IMAGES_URI/admin/move_down.gif" width="17" height="13" border="0" alt="Move Down" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
if ($allkids_index > 0) {
$html .= <<HTML
<a href="$CGI_URI/admin/move.pl?stepparent=$article->{id}&d=swap&id=$allkids[$allkids_index]{id}&other=$allkids[$allkids_index-1]{id}&refreshto=$refreshto"><img src="$IMAGES_URI/admin/move_up.gif" width="17" height="13" border="0" alt="Move Up" align="absbottom"></a>
HTML
}
+ else {
+ $html .= $blank;
+ }
return $html;
},
ifCurrentPage=>
sub generate {
my ($self, $article, $articles) = @_;
- open SOURCE, "< $TMPLDIR$article->{template}"
- or die "Cannot open template $article->{template}: $!";
- my $html = do { local $/; <SOURCE> };
- close SOURCE;
-
+ my $html = BSE::Template->get_source($article->{template}, $self->{cfg});
$html =~ s/<:\s*embed\s+(?:start|end)\s*:>//g;
return $self->generate_low($html, $article, $articles, 0);
use Generate;
use Products;
use base 'Generate::Article';
-use Squirrel::Template;
-use Constants qw($TMPLDIR %TEMPLATE_OPTS $CGI_URI $IMAGES_URI
- $ADMIN_URI);
+use BSE::Template;
+use Constants qw($CGI_URI $IMAGES_URI $ADMIN_URI);
use Util qw(generate_button);
use OtherParents;
my %acts;
%acts =
(
- $self->baseActs($articles, \%acts, $article, 0),
+ $self->baseActs($articles, \%acts, $article, $embedded),
article => sub { CGI::escapeHTML($article->{$_[0]}) },
iterate_products =>
sub {
return '' unless $self->{request};
return ''
unless $self->{request}->user_can(edit_reorder_children => $article);
+ return '' unless @allprods > 1;
my $html = '';
my $can_move_up = $allprod_index > 0;
my $can_move_down = $allprod_index < $#allprods;
return $value;
};
- return Squirrel::Template->new(%TEMPLATE_OPTS)
- ->replace_template($template, \%acts);
+ return BSE::Template->replace($template, $self->{cfg}, \%acts);
}
sub generate {
my ($self, $article, $articles) = @_;
- open SOURCE, "< $TMPLDIR$article->{template}"
- or die "Cannot open template $article->{template}: $!";
- my $html = do { local $/; <SOURCE> };
- close SOURCE;
+ my $html = BSE::Template->get_source($article->{template}, $self->{cfg});
$html =~ s/<:\s*embed\s+(?:start|end)\s*:>//g;
return $self->generate_low($html, $article, $articles, 0);
}
-sub embed {
- my ($self, $article, $articles, $template) = @_;
-
- $template = $article->{template}
- unless defined($template) && $template =~ /\S/;
-
- open SOURCE, "< $TMPLDIR$template"
- or die "Cannot open template $template: $!";
- my $html = do { local $/; <SOURCE> };
- close SOURCE;
-
- # the template will hopefully contain <:embed start:> and <:embed end:>
- # tags
- # otherwise pull out the body content
- if ($html =~ /<:\s*embed\s*start\s*:>(.*)<:\s*embed\s*end\s*:>/s
- || $html =~ m"<\s*body[^>]*>(.*)<\s*/\s*body>"s) {
- $html = $1;
- }
-
- return $self->generate_low($html, $article, $articles);
-}
-
1;
__END__
use Products;
use Images;
use base qw(Generate::Article);
-use Squirrel::Template;
-use Constants qw(:shop $TMPLDIR %TEMPLATE_OPTS $CGI_URI $ADMIN_URI);
+use Constants qw(:shop $CGI_URI $ADMIN_URI);
use Carp qw(confess);
sub edit_link {
return
(
- $self->SUPER::baseActs($articles, $acts, $product, 0),
+ $self->SUPER::baseActs($articles, $acts, $product, $embedded),
product=> sub { CGI::escapeHTML($product->{$_[0]}) },
admin =>
sub {
use vars qw($VERSION);
use strict;
use Carp qw/cluck confess/;
+use constant DEBUG => 0;
$VERSION="0.05";
sub cond {
my ($self, $name, $args, $true, $false, $acts, $orig) = @_;
+ print STDERR "cond $name $args\n" if DEBUG;
+
my $result =
eval {
if (exists $acts->{"if$name"}) {
+ print STDERR " found cond if$name\n" if DEBUG > 1;
my $cond = $self->low_perform($acts, "if$name", $args, '');
return $cond ? $true : $false;
}
elsif (exists $acts->{lcfirst $name}) {
+ print STDERR " found cond $name\n" if DEBUG > 1;
my $cond = $self->low_perform($acts, lcfirst $name, $args, '');
return $cond ? $true : $false;
}
else {
+ print STDERR " not found\n" if DEBUG > 1;
return $orig;
}
};
return $result;
}
+sub find_template {
+ my ($self, $name) = @_;
+
+ return unless $self->{template_dir};
+
+ my @dirs = ref $self->{template_dir} ? @{$self->{template_dir}} : $self->{template_dir};
+ for my $dir (@dirs) {
+ if (-e "$dir/$name") {
+ return "$dir/$name";
+ }
+ }
+
+ return;
+}
+
+sub include {
+ my ($self, $name) = @_;
+
+ print STDERR "Including $name\n";
+
+ my $filename = $self->find_template($name)
+ or return "** cannot find include $name in path **";
+
+ print STDERR "Found $filename\n";
+
+ open INCLUDE, "< $filename"
+ or return "** cannot open $filename : $! **";
+ my $data = do { local $/; <INCLUDE> };
+ close INCLUDE;
+
+ return $data;
+}
+
sub tag_param {
my ($params, $arg) = @_;
if ($self->{template_dir}) {
my $wrap_count = 0;
while ($template =~ /^(\s*<:\s*wrap\s+(\S+?)(?:\s+(\S.*?))?:>)/i) {
- my $wrapper = "$self->{template_dir}/$2";
- unless (-e $wrapper) {
- print STDERR "WARNING: Unknown wrap name: $wrapper\n";
+ my $name = $2;
+ my $wrapper = $self->find_template($name);
+ unless ($wrapper) {
+ print STDERR "WARNING: Unknown wrap name: $name\n";
last;
}
unless (++$wrap_count < 10) {
}
}
- $acts->{param} = [ \&tag_param, \%params ];
+ $acts->{param} ||= [ \&tag_param, \%params ];
+
+ if ($self->{template_dir} && !$acts->{include}) {
+ my $loops = 0;
+ 1 while $template =~
+ s!<:
+ \s*
+ include
+ \s+
+ ((?:\w+/)*\w+(?:\.\w+)?)
+ \s*
+ :>
+ !
+ $self->include($1)
+ !gex
+ && ++$loops < 10;
+ }
# the basic iterator
if ($iter &&
<:\s*eif\s+\2\s*:>)/
$self->cond($2, $3, $4, $5, $acts, $1) /sgex
&& ++$nesting < 5;
- $template =~ s/(<:\s*if(\w+)(?:\s+(.*?))?\s*:>
+ $template =~ s/(<:\s*if([A-Z]\w*)(?:\s+(.*?))?\s*:>
(.*?)
<:\s*or\s*:>
(.*?)
$acts ||= {};
- my $file = $page ? "$base/$page" : $base;
+ my $file;
+ if ($base) {
+ $file = $page ? "$base/$page" : $base;
+ }
+ else {
+ $file = $self->find_template($page)
+ or die "Cannot find template $page";
+ }
open TMPLT, "< $file"
or die "Cannot open template $file: $!";
my $template = do { local $/; <TMPLT> };
=item template_dir
Used by the wrapper mechanism to find wrapper templates. See
-L<WRAPPING> below.
+L<WRAPPING> below. This can be either a scalar, or a reference to an
+array of locations to search for the wrapper. This is also used for
+the <:include filename:> mechanism.
=back
@ISA = qw(Exporter);
@EXPORT_OK = qw(generate_article generate_all generate_button
refresh_to regen_and_refresh);
-use Constants qw($CONTENTBASE $TMPLDIR %TEMPLATE_OPTS
- $GENERATE_BUTTON $SHOPID $AUTO_GENERATE);
+use Constants qw($CONTENTBASE $GENERATE_BUTTON $SHOPID $AUTO_GENERATE);
+use Carp qw(confess);
my %gen_cache;
# generates search.tmpl from search_base.tmpl
sub generate_search {
- my ($articles) = @_;
+ my ($articles, $cfg) = @_;
+
+ $cfg or confess "Call generate search with a config object";
require 'Generate/Article.pm';
- my $gen = Generate::Article->new;
+ my $gen = Generate::Article->new(cfg=>$cfg);
# build a dummy article
use Constants qw($SEARCH_TITLE $SEARCH_TITLE_IMAGE $CGI_URI);
my %acts;
%acts = $gen->baseActs($articles, \%acts, \%article);
- my $templ = Squirrel::Template->new(%TEMPLATE_OPTS);
- my $content = $templ->show_page($TMPLDIR, 'search_base.tmpl', \%acts);
- my $outname = "$TMPLDIR/search.tmpl.work";
- my $finalname = "$TMPLDIR/search.tmpl";
+ my $content = BSE::Template->get_page('search_base', $cfg, \%acts);
+ my $tmpldir = $cfg->entryVar('paths', 'templates');
+ my $outname = "$tmpldir/search.tmpl.work";
+ my $finalname = "$tmpldir/search.tmpl";
open OUT, "> $outname"
or die "Cannot open $outname for write: $!";
print OUT $content
}
return $value;
};
- my $templ = Squirrel::Template->new(%TEMPLATE_OPTS);
- my $content = $templ->show_page($TMPLDIR, "${name}_base.tmpl", \%acts);
- my $outname = "$TMPLDIR/$name.tmpl.work";
- my $finalname = "$TMPLDIR/$name.tmpl";
+ my $content = BSE::Template->get_page("${name}_base", $cfg, \%acts);
+ my $tmpldir = $cfg->entryVar('paths', 'templates');
+ my $outname = "$tmpldir/$name.tmpl.work";
+ my $finalname = "$tmpldir/$name.tmpl";
open OUT, "> $outname"
or die "Cannot open $outname for write: $!";
print OUT $content
use BSE::Cfg;
$cfg ||= BSE::Cfg->new;
- my $template_dir = $cfg->entry('paths', 'templates') || $TMPLDIR;
+ my $template_dir = $cfg->entryVar('paths', 'templates');
open EXTRAS, "$template_dir/extras.txt"
or return;
}
return $value;
};
- my $templ = Squirrel::Template->new(%TEMPLATE_OPTS,
- template_dir=>$template_dir);
- my $content = $templ->show_page($template_dir, $in, \%acts);
+ my $content = BSE::Template->get_page($in, $cfg, \%acts);
my $outname = $CONTENTBASE . $out . ".work";
my $finalname = $CONTENTBASE . $out;
open OUT, "> $outname"
}
return $value;
};
- my $templ = Squirrel::Template->new(%TEMPLATE_OPTS,
- template_dir=>$template_dir);
- my $content = $templ->show_page($template_dir, $input, \%acts);
+ my $content = BSE::Template->get_page($input, $cfg, \%acts);
my $outname = $template_dir .'/'.$out.'.work';
my $finalname = $template_dir . '/'. $out;
open OUT, "> $outname"
%gen_cache = ();
$callback->("Generating search base") if $callback;
- generate_search($articles);
+ generate_search($articles, $cfg);
$callback->("Generating shop base pages") if $callback;
generate_shop($articles);
if ($article) {
if ($article eq 'extras') {
$progress->("Generating search base") if $progress;
- generate_search($articles);
+ generate_search($articles, $cfg);
$progress->("Generating shop base pages") if $progress ;
generate_shop($articles);
use CGI qw(:standard);
use Carp; # 'verbose'; # remove the 'verbose' in production
use Articles;
-use Constants qw($TMPLDIR);
-use Squirrel::Template;
use BSE::Cfg;
use BSE::Template;
eval "use $article->{generator}";
die $@ if $@;
-my $generator = $article->{generator}->new(articles=>'Articles');
+my $generator = $article->{generator}->new(articles=>'Articles', cfg => $cfg);
my $template = param('template');
print "Content-Type: $type\n\n";
print $generator->generate_low($text, $article, 'Articles');
+
sub error_page {
my ($error) = @_;
$error ||= "Unknown error";
$gen->baseActs('Articles', \%acts),
error => sub { CGI::escapeHTML($error) },
);
- print "Content-Type: text/html\n\n";
- print Squirrel::Template->new(template_dir=>$TMPLDIR)
- ->show_page($TMPLDIR, 'error.tmpl', \%acts);
+
+ BSE::Template->show_page('error', $cfg, \%acts);
exit;
}
sub file_from_template {
my ($template) = @_;
- my $file = $TMPLDIR;
- $file .= "/" unless $file =~ m![\\/]$!;
- $file .= "printable/";
- $file .= $template;
-
- return $file;
+ return BSE::Template->find_source($template, $cfg);
}
use lib "$FindBin::Bin/modules";
use Articles;
use BSE::DB;
-use Squirrel::Template;
use Constants qw(:search);
use Carp;
use BSE::Cfg;
+use BSE::Template;
my $cfg = BSE::Cfg->new;
},
);
-print "Content-Type: text/html\n\n";
-my $templ = Squirrel::Template->new();
-print $templ->show_page($TMPLDIR, "search.tmpl", \%acts);
+BSE::Template->show_page('search', $cfg, \%acts);
sub getSearchResult {
my ($words, $section, $date, $terms) = @_;
use CGI ':standard';
use Products;
use Product;
-use Constants qw(:shop $TMPLDIR $CGI_URI);
-use Squirrel::Template;
+use Constants qw(:shop $CGI_URI);
+use BSE::Template;
use CGI::Cookie;
use BSE::Custom;
use BSE::Mail;
ifOptions => sub { @options },
options => sub { nice_options(@options) },
);
- my $templ = Squirrel::Template->new;
my $mailer = BSE::Mail->new(cfg=>$cfg);
# ok, send some email
- my $confirm = $templ->show_page($TMPLDIR, 'mailconfirm.tmpl', \%acts);
+ my $confirm = BSE::Template->get_page('mailconfirm', $cfg, \%acts);
if ($SHOP_EMAIL_ORDER) {
$acts{cardNumber} = sub { param('cardNumber') };
$acts{cardExpiry} = sub { param('cardExpiry') };
- my $ordertext = $templ->show_page($TMPLDIR, 'mailorder.tmpl', \%acts);
+ my $ordertext = BSE::Template->get_page('mailorder', $cfg, \%acts);
eval "use $crypto_class";
!$@ or die $@;
sub page {
my ($template, $acts) = @_;
- print "Content-Type: text/html\n\n";
- print Squirrel::Template->new->show_page($TMPLDIR, $template, $acts);
+
+ BSE::Template->show_page($template, $cfg, $acts);
}
# convert an epoch time to sql format
=head1 CHANGES
+=head2 0.12_22
+
+=over
+
+=item *
+
+added iterator allkids_of to iterate over the children and
+stepchildren of a given article.
+
+=over
+
+ <:iterator begin allkids_of I<parent_id1> ...:>
+ <:ofallkid I<field>:>
+ <:iterator end allkids_of:>
+
+=back
+
+=item *
+
+when you clicked send from the subscriptions list the archive parent
+field wasn't being set from the value set when adding/editing the
+subscription
+
+=item *
+
+generate_search() wasn't supplying a config object when creating the
+article generator. This caused problems when some article types were
+embedded within the search page.
+
+=item *
+
+added mailing list info
+
+=item *
+
+$TMPLDIR is no longer present or used in Constants.pm. Use templates
+in the [paths] section of the config file.
+
+=item *
+
+The path specified by the local_templates entry in [paths] is now
+searched for templates before the path specified by the templates
+entry in [paths]. This can be used to keep locally modified versions
+of templates separate from the distributed templates.
+
+=item *
+
+reordering arrows now display a filler image where there's a single
+missing arrow image (at the top and bottom of the list). No spacer is
+displayed if there's a single item.
+
+=item *
+
+added tt[text], pre[text], h1[class|text] through h6[class|text],
+class[class|text] tags to the body text formatter. Paragraphs are now
+closed by the body text formatter.
+
+=item *
+
+added a few more tests
+
+=back
+
=head2 0.12_21
=over
=item *
-template change from adriam (edit_steps.tmpl):
+template change from adrian (edit_steps.tmpl):
Finally fixed something that has bugged me for a while... I simply
moved the "if Kids" conditional to include the note about "Delete
=item templates
-Directory base for most templates. Note: this is not completely
-implemented for now, so assume the default. Default: $TMPLDIR.
+Directory base for most templates.
+
+=item local_templates
+
+Local Directory base for templates. This is searched before the
+templates directory.
=item images
}
sub make_ua {
- require "WWW/Automate.pm";
+ require WWW::Mechanize;
require "HTTP/Cookies.pm";
- my $ua = WWW::Automate->new;
+ my $ua = WWW::Mechanize->new;
$ua->cookie_jar(HTTP::Cookies->new);
$ua;
use BSE::Test;
++$|;
-print "1..43\n";
+print "1..45\n";
my $baseurl = base_url;
ok($baseurl =~ /^http:/, "basic check of base url");
my $ua = make_ua;
qr!Admin\sUsers!s);
fetch_ok($ua, "group list", "$baseurl/cgi-bin/admin/adminusers.pl?a_groups=1",
qr!Admin\sGroups!s);
-
+fetch_ok($ua, "subscriptions", "$baseurl/cgi-bin/admin/subs.pl",
+ qr/Subscriptions\s+List/);
use strict;
use BSE::Test qw(base_url make_ua fetch_ok skip check_form post_ok ok
check_content);
-use WWW::Automate;
+#use WWW::Mechanize;
++$|;
print "1..24\n";
my $baseurl = base_url;
#!perl -w
use strict;
use BSE::Test ();
-use Test::More tests=>31;
+use Test::More tests=>34;
use File::Spec;
use FindBin;
my $cgidir = File::Spec->catdir(BSE::Test::base_dir, 'cgi-bin');
ok(chdir $cgidir, "switch to CGI directory");
push @INC, 'modules';
+require BSE::Cfg;
+my $cfg = BSE::Cfg->new;
# create some articles to test with
require Articles;
require BSE::Util::SQL;
push(@kids, $kid);
}
+# make parent a step child of itself
+require BSE::Admin::StepParents;
+BSE::Admin::StepParents->add($parent, $parent);
+
my $top = Articles->getByPkey(1);
ok($top, "grabbing Home page");
EXPECTED
+template_test "allkids_of", $top, <<TEMPLATE, <<EXPECTED;
+<:iterator begin allkids_of $parent->{id}:><:
+ofallkid title:>
+<:iterator end allkids_of:>
+TEMPLATE
+Parent
+Three
+Two
+One
+
+EXPECTED
+
my @kidids = map $_->{id}, @kids;
template_test "inlines", $top, <<TEMPLATE, <<EXPECTED;
<:iterator begin inlines @kidids:><:
EXPECTED
+BSE::Admin::StepParents->del($parent, $parent);
for my $kid (reverse @kids) {
my $name = $kid->{title};
$kid->remove();
(my $filename = $article->{generator}) =~ s!::!/!g;
$filename .= ".pm";
require $filename;
- $article->{generator}->new();
+ $article->{generator}->new(cfg => $cfg);
};
ok($gen, "$tag: created generator $article->{generator}");
diag $@ unless $gen;
base_url = http://bsetest.develop-help.com
securl = http://shop.bsetest.develop-help.com:80
# where to install the site
-base_dir = /home/httpd/bsetest
+base_dir = /var/www/httpd/bsetest
# the database user/password/dsn
dbuser = bsetest
dbpass = bsetest
dbclass = BSE::DB::Mysql
sessionclass = Apache::Session::MySQL
# the location of mysql
-mysql = /usr/local/mysql/bin/mysql
+mysql = mysql
basic.access_control=0
#basic.htusers = /home/httpd/bsetest/htdocs/images/.htusers