Permalink
Browse files

Made index a little more resilient to not render graphs if there aren…

…'t any active hosts

Added some notes regarding dependencies due to some lazy gem authors
Cleaned up button styles to be universal
Corrected Rakefile issues to actually work!
Made configuation a 'must do'
  • Loading branch information...
1 parent e85946c commit 73931de80751c8b9e1d23156ff70e17db04e7f40 @benschwarz committed Feb 14, 2009
View
@@ -1,2 +1,4 @@
.DS_Store
-log/*
+log/*
+Capfile
+config/
View
@@ -0,0 +1,6 @@
+[submodule "vendor/sinatra-ditties"]
+ path = vendor/sinatra-ditties
+ url = git://github.com/foca/sinatra-ditties.git
+[submodule "vendor/gchart"]
+ path = vendor/gchart
+ url = git://github.com/abhay/gchart.git
View
@@ -1,12 +1,12 @@
-require File.dirname(__FILE__) + "amnesia"
+require File.join(File.dirname(__FILE__), "amnesia")
namespace :db do
- task :connect
+ task :connect do
Amnesia.new
end
desc "Auto migrate the database"
- task :migrate do
+ task :migrate => :connect do
DataMapper.auto_migrate!
end
View
@@ -1,13 +1,22 @@
+# Stdlib
+require 'rubygems'
require 'logger'
require 'yaml'
+
+# Readily available
+require 'sinatra'
require 'dm-core'
-require 'memcache'
+require 'memcache' # memcache-client
require 'active_support'
-require 'gchart'
+require 'gchart' # googlecharts
+# Core extensions
Dir["app/core_ext/*.rb"].each &method(:require)
-require 'app/base'
-require 'app/models'
-require 'app/helpers'
-require 'app/web'
+$:.unshift "#{File.dirname(__FILE__)}/app"
+
+# Amnesia
+require 'base'
+require 'models'
+require 'helpers'
+require 'web'
View
@@ -1,7 +1,7 @@
module Amnesia
class << self
- def new(config_file)
- self.config = config_file unless config_file.nil?
+ def new
+ configure!
DataMapper.setup(:default, config[:db])
Sinatra::Application
end
@@ -18,8 +18,8 @@ def default_config
}
end
- def config=(file)
- @config ||= default_config.merge(YAML.load_file(file))
+ def configure!
+ @config ||= default_config.merge(YAML.load_file('amnesia.yml'))
end
end
end
@@ -2,7 +2,7 @@ module Amnesia
module Helpers
module HostGraph
def graph_url(data = [], labels = [])
- Gchart.pie(:data => data, :size => '115x115')
+ GChart.pie(:data => data, :size => '115x115').to_url
end
end
end
View
@@ -1,14 +1,7 @@
-require 'rubygems'
-require 'sinatra'
+require 'amnesia'
set :run, false
set :environment, ENV['RACK_ENV']
set :raise_errors, true
-root_dir = File.dirname(__FILE__)
-$:.unshift "#{root_dir}/lib"
-$:.unshift "#{root_dir}"
-
-require 'amnesia'
-
-run Amnesia.new('amnesia.yml')
+run Amnesia.new
@@ -4,7 +4,7 @@ div.container { width: 605px; margin: 0 auto; }
h1, h2, h3 { color: #1f1f1f; }
img { display: block; }
a { color: #1f1f1f; }
-button { padding: 0; }
+button { padding: 0; background-color: white; border: 0; text-decoration: underline; }
a:hover, button:hover { color: #666; cursor: pointer; }
div#header { background-color: #e1e1e1; padding: 20px 0 10px 0; line-height: 1.3em; }
@@ -34,7 +34,7 @@ div#hosts li p { font-weight: bold; color: #1f1f1f; }
div#hosts li.inactive p { color: #ccc; }
div#hosts li.inactive p.status { font-size: 0.8em; }
-div#hosts li button { background-color: white; border: 0; text-decoration: underline; position: absolute; right: 0; top: 0; }
+div#hosts li button { position: absolute; right: 0; top: 0; }
div#main div#details { position: absolute; top: 0; left: 560px; width: 220px; }
File renamed without changes
File renamed without changes
View
@@ -1,4 +1,4 @@
-<% unless @hosts.empty? %>
+<% if !@hosts.empty? and @hosts.any?{|h| h.alive? } %>
<div id="overall">
<h2>Overview</h2>
<p class="sub"><em>For all active hosts</em></p>

0 comments on commit 73931de

Please sign in to comment.