]> ruin.nu Git - ndwebbie.git/commitdiff
Added page to list def channels and alliance for planets
authorMichael Andreen <harv@ruin.nu>
Sat, 25 Jul 2009 13:58:07 +0000 (15:58 +0200)
committerMichael Andreen <harv@ruin.nu>
Sat, 25 Jul 2009 13:58:07 +0000 (15:58 +0200)
lib/NDWeb/Controller/Intel.pm
root/lib/site/leftbar.tt2
root/src/intel/channels.tt2 [new file with mode: 0644]

index 535ca28bbf0a4d7109796df30001a2750416895e..bbdf0f749ad461fb16fd0ffaa1101569ddf60105 100644 (file)
@@ -2,6 +2,7 @@ package NDWeb::Controller::Intel;
 
 use strict;
 use warnings;
+use feature ':5.10';
 use parent 'Catalyst::Controller';
 
 use NDWeb::Include;
@@ -97,6 +98,27 @@ sub planet : Local {
 
 }
 
+sub channels : Local {
+       my ( $self, $c, $order ) = @_;
+       my $dbh = $c->model;
+
+       if ($order ~~ /(alliance|channel)/){
+               $order = "lower($1) ASC";
+       }elsif ($order ~~ /(coords)/){
+               $order = "x,y,z";
+       }else{
+               $order = 'lower(channel)';
+       }
+
+       my $query = $dbh->prepare(q{
+SELECT id,coords(x,y,z),nick,channel,alliance FROM current_planet_stats
+WHERE channel <> '' and channel IS NOT NULL
+ORDER BY } . $order
+       );
+       $query->execute;
+       $c->stash(planets => $query->fetchall_arrayref({}) );
+}
+
 sub postplanetcomment : Local {
        my ($self, $c, $p) = @_;
 
index 7fdbbd4b82fa2519584ad463d995011765c2df18..6a271194d3e5ab01043d4ee431315d4ca7e6a27f 100644 (file)
 <p>Intel menu</p>
 <ul class="linkbar">
        <li><a href="/intel">Intel</a></li>
+       <li><a href="/intel/channels">Channels</a></li>
        <li><form action="/intel/find" method="post"><p>
                <input class="coordsinput" type="text" name="coords" value="[% checkcoords %]">
                <input class="coordsinput" type="submit" value="Check">
diff --git a/root/src/intel/channels.tt2 b/root/src/intel/channels.tt2
new file mode 100644 (file)
index 0000000..f1b70da
--- /dev/null
@@ -0,0 +1,17 @@
+[% META title = 'Channels' %]
+<table>
+       <tr>
+       <th><a href="[% c.uri_for('channels','coords') %]">Coords</a></th>
+       <th>Nick</th>
+       <th><a href="[% c.uri_for('channels','channel') %]">Channel</a></th>
+       <th><a href="[% c.uri_for('channels','alliance') %]">Alliance</a></th>
+       </tr>
+[% FOR p IN planets %]
+       <tr align="left" class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+       <td><a href="[% c.uri_for('/stats/planet',p.id) %]">[% p.coords %]</a></td>
+       <td><a href="[% c.uri_for('planet',p.id) %]">[% p.nick %]</a></td>
+       <td>[% p.channel %]</td>
+       <td>[% p.alliance %]</td>
+       </tr>
+[% END %]
+</table>