summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-09-22 20:27:35 +0200
committerSergey Poznyakoff <gray@gnu.org>2017-09-22 20:27:35 +0200
commit5cde1836ae832ed04e01cb12f4aa34f2d0d5d44e (patch)
treeab523510f843d27bdee9ca2a88bb2de528ff713e
parent61af1d7f309befd07d5ffaf4fca579f68f75dd44 (diff)
downloadsourceyard-5cde1836ae832ed04e01cb12f4aa34f2d0d5d44e.tar.gz
sourceyard-5cde1836ae832ed04e01cb12f4aa34f2d0d5d44e.tar.bz2
New helper 'alt_tag' for alternating class tags
-rw-r--r--lib/Sourceyard.pm22
-rw-r--r--templates/user/admin.html.ep29
2 files changed, 36 insertions, 15 deletions
diff --git a/lib/Sourceyard.pm b/lib/Sourceyard.pm
index fef3fe3..1ae9405 100644
--- a/lib/Sourceyard.pm
+++ b/lib/Sourceyard.pm
@@ -24,7 +24,8 @@ sub startup {
$self->helper(db => sub { return $schema; });
$self->helper(top_menu_item => \&_top_menu_item);
-
+ $self->helper(alt_tag => \&_alt_tag);
+
# FIXME: Move to a plugin?
$self->plugin('RemoteAddr');
$self->hook(before_dispatch => sub {
@@ -39,6 +40,7 @@ sub startup {
$self->app->defaults(user => undef);
$self->app->defaults(return_url => undef);
+ $self->app->defaults('sourceyard.alt' => 0);
# Router
my $r = $self->routes;
@@ -76,4 +78,22 @@ sub _top_menu_item {
title => $title, $content));
}
+sub _alt_tag {
+ my ($c, $tag) = (shift, shift);
+
+ my $last;
+ if (ref $_[-1] eq 'CODE') {
+ $last = pop;
+ }
+ if (@_ % 2 == 0) {
+ local %_ = @_;
+ my $n = delete $_{init} || $c->stash('sourceyard.alt');
+ $c->stash('sourceyard.alt' => !$n);
+ $_{class} .= 'alt' if $n;
+ @_ = %_;
+ }
+ push @_, $last if defined($last);
+ return $c->tag($tag, @_);
+}
+
1;
diff --git a/templates/user/admin.html.ep b/templates/user/admin.html.ep
index 2a621b0..fb99cea 100644
--- a/templates/user/admin.html.ep
+++ b/templates/user/admin.html.ep
@@ -7,7 +7,7 @@
<div class="splitleft">
<div class="box">
<div class="boxtitle">Identity Record</div>
- <div class="boxitem">
+%= alt_tag div => (class => 'boxitem', init => 0) => begin
Account #<%= $user->user_id %>
<p class="smaller">
Your login is <strong><%= $user->user_name %></strong>.
@@ -15,31 +15,32 @@
% $user->add_date->set_time_zone('local');
<strong><%= $user->add_date->strftime('%a %d %b %Y %I:%M:%S %p %z') %></strong>.
</p>
- </div><!-- end ---- boxitem -->
- <div class="boxitemalt">
+% end
+%= alt_tag div => (class => 'boxitem') => begin
<a href="change.php?item=realname">Change Real Name</a>
<p class="smaller">
You are <strong><%= $user->real_name %></strong>.
</p>
- </div><!-- end ---- boxitem -->
- <div class="boxitem">
+% end
+%= alt_tag div => (class => 'boxitem') => begin
<a href="resume.php">Edit Resume and Skills</a>
<p class="smaller">
Details about your experience and skills will be available to
logged in users in the hope they will be of interest.
</p>
- </div><!-- end ---- boxitem -->
- <div class="boxitemalt">
+% end
+%= alt_tag div => (class => 'boxitem') => begin
<a href="/users/gray">View your Public Profile</a>
<p class="smaller">
Your profile can be viewed by everybody.
</p>
- </div><!-- end ---- boxitem -->
+% end
+
</div><!-- end box -->
<br />
<div class="box">
<div class="boxtitle">Mail Setup</div>
- <div class="boxitem">
+%= alt_tag div => (class => 'boxitem') => begin
<a href="change.php?item=email">
Change Email Address
</a>
@@ -49,8 +50,8 @@
It is essential to us that this address remains valid. Keep
it up to date.
</p>
- </div><!-- end boxitem -->
- <div class="boxitemalt">
+% end
+%= alt_tag div => (class => 'boxitem') => begin
<a href="change_notifications.php">
Edit Personal Notification Settings
</a>
@@ -59,15 +60,15 @@
It permits also to configure the subject line prefix of sent
mails.
</p>
- </div><!-- end ---- boxitem -->
- <div class="boxitem">
+% end
+%= alt_tag div => (class => 'boxitem') => begin
<a href="cc.php">
Cancel Mail Notifications
</a>
<p class="smaller">
Here, you can cancel all mail notifications.
</p>
- </div><!-- end ---- boxitem -->
+% end
</div><!-- end box -->
<br />
</div><!-- end splitleft -->

Return to:

Send suggestions and report system problems to the System administrator.