Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 12 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
View
6 site/cgi-bin/modules/Article.pm
@@ -8,7 +8,7 @@ use vars qw/@ISA/;
@ISA = qw/Squirrel::Row BSE::TB::SiteCommon BSE::TB::TagOwner/;
use Carp 'confess';
-our $VERSION = "1.017";
+our $VERSION = "1.018";
=head1 NAME
@@ -596,10 +596,10 @@ sub should_generate {
return $self->is_linked && $self->listed && $self->is_released && !$self->is_expired;
}
-sub restricted_methods {
+sub restricted_method {
my ($self, $name) = @_;
- return $self->SUPER::restricted_methods($name)
+ return $self->SUPER::restricted_method($name)
|| $name =~ /^(?:update_|remove_|add_)/;
}
View
36 site/cgi-bin/modules/BSE/Regen.pm
@@ -10,7 +10,7 @@ use Carp qw(confess);
use BSE::WebUtil qw(refresh_to_admin);
use BSE::Util::HTML;
-our $VERSION = "1.008";
+our $VERSION = "1.010";
# returns non-zero if the Regenerate button should work
sub generate_button {
@@ -123,7 +123,7 @@ sub _search_presets {
_cfg_presets($cfg, \%article, "search");
- return \%article;
+ return _dummy_article(\%article);
}
sub _shop_presets {
@@ -138,7 +138,7 @@ sub _shop_presets {
_cfg_presets($cfg, $shop, "shop");
- return $shop;
+ return _dummy_article($shop);
}
sub _extras_presets {
@@ -152,7 +152,7 @@ sub _extras_presets {
$article{link} = $cfg->entryErr('site', 'url');
_cfg_presets($cfg, \%article, $presets);
- return \%article;
+ return _dummy_article(\%article);
}
my %builtin_extras =
@@ -465,4 +465,32 @@ sub _write_text {
or die "Cannot close $filename: $!";
}
+sub _dummy_article {
+ my ($data) = @_;
+
+ return bless $data, "BSE::Regen::DummyArticle";
+}
+
+package BSE::Regen::DummyArticle;
+use base 'BSE::TB::SiteCommon';
+
+sub images {
+ return;
+}
+
+sub files {
+ return;
+}
+
+{
+ use Articles;
+ for my $name (Article->columns) {
+ eval "sub $name { \$_[0]{$name} }";
+ }
+}
+
+sub restricted_method {
+ return 0;
+}
+
1;
View
47 site/cgi-bin/modules/BSE/UserReg.pm
@@ -18,7 +18,7 @@ use BSE::Util::Iterate;
use base 'BSE::UI::UserCommon';
use Carp qw(confess);
-our $VERSION = "1.023";
+our $VERSION = "1.024";
use constant MAX_UNACKED_CONF_MSGS => 3;
use constant MIN_UNACKED_CONF_GAP => 2 * 24 * 60 * 60;
@@ -528,23 +528,7 @@ sub req_show_register {
"Registration disabled");
}
}
- $errors ||= {};
- $message ||= $cgi->param('message');
- if (defined $message) {
- $message = escape_html($message);
- }
- else {
- if (keys %$errors) {
- my @keys = $cgi->param();
- my %errors_copy = %$errors;
- my @errors = grep defined, delete @errors_copy{@keys};
- push @errors, values %errors_copy;
- $message = join("<br />", map escape_html($_), @errors);
- }
- else {
- $message = '';
- }
- }
+ $message = $req->message($message || $errors);
my @subs = grep $_->{visible}, BSE::SubscriptionTypes->all;
my $sub_index = -1;
@@ -767,6 +751,8 @@ sub req_register {
$custom->siteusers_changed($cfg);
+ $req->flash_notice("msg:bse/user/register", [ $user ]);
+
return $self->_got_user_refresh($req);
}
else {
@@ -926,19 +912,8 @@ sub req_show_opts {
my %usersubs = map { $_->{subId}, $_ } @usersubs;
my $sub_index;
- $errors ||= {};
- $message ||= $cgi->param('message');
- if (defined $message) {
- $message = escape_html($message);
- }
- else {
- if (keys %$errors) {
- $message = $req->message($errors);
- }
- else {
- $message = '';
- }
- }
+ $message = $req->message($message || $errors);
+
require BSE::TB::OwnedFiles;
my @file_cats = BSE::TB::OwnedFiles->categories($cfg);
my %subbed = map { $_ => 1 } $user->subscribed_file_categories;
@@ -1218,6 +1193,8 @@ sub req_saveopts {
}
}
+ $req->flash_notice("msg:bse/user/saveopts", [ $user ]);
+
$custom->siteusers_changed($cfg);
return $req->get_refresh($url);
@@ -1348,17 +1325,11 @@ sub req_userpage {
my $cgi = $req->cgi;
my $session = $req->session;
- if ($message) {
- $message = escape_html($message);
- }
- else {
- $message = $req->message;
- }
+ $message = $req->message($message);
my $result;
my $user = $self->_get_user($req, 'userpage', \$result)
or return $result;
- $message ||= $cgi->param('message') || '';
my $it = BSE::Util::Iterate->new;
my %acts =
View
2,381 site/cgi-bin/modules/Generate.pm
1,223 additions, 1,158 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
9 site/cgi-bin/modules/Generate/Article.pm
@@ -16,7 +16,7 @@ use Carp 'confess';
use BSE::Util::Iterate;
use BSE::CfgInfo qw(cfg_dist_image_uri cfg_image_uri);
-our $VERSION = "1.009";
+our $VERSION = "1.011";
=head1 NAME
@@ -102,13 +102,17 @@ sub link_to_form {
sub generate_low {
my ($self, $template, $article, $articles, $embedded) = @_;
+
+ $self->localize;
my %acts;
%acts = $self->baseActs($articles, \%acts, $article, $embedded);
+ local $self->{acts} = \%acts;
my $page = BSE::Template->replace($template, $self->{cfg}, \%acts,
$self->variables);
%acts = (); # try to destroy any circular refs
+ $self->unlocalize;
return $page;
}
@@ -116,11 +120,14 @@ sub generate_low {
sub generate {
my ($self, $article, $articles) = @_;
+ $self->localize;
my %acts;
%acts = $self -> baseActs($articles, \%acts, $article, 0);
+ local $self->{acts} = \%acts;
my $page = BSE::Template->get_page($article->template, $self->{cfg}, \%acts, undef, undef, $self->variables);
%acts = ();
+ $self->unlocalize;
return $page;
}
View
6 site/cgi-bin/modules/Squirrel/Template.pm
@@ -20,7 +20,7 @@ BEGIN {
use constant DEBUG_GET_PARMS => 0;
-our $VERSION = "1.025";
+our $VERSION = "1.026";
my %compile_cache;
@@ -921,6 +921,10 @@ prev, next - the previous or next element respectively, if any.
list - the list argument to C<.for>.
+=item *
+
+current - the current item in the iteration.
+
=back
=head2 params
View
4 site/cgi-bin/modules/Squirrel/Template/Expr.pm
@@ -1,7 +1,7 @@
package Squirrel::Template::Expr;
use strict;
-our $VERSION = "1.010";
+our $VERSION = "1.011";
package Squirrel::Template::Expr::Eval;
use Scalar::Util ();
@@ -663,7 +663,7 @@ sub get {
$self->[TEXT] =~ s!\A(\s*/((?:[^/\\]|\\.)+)/([ismx]*\s)?\s*)!!) {
push @$queue, [ re => $1, $2, $3 || "" ];
}
- elsif ($self->[TEXT] =~ s/\A(\s*(not\b|eq\b|ne\b|le\b|lt\b|ge\b|gt\b|<=|>=|[!=]\=|\=\~|[_\?:,\[\]\(\)<>=!.*\/+\{\};\$-])\s*)//) {
+ elsif ($self->[TEXT] =~ s/\A(\s*(not\b|eq\b|ne\b|le\b|lt\b|ge\b|gt\b|<=|>=|[!=]\=|\=\~|!~|[_\?:,\[\]\(\)<>=!.*\/+\{\};\$-])\s*)//) {
push @$queue, [ "op$2" => $1 ];
}
elsif ($self->[TEXT] =~ s/\A(\s*([A-Za-z_][a-zA-Z_0-9]*)\s*)//) {
View
23 site/cgi-bin/modules/Squirrel/Template/Expr/WrapScalar.pm
@@ -2,7 +2,7 @@ package Squirrel::Template::Expr::WrapScalar;
use strict;
use base qw(Squirrel::Template::Expr::WrapBase);
-our $VERSION = "1.007";
+our $VERSION = "1.008";
sub _do_length {
my ($self, $args) = @_;
@@ -234,6 +234,14 @@ sub _do_replace {
return $str;
}
+sub _do_escape {
+ my ($self, $args) = @_;
+
+ @$args == 1
+ or die [ error => "scalar.escape requires one parameter" ];
+ return $self->[1]->format($self->[0], $args->[0]);
+}
+
sub call {
my ($self, $method, $args) = @_;
@@ -314,6 +322,19 @@ C<count> defaults to C<0>. A count of C<0> returns as many elements
as are found but removes any trailing empty length elements. A
negative C<count> returns all elements.
+=item format(format)
+
+Formats the scalar using a sprintf() format code.
+
+ (10.123).format("%.2f") # "10.12"
+
+=item escape(type)
+
+Escape the scalar with the template defined escape method, eg. "html",
+"uri".
+
+ "a&b".escape("html") # "a&amp;b"
+
=item evaltag
Evalulate the value of string as if processed as a tag. The string
View
3 site/cgi-bin/modules/Squirrel/Template/Processor.pm
@@ -3,7 +3,7 @@ use strict;
use Squirrel::Template::Constants qw(:node);
use Scalar::Util ();
-our $VERSION = "1.020";
+our $VERSION = "1.021";
use constant ACTS => 0;
use constant TMPLT => 1;
@@ -278,6 +278,7 @@ sub _process_for {
my @result;
for my $current (@$list) {
$scope->{$name} = $current;
+ $loop{current} = $current;
push @result, $self->process($node->[NODE_FOR_CONTENT]);
++$index;
}
View
8 site/data/db/bse_msg_base.data
@@ -1,5 +1,5 @@
--
-# VERSION=1.003
+# VERSION=1.004
id: bse/
description: BSE messages
@@ -65,6 +65,12 @@ description: No order containing this file has been paid for (if must_be_paid se
id: bse/user/downloaderror/unfilled
description: No order containing this file has been filled (if must_be_filled set)
+id: bse/user/register
+description: Displayed on successful registration ($1 the new user object).
+
+id: bse/user/saveopts
+description: Displayed when options saved successfully ($1 the user object).
+
id: bse/admin/
description: BSE Administration
View
6 site/data/db/bse_msg_defaults.data
@@ -37,6 +37,12 @@ message: You haven't paid the order containing this file
id: bse/user/downloaderror/unfilled
message: The order containing this file hasn't been filled. Please contact us.
+id: bse/user/register
+message: User '%1:{userId}s' successfully registered
+
+id: bse/user/saveopts
+message: Saved %1:{userId}s's options
+
id: bse/admin/edit/image/save/nameformat
message: Image identifiers must be a letter or underscore followed by zero or more letters, underscores or digits
View
24 site/templates/preload.tmpl
@@ -164,4 +164,28 @@ Page <:= pages.page :> of <:= pages.pagecount :>
<: .end if -:>
<:.end define -:>
+<:.define mover -:>
+<:# expects loop, parent
+ which in most cases means you can just supply parent
+-:>
+<:.set distim = cfg.entryIfVar("uri", "dist_images", "/images") -:>
+<:.set width = cfg.entry("arrows", "width", 17) -:>
+<:.set height = cfg.entry("arrows", "height", 13) -:>
+<:.set extras = 'width="' _ width _ '" height="' _ height _ '"' -:>
+<:.set blankim = '<img src="' _ (distim _ "/trans_pixel.gif").escape("html") _ '" alt="" ' _ extras _ ' />' -:>
+<:.if loop.prev -:>
+ <:.set upimg = cfg.entry("arrows", "upimg", distim _ "/admin/move_up.gif") -:>
+<a href="<:= cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.prev.id, "r":top.admin }) :>"><img src="<:= upimg :>" <:= extras :> /></a>
+<:.else -:>
+<:= blankim |raw-:>
+<:.end if -:>
+<:.if loop.next -:>
+ <:.set downimg = cfg.entry("arrows", "downimg", distim _ "/admin/move_down.gif") -:>
+<a href="<:= cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.next.id, "r":top.admin }) :>"><img src="<:= downimg :>" <:= extras :> /></a>
+<:.else -:>
+<:= blankim |raw-:>
+<:.end if -:>
+
+<:.end define -:>
+
<:- include includes/custom/preload.tmpl optional -:>
View
7 site/templates/user/options_base.tmpl
@@ -45,14 +45,13 @@
</td>
</tr>
<:eif Partial_logon:>
- <:if Message:>
+ <:.if request.message:>
<tr>
<td colspan="2" align="center">
- <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>
- <:message:></b></font></p>
+ <:- .call "messages" -:>
</td>
</tr>
- <:or Message:><:eif Message:>
+ <:.end if:>
<:if Imagetemplates:>
<tr>
<td colspan="2" height="20" align="center">
View
6 site/templates/user/register_base.tmpl
@@ -7,13 +7,13 @@
Registration</font></b></p>
</th>
</tr>
- <:if Message:>
+ <:.if request.message:>
<tr>
<td colspan="2" align="center">
- <p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><:message:></font></b></p>
+ <:.call "messages":>
</td>
</tr>
- <:or Message:><:eif Message:> <:if User:>
+ <:.end if:> <:if User:>
<tr>
<td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">You
are already logged on - Why register again?</font></td>
View
2 site/templates/user/userpage_base.tmpl
@@ -30,7 +30,7 @@
</table>
<br>
-<:if Message:><p class="message"><:message:></p> <:or Message:><:eif Message:>
+<:.if request.message:><p class="message"><:.call "messages":></p> <:.end if:>
<table width="100%" cellpadding="0" cellspacing="1">
<tr>
<th align="center" height="20"><font face="Verdana, Arial, Helvetica, sans-serif" size="3">Your
View
24 t/020-templater/040-original.t
@@ -1,7 +1,8 @@
#!perl -w
# Basic tests for Squirrel::Template
use strict;
-use Test::More tests => 167;
+use Test::More tests => 170;
+use HTML::Entities;
sub template_test($$$$;$$);
@@ -466,7 +467,9 @@ OUT
[ 'not 1 or 1', 1 ],
[ 'not 1 and 1', "" ],
[ '"xabcy" =~ /abc/', 1 ],
+ [ '"xabcy" !~ /abc/', "" ],
[ '[ "abc" =~ /(.)(.)/ ][1]', "b" ],
+ [ '"xabcy" !~ /abg/', 1 ],
[ '{ "a": 11, "b": 12, "c": 20 }["b"]', 12 ],
[ '[ 1, 2, 3 ][1]', 2 ],
[ 'testclass.foo', "[TestClass.foo]" ],
@@ -516,6 +519,7 @@ OUT
[ '"test".is_list', 0 ],
[ '"test".is_hash', 0 ],
[ '"abc".replace(/(.)(.)(.)/, "$3$2$1")', "cba" ],
+ [ '"a&b".escape("html")', 'a&amp;b' ],
# WrapArray
[ '[ [ 1, 2 ], 3 ].expand.join(",")', "1,2,3" ],
@@ -554,13 +558,13 @@ IN
IN
template_test(<<IN, <<OUT, "simple .for", \%acts, "", \%vars);
<:.for x in [ "a" .. "d" ] -:>
-Value: <:= x :> Index: <:= loop.index :> Count: <:= loop.count:> Prev: <:= loop.prev :> Next: <:= loop.next :> Even: <:= loop.even :> Odd: <:= loop.odd :> Parity: <:= loop.parity :> is_first: <:= loop.is_first :> is_last: <:= loop.is_last :>-
+Value: <:= x :> Index: <:= loop.index :> Count: <:= loop.count:> Prev: <:= loop.prev :> Next: <:= loop.next :> Even: <:= loop.even :> Odd: <:= loop.odd :> Parity: <:= loop.parity :> is_first: <:= loop.is_first :> is_last: <:= loop.is_last :> Current by index: <:= loop.current :>-
<:.end-:>
IN
-Value: a Index: 0 Count: 1 Prev: Next: b Even: Odd: 1 Parity: odd is_first: 1 is_last: -
-Value: b Index: 1 Count: 2 Prev: a Next: c Even: 1 Odd: Parity: even is_first: is_last: -
-Value: c Index: 2 Count: 3 Prev: b Next: d Even: Odd: 1 Parity: odd is_first: is_last: -
-Value: d Index: 3 Count: 4 Prev: c Next: Even: 1 Odd: Parity: even is_first: is_last: 1-
+Value: a Index: 0 Count: 1 Prev: Next: b Even: Odd: 1 Parity: odd is_first: 1 is_last: Current by index: a-
+Value: b Index: 1 Count: 2 Prev: a Next: c Even: 1 Odd: Parity: even is_first: is_last: Current by index: b-
+Value: c Index: 2 Count: 3 Prev: b Next: d Even: Odd: 1 Parity: odd is_first: is_last: Current by index: c-
+Value: d Index: 3 Count: 4 Prev: c Next: Even: 1 Odd: Parity: even is_first: is_last: 1 Current by index: d-
OUT
template_test(<<IN, <<OUT, "simple .if", \%acts, "", \%vars);
<:.if "a" eq "b" :>FAIL<:.else:>SUCCESS<:.end:>
@@ -728,7 +732,13 @@ sub template_test ($$$$;$$) {
my $templater = Squirrel::Template->new
(
template_dir=>'t/templates',
- preload => "preload.tmpl"
+ preload => "preload.tmpl",
+ formats =>
+ {
+ html => sub {
+ encode_entities($_[0], '&<>');
+ }
+ }
);
my $result = $templater->replace_template($in, $acts, undef, "test", $vars);

No commit comments for this range

Something went wrong with that request. Please try again.