Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
added /stats page
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Mar 22, 2009
1 parent d55bde6 commit ff0a6e1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sickounter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -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>
16 changes: 16 additions & 0 deletions views/stats.erb
Original file line number Diff line number Diff line change
@@ -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.