]> ruin.nu Git - ndwebbie.git/commitdiff
rename top100 and added images and titles
authorMichael Andreen <harv@ruin.nu>
Fri, 26 Jan 2007 16:20:37 +0000 (16:20 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 26 Jan 2007 16:20:37 +0000 (16:20 +0000)
ND/Web/Pages/PlanetRankings.pm [new file with mode: 0644]
ND/Web/Pages/Top100.pm [deleted file]
startup.pl
templates/planetrankings.tmpl [new file with mode: 0644]
templates/skel.tmpl
templates/top100.tmpl [deleted file]

diff --git a/ND/Web/Pages/PlanetRankings.pm b/ND/Web/Pages/PlanetRankings.pm
new file mode 100644 (file)
index 0000000..813c9f6
--- /dev/null
@@ -0,0 +1,104 @@
+#**************************************************************************
+#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
+#                                                                         *
+#   This program is free software; you can redistribute it and/or modify  *
+#   it under the terms of the GNU General Public License as published by  *
+#   the Free Software Foundation; either version 2 of the License, or     *
+#   (at your option) any later version.                                   *
+#                                                                         *
+#   This program is distributed in the hope that it will be useful,       *
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+#   GNU General Public License for more details.                          *
+#                                                                         *
+#   You should have received a copy of the GNU General Public License     *
+#   along with this program; if not, write to the                         *
+#   Free Software Foundation, Inc.,                                       *
+#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+#**************************************************************************/
+
+package ND::Web::Pages::PlanetRankings;
+use strict;
+use warnings FATAL => 'all';
+use CGI qw/:standard/;
+use ND::Web::Include;
+
+use base qw/ND::Web::XMLPage/;
+
+$ND::Web::Page::PAGES{planetrankings} = __PACKAGE__;
+
+sub parse {
+       #TODO: Need to fix some links first
+       #if ($uri =~ m{^/[^/]+/(\w+)}){
+       #       param('order',$1);
+       #}
+}
+
+sub render_body {
+       my $self = shift;
+       my ($BODY) = @_;
+       $self->{TITLE} = 'Top planets';
+       my $DBH = $self->{DBH};
+
+       return $self->noAccess unless $self->isMember;
+
+       my $error = '';
+
+       $BODY->param(isHC => $self->isHC);
+
+       my $offset = 0;
+       if (defined param('offset') && param('offset') =~ /^(\d+)$/){
+               $offset = $1;
+       }
+       $BODY->param(Offset => $offset);
+       $BODY->param(PrevOffset => $offset - 100);
+       $BODY->param(NextOffset => $offset + 100);
+
+       my $order = 'scorerank';
+       if (defined param('order') && param('order') =~ /^(scorerank|sizerank|valuerank|xprank|hit_us)$/){
+               $order = $1;
+       }
+       $BODY->param(Order => $order);
+       $order .= ' DESC' if ($order eq 'hit_us');
+
+
+       my $extra_columns = '';
+       if ($self->isHC){
+               $extra_columns = ",planet_status,hit_us, alliance,relationship,nick";
+       }
+       my $query = $DBH->prepare(qq{SELECT coords(x,y,z),((ruler || ' OF ') || planet) as planet,race,
+               size, size_gain, size_gain_day,
+               score,score_gain,score_gain_day,
+               value,value_gain,value_gain_day,
+               xp,xp_gain,xp_gain_day,
+               sizerank,sizerank_gain,sizerank_gain_day,
+               scorerank,scorerank_gain,scorerank_gain_day,
+               valuerank,valuerank_gain,valuerank_gain_day,
+               xprank,xprank_gain,xprank_gain_day
+               $extra_columns FROM current_planet_stats_full ORDER BY $order LIMIT 100 OFFSET ?});
+       $query->execute($offset) or $error .= p($DBH->errstr);
+       my @planets;
+       my $i = 0;
+       while (my $planet = $query->fetchrow_hashref){
+               for my $type (qw/size score value xp/){
+                       #$planet->{$type} = prettyValue($planet->{$type});
+                       $planet->{"${type}img"} = 'stay';
+                       $planet->{"${type}img"} = 'up' if $planet->{"${type}_gain_day"} > 0;
+                       $planet->{"${type}img"} = 'down' if $planet->{"${type}_gain_day"} < 0;
+                       $planet->{"${type}rankimg"} = 'stay';
+                       $planet->{"${type}rankimg"} = 'up' if $planet->{"${type}rank_gain_day"} < 0;
+                       $planet->{"${type}rankimg"} = 'down' if $planet->{"${type}rank_gain_day"} > 0;
+                       for my $type ($type,"${type}_gain","${type}_gain_day"){
+                               $planet->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000
+                       }
+               }
+               $i++;
+               $planet->{ODD} = $i % 2;
+               push @planets,$planet;
+       }
+       $BODY->param(Planets => \@planets);
+       $BODY->param(Error => $error);
+       return $BODY;
+}
+
+1;
diff --git a/ND/Web/Pages/Top100.pm b/ND/Web/Pages/Top100.pm
deleted file mode 100644 (file)
index e18e36d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#**************************************************************************
-#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
-#                                                                         *
-#   This program is free software; you can redistribute it and/or modify  *
-#   it under the terms of the GNU General Public License as published by  *
-#   the Free Software Foundation; either version 2 of the License, or     *
-#   (at your option) any later version.                                   *
-#                                                                         *
-#   This program is distributed in the hope that it will be useful,       *
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-#   GNU General Public License for more details.                          *
-#                                                                         *
-#   You should have received a copy of the GNU General Public License     *
-#   along with this program; if not, write to the                         *
-#   Free Software Foundation, Inc.,                                       *
-#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
-#**************************************************************************/
-
-package ND::Web::Pages::Top100;
-use strict;
-use warnings FATAL => 'all';
-use CGI qw/:standard/;
-use ND::Web::Include;
-
-use base qw/ND::Web::XMLPage/;
-
-$ND::Web::Page::PAGES{top100} = __PACKAGE__;
-
-sub parse {
-       #TODO: Need to fix some links first
-       #if ($uri =~ m{^/[^/]+/(\w+)}){
-       #       param('order',$1);
-       #}
-}
-
-sub render_body {
-       my $self = shift;
-       my ($BODY) = @_;
-       $self->{TITLE} = 'Top planets';
-       my $DBH = $self->{DBH};
-
-       return $self->noAccess unless $self->isMember;
-
-       my $error = '';
-
-       $BODY->param(isHC => $self->isHC);
-
-       my $offset = 0;
-       if (defined param('offset') && param('offset') =~ /^(\d+)$/){
-               $offset = $1;
-       }
-       $BODY->param(Offset => $offset);
-       $BODY->param(PrevOffset => $offset - 100);
-       $BODY->param(NextOffset => $offset + 100);
-
-       my $order = 'scorerank';
-       if (defined param('order') && param('order') =~ /^(scorerank|sizerank|valuerank|xprank|hit_us)$/){
-               $order = $1;
-       }
-       $BODY->param(Order => $order);
-       $order .= ' DESC' if ($order eq 'hit_us');
-
-
-       my $extra_columns = '';
-       if ($self->isHC){
-               $extra_columns = ",planet_status,hit_us, alliance,relationship,nick";
-       }
-       my $query = $DBH->prepare(qq{SELECT coords(x,y,z),((ruler || ' OF ') || planet) as planet,race,
-               size, score, value, xp, sizerank, scorerank, valuerank, xprank
-               $extra_columns FROM current_planet_stats ORDER BY $order LIMIT 100 OFFSET ?});
-       $query->execute($offset) or $error .= p($DBH->errstr);
-       my @planets;
-       my $i = 0;
-       while (my $planet = $query->fetchrow_hashref){
-               $i++;
-               $planet->{ODD} = $i % 2;
-               push @planets,$planet;
-       }
-       $BODY->param(Planets => \@planets);
-       $BODY->param(Error => $error);
-       return $BODY;
-}
-
-1;
index 186b0c8ae3f2e9c62684694ed4e0e14da85790b3..113a1cca352d6c4756b7f8a69fb1af0cb63734e6 100644 (file)
@@ -34,7 +34,7 @@ use ND::Web::Pages::AddIntel;
 use ND::Web::Pages::Points;
 use ND::Web::Pages::LaunchConfirmation;
 use ND::Web::Pages::CovOp;
-use ND::Web::Pages::Top100;
+use ND::Web::Pages::PlanetRankings;
 use ND::Web::Pages::DefRequest;
 use ND::Web::Pages::Check;
 use ND::Web::Pages::Raids;
diff --git a/templates/planetrankings.tmpl b/templates/planetrankings.tmpl
new file mode 100644 (file)
index 0000000..8abca3a
--- /dev/null
@@ -0,0 +1,47 @@
+<TMPL_VAR NAME=Error>
+<p><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
+       <a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>
+<table>
+       <tr align="center"><th colspan="4">Rank</th>
+       </tr>
+       <tr>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=sizerank">Size</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=scorerank">Score</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=valuerank">Value</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=xprank">XP</a></th>
+       <th>Coords</th><th>Planet</th><th>Race</th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=sizerank">Size</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=scorerank">Score</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=valuerank">Value</a></th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=xprank">XP</a></th>
+       <TMPL_IF isHC>
+       <th>Nick</th>
+       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=hit_us">Hit us</a></th>
+       <th>Alliance</th>
+       </TMPL_IF>
+       </tr>
+       <TMPL_LOOP Planets>
+       <tr align="right" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=SizeRank_Gain_day> Today | <TMPL_VAR NAME=SizeRank_Gain> Tick"><TMPL_VAR NAME=SizeRank> <img src="/images/<TMPL_VAR NAME=SizeRankImg>.png" alt="<TMPL_VAR NAME=SizeImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=ScoreRank_Gain_day> Today | <TMPL_VAR NAME=ScoreRank_Gain> Tick"><TMPL_VAR NAME=ScoreRank> <img src="/images/<TMPL_VAR NAME=ScoreRankImg>.png" alt="<TMPL_VAR NAME=ScoreImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=ValueRank_Gain_day> Today | <TMPL_VAR NAME=ValueRank_Gain> Tick"><TMPL_VAR NAME=ValueRank> <img src="/images/<TMPL_VAR NAME=ValueRankImg>.png" alt="<TMPL_VAR NAME=ValueImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=XPRank_Gain_day> Today | <TMPL_VAR NAME=XPRank_Gain> Tick"><TMPL_VAR NAME=XPRank> <img src="/images/<TMPL_VAR NAME=XPRankImg>.png" alt="<TMPL_VAR NAME=XPImg>"/> </td>
+
+               <td align="left"><a href="/<TMPL_VAR NAME=PAGE>?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
+               <td align="center"><TMPL_VAR NAME=Planet></td>
+               <td align="center"><TMPL_VAR NAME=Race></td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=Size_Gain_day> Today | <TMPL_VAR NAME=Size_Gain> Tick"><TMPL_VAR NAME=Size> <img src="/images/<TMPL_VAR NAME=SizeImg>.png" alt="<TMPL_VAR NAME=SizeImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=Score_Gain_day> Today | <TMPL_VAR NAME=Score_Gain> Tick"><TMPL_VAR NAME=Score> <img src="/images/<TMPL_VAR NAME=ScoreImg>.png" alt="<TMPL_VAR NAME=ScoreImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=Value_Gain_day> Today | <TMPL_VAR NAME=Value_Gain> Tick"><TMPL_VAR NAME=Value> <img src="/images/<TMPL_VAR NAME=ValueImg>.png" alt="<TMPL_VAR NAME=ValueImg>"/> </td>
+               <td style="padding-left: 0.5em" title="<TMPL_VAR NAME=XP_Gain_day> Today | <TMPL_VAR NAME=XP_Gain> Tick"><TMPL_VAR NAME=XP> <img src="/images/<TMPL_VAR NAME=XPImg>.png" alt="<TMPL_VAR NAME=XPImg>"/> </td>
+
+       <TMPL_IF isHC>
+       <td class="<TMPL_VAR NAME=Planet_Status>"><a href="intel?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Nick>(<TMPL_VAR NAME=Planet_Status>)</a></td>
+       <td><TMPL_VAR NAME=Hit_Us></td>
+       <td class="<TMPL_VAR NAME=Relationship>"><TMPL_VAR NAME=Alliance></td>
+       </TMPL_IF>
+       </tr>
+       </TMPL_LOOP>
+</table>
+<p><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
+       <a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>
index 6ae06911697a1a8568eeb2cb7049c0bb2c8a2e3b..02d88a09ca0662e6466c085624a3f9d1f9b6cffe 100644 (file)
@@ -27,7 +27,7 @@
                <li><a href="/launchConfirmation">Launch confirmation</a></li>
                <li><a href="/covop">CovOp targets</a></li>
                <li><a href="/covop?list=distwhores">Distwhores</a></li>
-               <li><a href="/top100">Top100 planets</a></li>
+               <li><a href="/planetrankings">Planet Rankings</a></li>
                <li><a href="/defrequest">Request defense</a></li>
        </ul>
        </TMPL_IF>
diff --git a/templates/top100.tmpl b/templates/top100.tmpl
deleted file mode 100644 (file)
index 68c83d1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<TMPL_VAR NAME=Error>
-<p><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
-       <a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>
-<table>
-       <tr><th>Coords</th><th>Planet</th><th>Race</th>
-       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=sizerank">Size (rank)</a></th>
-       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=scorerank">Score (rank)</a></th>
-       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=valuerank">Value (rank)</a></th>
-       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=xprank">XP (rank)</a></th>
-       <TMPL_IF isHC>
-       <th>Nick</th>
-       <th><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=Offset>&amp;order=hit_us">Hit us</a></th>
-       <th>Alliance</th>
-       </TMPL_IF>
-       </tr>
-       <TMPL_LOOP Planets>
-       <tr align="center" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
-       <td><a href="check?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
-       <td><TMPL_VAR NAME=Planet></td>
-       <td><TMPL_VAR NAME=Race></td>
-       <td><TMPL_VAR NAME=Size>(<TMPL_VAR NAME=Sizerank>)</td>
-       <td><TMPL_VAR NAME=Score>(<TMPL_VAR NAME=Scorerank>)</td>
-       <td><TMPL_VAR NAME=Value>(<TMPL_VAR NAME=Valuerank>)</td>
-       <td><TMPL_VAR NAME=XP>(<TMPL_VAR NAME=XPrank>)</td>
-       <TMPL_IF isHC>
-       <td class="<TMPL_VAR NAME=Planet_Status>"><a href="intel?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Nick>(<TMPL_VAR NAME=Planet_Status>)</a></td>
-       <td><TMPL_VAR NAME=Hit_Us></td>
-       <td class="<TMPL_VAR NAME=Relationship>"><TMPL_VAR NAME=Alliance></td>
-       </TMPL_IF>
-       </tr>
-       </TMPL_LOOP>
-</table>
-<p><a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
-       <a href="/<TMPL_VAR NAME=PAGE>?offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>