mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-07 07:47 am

[dw-free] English-strip /stats

[commit: http://hg.dwscoalition.org/dw-free/rev/ba984edecb90]

http://bugs.dwscoalition.org/show_bug.cgi?id=408

Strip stats.bml.

Patch by [staff profile] denise.

Files modified:
  • htdocs/stats.bml
  • htdocs/stats.bml.text
--------------------------------------------------------------------------------
diff -r 36a421f8a480 -r ba984edecb90 htdocs/stats.bml
--- a/htdocs/stats.bml	Sat Mar 07 07:43:22 2009 +0000
+++ b/htdocs/stats.bml	Sat Mar 07 07:47:16 2009 +0000
@@ -1,16 +1,10 @@
 <?page
-title=>Statistics
 body<=
-
-<?h1 <?sitename?> Statistics h1?>
-<?p
-The following statistics may be interesting for some of you.  Note that for speed, most of this page is only updated every 24 hours.  However, certain parts are live.  Raw data can be picked up <a href="stats/stats.txt">here</a>.
-p?>
-<?hr?>
 
 <?_code
 
  use strict;
+ use vars qw/ $title /;
 
  LJ::set_active_crumb('stats');
 
@@ -19,6 +13,8 @@ p?>
 
  my $now = time();
  my %stat = ();
+ $title = BML::ml( '.title', { sitenameshort => $LJ::SITENAMESHORT } );
+ 
 
  $sth = $dbr->prepare("SELECT statcat, statkey, statval FROM stats WHERE statcat IN ('userinfo', 'client', 'age', 'gender', 'account', 'size')");
  $sth->execute;
@@ -51,30 +47,31 @@ p?>
  my $active = $stat{'size'}->{'accounts_active_30'}+0;
 
  my $ret = "";
- $ret .= "<?h1 Users h1?>\n";
- $ret .= "<?p How many users, and how many of those are active? p?> <ul>";
- $ret .= "<li><b>Total accounts: </b> $total</li>\n";
- $ret .= "<li><b>... active in some way: </b> $active</li>\n" if $active;
- $ret .= "<li><b>... that have ever updated: </b> $usedever</li>\n";
- $ret .= "<li><b>... updating in last 30 days: </b> $used30</li>\n";
- $ret .= "<li><b>... updating in last 7 days: </b> $used7</li>\n";
- $ret .= "<li><b>... updating in past 24 hours: </b> $usedlastday</li>\n";
+$ret .= "<p>" . BML::ml( '.description', { aopts => "href='stats/stats.txt'" } ) . "</p>";
+ $ret .= "<h1>$ML{'.users.header'}</h1>";
+ $ret .= "<p>$ML{'.users.desc'}</p>";
+ $ret .= "<li><b>$ML{'.users.total'} </b> $total</li>\n";
+ $ret .= "<li><b>$ML{'.users.total.active'} </b> $active</li>\n" if $active;
+ $ret .= "<li><b>$ML{'.users.total.everupdate'} </b> $usedever</li>\n";
+ $ret .= "<li><b>$ML{'.users.total.last30'} </b> $used30</li>\n";
+ $ret .= "<li><b>$ML{'.users.total.last7'} </b> $used7</li>\n";
+ $ret .= "<li><b>$ML{'.users.total.last24'} </b> $usedlastday</li>\n";
  $ret .= "</ul> \n";
 
- $ret .= "<?h1 Gender h1?>\n";
- $ret .= "<?p Who is more likely to maintain a journal? p?><ul>";
+ $ret .= "<h1>$ML{'.gender.header'}</h1>";
+ $ret .= "<p>$ML{'.gender.desc'}</p><ul>";
  {
      my $male = $stat{'gender'}->{'M'}+0;
      my $female = $stat{'gender'}->{'F'}+0;
      my $other = $stat{'gender'}->{'O'}+0;
      my $tot = $male+$female+$other;
      $tot ||= 1;
-     $ret .= "<li><b>Female: </b> $female (" . sprintf("%0.1f", $female*100/($tot||1)) . "%)</li>";
-     $ret .= "<li><b>Male: </b> $male (" . sprintf("%0.1f", $male*100/($tot||1)) . "%)</li>";
-     $ret .= "<li><b>Other: </b> $other (" . sprintf("%0.1f", $other*100/($tot||1)) . "%)</li>";
+     $ret .= "<li><b>$ML{'.gender.female'} </b> $female (" . sprintf("%0.1f", $female*100/($tot||1)) . "%)</li>";
+     $ret .= "<li><b>$ML{'.gender.male'} </b> $male (" . sprintf("%0.1f", $male*100/($tot||1)) . "%)</li>";
+     $ret .= "<li><b>$ML{'.gender.other'} </b> $other (" . sprintf("%0.1f", $other*100/($tot||1)) . "%)</li>";
  }
- $ret .= "<li><b>Unspecified: </b> " . ($stat{'gender'}->{'U'}+0) . "</li>";
- $ret .= "</ul>\n";
+     $ret .= "<li><b>$ML{'.gender.unspecified'} </b> " . ($stat{'gender'}->{'U'}+0) . "</li>";
+     $ret .= "</ul>\n";
 
  LJ::run_hook('statspage', {
      stat => \%stat,
@@ -83,8 +80,8 @@ p?>
 
  unless ($LJ::DISABLED{'stats-recentupdates'}) 
  { 
-     $ret .= "<?h1 Recent Updates h1?>\n";
-     $ret .= "<?p The following are the 10 most recently updated journals: p?><ul>";
+     $ret .= "<h1>$ML{'.recent.header'}</h1>";
+     $ret .= "<p>$ML{'.recent.desc'}</p><ul>";
      $sth = $dbr->prepare("SELECT u.user, u.name, uu.timeupdate FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate > DATE_SUB(NOW(), INTERVAL 30 DAY) ORDER BY uu.timeupdate DESC LIMIT 10");
      $sth->execute;
      my $ct;
@@ -92,14 +89,14 @@ p?>
          $ret .= "<li><a href='/users/$iuser/'><?_eh $iname _eh?></a>, $itime</li>\n";
          $ct++;
      }
-     $ret .= "<li><i>stat not available</i></li>" unless $ct;
+     $ret .= "<li><i>$ML{'.notavailable'}</i></li>" unless $ct;
      $ret .= "</ul> \n";
  }
 
  unless ($LJ::DISABLED{'stats-newjournals'}) 
  {
-     $ret .= "<?h1 New Journals h1?>\n";
-     $ret .= "<?p The following are the 10 most recently created journals.  It's very likely these users haven't modified their journals much, and probably haven't written much in them yet either... p?><ul>";
+     $ret .= "<h1>$ML{'.new.header'}</h1>";
+     $ret .= "<p>$ML{'.new.desc'}</p><ul>";
      $sth = $dbr->prepare("SELECT u.user, u.name, uu.timeupdate FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate IS NOT NULL ORDER BY uu.timecreate DESC LIMIT 10");
      $sth->execute;
      my $ct;
@@ -107,13 +104,13 @@ p?>
          $ret .= "<li><a href='/users/$iuser/'><?_eh $iname _eh?></a>, $itime</li>\n";
          $ct++;
      }
-     $ret .= "<li><i>stat not available</i></li>" unless $ct;
+     $ret .= "<li><i>$ML{'.notavailable'}</i></li>" unless $ct;
      $ret .= "</ul>\n";
  }
 
- $ret .= "<?h1 Demographics h1?>\n";
+     $ret .= "<h1>$ML{'.demographics.header'}</h1>";
  {
-     $ret .= "<?p The following are the 15 most popular countries $LJ::SITENAMESHORT is used in: p?><ul>";
+     $ret .= "<p>$ML{'.demographics.desc.countries'}</p><ul>";
      my $ct;
      foreach my $key (sort { $stat{'country'}->{$b} <=> $stat{'country'}->{$a} }
                       keys %{$stat{'country'}})
@@ -121,19 +118,19 @@ p?>
          $ret .= "<li><b>$key</b> - $stat{'country'}->{$key}</li>\n";
          $ct++;
      }
-     $ret .= "<li><i>stat not available</i></li>" unless $ct;
+     $ret .= "<li><i>$ML{'.notavailable'}</i></li>" unless $ct;
      $ret .= "</ul>\n";
  }
 
  {
-     $ret .= "The following are the 15 most popular U.S. states $LJ::SITENAMESHORT is used in: <ul>";
+     $ret .= "<p>$ML{'.demographics.desc.countries'}</p><ul>";
      my $ct;
      foreach my $key (sort { $stat{'state'}->{$b} <=> $stat{'state'}->{$a} } keys %{$stat{'state'}})
      {
          $ret .= "<li><b>$key</b> - $stat{'state'}->{$key}</li>\n";
          $ct++;
      }
-     $ret .= "<li><i>stat not available</i></li>" unless $ct;
+     $ret .= "<li><i>$ML{'.notavailable'}</i></li>" unless $ct;
      $ret .= "</ul> \n";
  }
 
