Skip to content
Browse files

added /stats page

  • Loading branch information...
1 parent d55bde6 commit ff0a6e129c9430c1e85b3bc6d77aa352fe35e277 @sickill committed Mar 22, 2009
Showing with 43 additions and 0 deletions.
  1. +7 −0 sickounter.rb
  2. +20 −0 views/layout.erb
  3. +16 −0 views/stats.erb
View
7 sickounter.rb
@@ -14,3 +14,10 @@
redirect(url)
end
+get '/stats' do
+ @downloads = {}
+ Dir["counters/*.txt"].each do |counter|
+ @downloads[counter.split("/")[1]] = File.read(counter).strip.to_i
+ end
+ erb :stats
+end
View
20 views/layout.erb
@@ -0,0 +1,20 @@
+<html>
+<head>
+ <title>Sickounter download statistics</title>
+ <style>
+ body { background-color: white; color: black; font: 8pt Verdana }
+ th { background-color: #789 }
+ tr th { font-weight: bold; text-align: left; color: white }
+ td, th { padding: 10px }
+ td { border-right: 1px solid #ccc; border-bottom: 1px solid #ccc }
+ div#main { margin: 0 auto; text-align: center; width: 800px }
+ table { border-left: 1px solid #ccc; border-bottom: 2px solid #ccc; border-spacing:0; }
+ table.wide { width: 100% }
+ th.dl { width: 50px }
+ h1 { text-align: center; margin-bottom: 60px }
+ </style>
+</head>
+<body>
+<%= yield %>
+</body>
+</html>
View
16 views/stats.erb
@@ -0,0 +1,16 @@
+<h1>Sickounter download statistics</h1>
+
+<div id="main">
+<table class="wide">
+ <tr>
+ <th>File</th>
+ <th class="dl">Downloads</th>
+ </tr>
+ <% @downloads.keys.sort_by { |counter| -@downloads[counter] }.each do |counter| %>
+ <tr>
+ <td><%= counter %></td>
+ <td><%= @downloads[counter] %></td>
+ </tr>
+ <% end %>
+</table>
+</div>

0 comments on commit ff0a6e1

Please sign in to comment.
Something went wrong with that request. Please try again.