Changeset 424


Ignore:
Timestamp:
Jun 17, 2004, 11:51:49 PM (18 years ago)
Author:
kake
Message:

Fixed userstats to work for host IP as well as username.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/templates/recent_changes.tt

    r423 r424  
    1818            <a href="[% cgi_url %]?username=[% node.username %];action=userstats">[% node.username %]</a>
    1919          [% ELSE %]
    20             <a href="[% cgi_url %]?username=[% node.host %];action=userstats">[% node.host %]</a>
     20            <a href="[% cgi_url %]?host=[% node.host %];action=userstats">[% node.host %]</a>
    2121          [% END %]
    2222        </td>
  • trunk/templates/userstats.tt

    r423 r424  
    33<div id="content">
    44[% INCLUDE navbar.tt %]
    5 <h2>User Stats for [% username %]</h2>
     5<h2>
     6  User Stats for
     7    [% IF username %]
     8      [% username %]
     9    [% ELSE %]
     10      [% host %]
     11    [% END %]
     12</h2>
    613
    714[% content %]
    815
    9 <h2>Last five nodes edited by <a href="[% full_cgi_url %]?[% username_param %]">[% username %]</a></h2>
     16<h2>
     17  Last five nodes edited by
     18  [% IF username %]
     19    <a href="[% full_cgi_url %]?[% username_param %]">[% username %]</a>
     20  [% ELSE %]
     21    [% host %]
     22  [% END %]
     23</h2>
    1024
    1125<ul>
  • trunk/wiki.cgi

    r423 r424  
    5050    my $preview = $q->param('preview') || 0;
    5151    my $search_terms = $q->param('terms') || $q->param('search') || '';
    52     my $username = $q->param('username') || '';
    5352    my $format = $q->param('format') || '';
    5453
     
    9089        delete_node($node);
    9190    } elsif ($action eq 'userstats') {
    92         show_userstats( $username );
     91        show_userstats(
     92                        username => $q->param("username") || "",
     93                        host     => $q->param("host") || "",
     94                      );
    9395    } elsif ($action eq 'list_all_versions') {
    9496        $guide->list_all_versions( id => $node );
     
    142144
    143145sub show_userstats {
    144     my $username = shift;
    145     croak "No username supplied to show_userstats" unless $username;
    146     my @nodes = $wiki->list_recent_changes(
    147         last_n_changes => 5,
    148         metadata_is    => { username => $username }
    149     );
     146    my %args = @_;
     147    my ($username, $host) = @args{ qw( username host ) };
     148    croak "No username or host supplied to show_userstats"
     149        unless $username or $host;
     150    my %criteria = ( last_n_changes => 5 );
     151    $criteria{metadata_is} = $username ? { username => $username }
     152                                       : { host     => $host };
     153    my @nodes = $wiki->list_recent_changes( %criteria );
    150154    @nodes = map { {name          => $q->escapeHTML($_->{name}),
    151155                    last_modified => $q->escapeHTML($_->{last_modified}),
     
    157161                    username        => $username,
    158162                    username_param  => $wiki->formatter->node_name_to_node_param($username),
     163                    host            => $host,
    159164                  );
    160165    process_template("userstats.tt", "", \%tt_vars);
Note: See TracChangeset for help on using the changeset viewer.