@@ -146,8 +143,8 @@ p?>
  }
  my @ages = grep { $_ >= 13  && $_ <= 55 } sort { $a <=> $b } sort keys %age;
  if (@ages) {
-     $ret .= "<?h1 Age Distribution h1?><?p The following shows the age distribution " .
-             "of $LJ::SITENAMESHORT users: p?>\n";
+     $ret .= "<h1>$ML{'.age.header'}</h1>";
+     $ret .= "<p>$ML{'.age.desc'}</p>";
      $ret .= "<table>\n";
      my $lastage = 0;
      foreach my $age (@ages) {
@@ -186,7 +183,8 @@ p?>
      }
 
      if ($out) {
-         $ret .= "<?h1 Client Usage h1?><?p How people update their journals (over the last 30 days): p?>\n";
+         $ret .= "<h1>$ML{'.client.header'}</h1>";
+         $ret .= "<p>$ML{'.client.desc'}</p>";
          $ret .= "<table cellpadding='3'>\n";
          $ret .= $out;
          $ret .= "</table>\n";
@@ -215,6 +213,7 @@ _code?>
 _code?>
 
 <=body
+title=><?_code return $title; _code?>
 page?><?_c <LJDEP>
 link: htdocs/stats/, htdocs/support/faqbrowse.bml
 img: htdocs/img/bluedot.gif, htdocs/stats/postsbyday.png, htdocs/stats/postsbyweek.png, htdocs/stats/newbyday.png
diff -r 36a421f8a480 -r ba984edecb90 htdocs/stats.bml.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/stats.bml.text	Sat Mar 07 07:47:16 2009 +0000
@@ -0,0 +1,59 @@
+;; -*- coding: utf-8 -*-
+
+.age.header=Age Distribution
+
+.age.desc=The age distribution of our users:
+
+.client.header=Client Use
+
+.client.desc=How people have updated their journals over the last 30 days:
+
+.demographics.header=Demographics
+
+.demographics.desc.countries=The 15 top countries our users have listed as their homes:
+
+.demographics.desc.states=The 15 top states our users have listed as their homes:
+
+.description=The following statistics may be interesting. For speed, most of this page is only updated every 24 hours. You can also see the <a [[aopts]]>raw data</a>.
+
+.gender.header=Gender
+
+.gender.desc=The gender balance of our users:
+
+.gender.female=Female
+
+.gender.male=Male
+
+.gender.other=Other
+
+.gender.unspecified=Unspecified
+
+.new.header=New Journals
+
+.new.desc=The following are the 10 most recently created journals. (It's very likely these users haven't written much in them yet...)
+
+.notavailable=stat not available
+
+.recent.header=Recently Updated
+
+.recent.desc=The 10 most recently updated journals:
+
+.users.header=Users
+
+.users.desc=How many users, and how many of those are active?
+
+.users.total=Total accounts:
+
+.users.total.active=... active in some way:
+
+.users.total.everupdate=... that have ever updated:
+
+.users.total.last30=... updating in last 30 days:
+
+.users.total.last7=... updating in the last 7 days:
+
+.users.total.last24=... updating in the last 24 hours:
+
+.title=[[sitenameshort]] Statistics
+
+
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org