dcav-stats/gen_index.rb

34 lines
802 B
Ruby
Raw Normal View History

2017-05-08 22:07:59 +00:00
require 'erb'
require 'filesize'
RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/"
usernames = ["christoffermadsen","jmaa","jacob","alexander"]
shot_dir = "/var/shots/"
2017-05-08 22:07:59 +00:00
erb_file = "dcav-index.erb"
html_file = "/var/shots/html/index.html"
class User
attr_accessor :name, :count, :size
def <=> other
2017-05-08 22:07:59 +00:00
other.count <=> count
end
end
users = []
2017-05-08 22:07:59 +00:00
usernames.each do |username|
user = User.new
user.name = username
user.size = `du -B1 #{shot_dir}#{username}/ | awk {'print $1'} | head -n 1`
.delete("\n")
.to_i
user.count = `ls -1 #{shot_dir}#{username}/ | wc -l | head -n 1`
.delete("\n")
.to_i
2017-05-08 22:07:59 +00:00
users << user
end
File.open(html_file, 'w') do |f|
f << ERB.new(File.read erb_file).result
2017-05-08 22:07:59 +00:00
end