summaryrefslogtreecommitdiff
path: root/web/lib/sources.rb
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2010-11-13 22:34:38 +0100
committerJochen Topf <jochen@topf.org>2010-11-13 22:34:38 +0100
commitbcae4dba9ec66d224e3fe0da845a76dd1c6c19a2 (patch)
tree91238e96808d879d0ec19f87cfbb4e34670d5a60 /web/lib/sources.rb
parent9db63dc2526bf0b2a94e7a6f37a0f7dabdb8f12d (diff)
downloadtaginfo-bcae4dba9ec66d224e3fe0da845a76dd1c6c19a2.tar
taginfo-bcae4dba9ec66d224e3fe0da845a76dd1c6c19a2.tar.gz
Automatically generate file sizes for downloads
Diffstat (limited to 'web/lib/sources.rb')
-rw-r--r--web/lib/sources.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/web/lib/sources.rb b/web/lib/sources.rb
index 918dd4d..44f7ad5 100644
--- a/web/lib/sources.rb
+++ b/web/lib/sources.rb
@@ -3,7 +3,7 @@ class Source
@@sources = Array.new
- attr_reader :id, :name, :data_until, :update_start, :update_end
+ attr_reader :id, :name, :data_until, :update_start, :update_end, :dbsize, :dbpack
# Enumerate all available sources
def self.each
@@ -26,6 +26,10 @@ class Source
@data_until = data_until
@update_start = update_start
@update_end = update_end
+
+ @dbsize = File.size("../../data/#{ dbname }").to_bytes rescue '<i>unknown</i>'
+ @dbpack = File.size("../../download/#{ dbname }.bz2").to_bytes rescue '<i>unknown</i>'
+
@@sources << self
end
@@ -54,4 +58,12 @@ class Source
%Q{<a href="#{ url }">#{ name }</a>}
end
+ def dbname
+ "taginfo-#{ @id }.db"
+ end
+
+ def link_download
+ %Q{<a href="/download/#{ dbname }.bz2">#{ dbname }.bz2</a>}
+ end
+
end