diff options
author | 2014-10-10 09:41:56 +0200 | |
---|---|---|
committer | 2014-10-10 09:41:56 +0200 | |
commit | e859df7b20341bfec9a91dec033915669f7d169a (patch) | |
tree | ea485ec4280c014068d5ab9557fbdad774386d6b | |
parent | Improve exception handling (diff) | |
download | infra-status-e859df7b20341bfec9a91dec033915669f7d169a.tar.gz infra-status-e859df7b20341bfec9a91dec033915669f7d169a.tar.bz2 infra-status-e859df7b20341bfec9a91dec033915669f7d169a.zip |
Make columns configurable via services.rb as well
-rw-r--r-- | lib/helpers.rb | 11 | ||||
-rw-r--r-- | lib/service_registry.rb | 26 | ||||
-rw-r--r-- | views/index.erb | 9 |
3 files changed, 40 insertions, 6 deletions
diff --git a/lib/helpers.rb b/lib/helpers.rb index 91ce9fb..99180e8 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -18,6 +18,17 @@ helpers do nil end + def render_column(id) + content = '' + + ServiceRegistry.instance.columns[id].each do |category| + content << "<h3>%s</h3>\n" % category + content << services_info(ServiceRegistry.instance.categories[category][:services]) + end + + content + end + def services_info(services) content = '<div class="list-group">' diff --git a/lib/service_registry.rb b/lib/service_registry.rb index 3d560b9..1f9e0d7 100644 --- a/lib/service_registry.rb +++ b/lib/service_registry.rb @@ -83,6 +83,7 @@ class ServiceRegistry def initialize @cache_locked = false @next_name = nil + @current_category = nil end def name(n) @@ -113,9 +114,32 @@ class ServiceRegistry @status_data end + def columns + update? + @columns + end + + def categories + update? + @categories + end + + def category(name, &block) + @categories[name] = {} + @current_category = name + @categories[name][:services] = block.call + @columns[@categories[name][:column]] << name + end + + def column(id) + @categories[@current_category][:column] = id + end + def update! @cache_locked = true @services = {} + @categories = {} + @columns = {1 => [], 2 => [], 3 => []} @status_data = JSON.parse(File.read(StatusSource)) load(File.join(File.dirname(__FILE__), '..', 'data', 'services.rb')) @load_date = DateTime.now @@ -123,6 +147,8 @@ class ServiceRegistry rescue Exception => e $stderr.puts e @services = {} + @categories = {} + @columns = {1 => [], 2 => [], 3 => []} @load_date = DateTime.new(2000, 1, 1) @cache_locked = false end diff --git a/views/index.erb b/views/index.erb index 564b1e7..00ffd6b 100644 --- a/views/index.erb +++ b/views/index.erb @@ -6,16 +6,13 @@ <div class="row"> <div class="col-lg-4"> - <h3>Community Services</h3> - <%= services_info %w[www forums wiki planet pgo lists archives] %> + <%= render_column 1 %> </div> <div class="col-lg-4"> - <h3>Development Services</h3> - <%= services_info %w[cvs bugzilla rsync devmanual overlays sources] %> + <%= render_column 2 %> </div> <div class="col-lg-4"> - <h3>Developer Resources</h3> - <%= services_info %w[dgo_ssh dgo_http dgo_smtp dgo_mbox blogs] %> + <%= render_column 3 %> </div> </div> |