summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-09-22 14:59:33 +0200
committerSergey Poznyakoff <gray@gnu.org>2017-09-22 15:01:02 +0200
commit61af1d7f309befd07d5ffaf4fca579f68f75dd44 (patch)
tree8721cdfdc585bb26016bc75aff251ef67d893681
parentc990008d564dbaf4f8881458224b7ecaac104f07 (diff)
downloadsourceyard-61af1d7f309befd07d5ffaf4fca579f68f75dd44.tar.gz
sourceyard-61af1d7f309befd07d5ffaf4fca579f68f75dd44.tar.bz2
Provide tag helper for top-line menu items
* lib/Sourceyard.pm: New helper 'top_menu_item'. * templates/menu/topuser.html.ep: Use top_menu_item.
-rw-r--r--lib/Sourceyard.pm19
-rw-r--r--lib/Sourceyard/Controller.pm1
-rw-r--r--templates/menu/topuser.html.ep27
3 files changed, 23 insertions, 24 deletions
diff --git a/lib/Sourceyard.pm b/lib/Sourceyard.pm
index 4d1a528..fef3fe3 100644
--- a/lib/Sourceyard.pm
+++ b/lib/Sourceyard.pm
@@ -22,6 +22,8 @@ sub startup {
my $schema = Sourceyard::Schema->connect($config);
$self->helper(db => sub { return $schema; });
+
+ $self->helper(top_menu_item => \&_top_menu_item);
# FIXME: Move to a plugin?
$self->plugin('RemoteAddr');
@@ -57,4 +59,21 @@ sub startup {
$auth->get(':action')->to(controller => 'user');
}
+sub _top_menu_item {
+ my ($c, $tgt, $title, $content) = @_;
+
+ my $path = $c->req->url->path;
+ $path =~ s{^[^/]}{/};
+ $path =~ s{/$}{};
+
+ $tgt =~ s{^[^/]}{/};
+ $tgt =~ s{/$}{};
+
+ my $class = $tgt eq $path ? 'tabselect' : 'tabs';
+
+ return $c->tag('li', class => "topmenuitemmainitem",
+ $c->tag('a', href => $tgt, class => $class,
+ title => $title, $content));
+}
+
1;
diff --git a/lib/Sourceyard/Controller.pm b/lib/Sourceyard/Controller.pm
index 17f887c..98c5833 100644
--- a/lib/Sourceyard/Controller.pm
+++ b/lib/Sourceyard/Controller.pm
@@ -43,7 +43,6 @@ sub set_user {
&& -f ${$self->app->static->paths}[0] . '/css/' . $theme . '.css') {
$theme = $self->config->get(qw(default theme));
}
-
$self->stash(theme => $theme);
}
diff --git a/templates/menu/topuser.html.ep b/templates/menu/topuser.html.ep
index 11003ce..2cf5de1 100644
--- a/templates/menu/topuser.html.ep
+++ b/templates/menu/topuser.html.ep
@@ -10,29 +10,10 @@
</span><!-- end topmenutitle -->
<div class="topmenuitem">
<ul id="topmenuitem">
- <li class="topmenuitemmainitem">
- <a href="/user/" class="tabs" title="What's new for me?">
- Incoming Items
- </a>
- </li><!-- end topmenuitemmainitem -->
-
- <li class="topmenuitemmainitem">
- <a href="/user/items.php" class="tabs" title="Browse my items (bugs, tasks, bookmarks...)">
- Items
- </a>
- </li><!-- end topmenuitemmainitem -->
-
- <li class="topmenuitemmainitem">
- <a href="/user/groups.php" class="tabs" title="List the groups I belong to">
- Group Membership
- </a>
- </li><!-- end topmenuitemmainitem -->
-
- <li class="topmenuitemmainitem">
- <a href="/user/admin/" class="tabselect" title="Account configuration: authentication, cosmetics preferences...">
- Account Configuration
- </a>
- </li><!-- end topmenuitemmainitem -->
+%= top_menu_item '/user', "What's new for me?", "Incoming Items"
+%= top_menu_item '/user/items.php', "Browse my items (bugs, tasks, bookmarks...)", 'Items'
+%= top_menu_item '/user/groups.php', "List the groups I belong to", 'Group Membership'
+%= top_menu_item '/user/admin/', "Account configuration: authentication, cosmetics preferences...", "Account Configuration"
</ul>
</div><!-- end topmenuitem -->
</div>

Return to:

Send suggestions and report system problems to the System administrator.