chameleon 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -28
- data/app/controllers/widgets_controller.rb +8 -2
- data/app/models/widget.rb +5 -0
- data/app/views/widgets/line.xml.erb +15 -0
- data/app/views/widgets/number_and_secondary.xml.erb +2 -2
- data/app/views/widgets/pie.xml.erb +10 -0
- metadata +7 -48
- data/test/chameleon_test.rb +0 -7
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/widgets/test_widget.rb +0 -7
- data/test/dummy/app/widgets/test_widget2.rb +0 -8
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -45
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -22
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -26
- data/test/dummy/config/environments/production.rb +0 -49
- data/test/dummy/config/environments/test.rb +0 -35
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -2
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/log/test.log +0 -334
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -175
- data/test/dummy/script/rails +0 -6
- data/test/functional/widgets_test.rb +0 -31
- data/test/integration/navigation_test.rb +0 -7
- data/test/support/integration_case.rb +0 -5
- data/test/test_helper.rb +0 -22
- data/test/unit/widget_test.rb +0 -13
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ This only works for Rails 3 apps.
|
|
12
12
|
|
13
13
|
This provides a generator to build widgets using a basic DSL syntax to describe the data to be exposed, and the settings for it to be exposed under, and also includes the controller/routing necessary to provide an endpoint for Geckoboard to retrieve the data to display on your dashboard.
|
14
14
|
|
15
|
-
Currently it supports
|
15
|
+
Currently it supports the "number and optional secondary stat", "line" and "pie" widget types.
|
16
16
|
|
17
17
|
== SYNOPSIS:
|
18
18
|
|
@@ -37,42 +37,22 @@ This will generate something similar to the following in "app/widgets/users_widg
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
To implement your widget, you simply need to alter it to return the required data - for a "number_and_secondary" type of widget, it requires
|
40
|
+
To implement your widget, you simply need to alter it to return the required data - for a "number_and_secondary" type of widget, it requires a hash containing a :value, and optionally, a :previous value to compare it to (such as user count as of yesterday, for example):
|
41
41
|
|
42
42
|
widget :users do
|
43
43
|
key "3618c90ec02d5a57061ad7b78afcbb050e50b608"
|
44
44
|
type "number_and_secondary"
|
45
45
|
data do
|
46
|
-
|
46
|
+
{
|
47
|
+
:value => User.count,
|
48
|
+
:previous => User.count(:conditions => "created_at < '#{1.day.ago.to_s(:db)}'")
|
49
|
+
}
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
You can then point Geckoboard at your widget, http://myapp/widgets/users?key=3618c90ec02d5a57061ad7b78afcbb050e50b608, and Geckoboard will then show the current user count, as well as the percentage difference compared to a day ago.
|
53
|
+
You can then point Geckoboard at your widget, http://myapp/widgets/users?key=3618c90ec02d5a57061ad7b78afcbb050e50b608, and Geckoboard will then show the current user count, as well as the percentage difference compared to a day ago.
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
widget :users do
|
55
|
-
key "my_updated_key"
|
56
|
-
key_parameter :token
|
57
|
-
type "number_and_secondary"
|
58
|
-
data do
|
59
|
-
[User.count, User.count(:conditions => "created_at < '#{1.day.ago.to_s(:db)}'")]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
This will now expect the key to be passed in as the :token parameter, for example http://myapp/widgets/users?token=my_updated_key. For data that is acceptable to be publically exposed, you can exclude the key and set the widget as public as follows:
|
64
|
-
|
65
|
-
widget :users do
|
66
|
-
public true
|
67
|
-
type "number_and_secondary"
|
68
|
-
data do
|
69
|
-
[User.count, User.count(:conditions => "created_at < '#{1.day.ago.to_s(:db)}'")]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
This will now be accessible simply at http://myapp/widgets/users.
|
74
|
-
|
75
|
-
Full documentation on the different widget types and data will follow once the other widget types are implemented, but this basic syntax should provide an easy way to expose data from your Rails 3 application to Geckoboard quickly and easily.
|
55
|
+
More documentation on the settings available for the widgets, as well as the different types of widgets, is available on the wiki (http://github.com/ejdraper/chameleon/wiki).
|
76
56
|
|
77
57
|
== REQUIREMENTS:
|
78
58
|
|
@@ -4,7 +4,7 @@ class WidgetsController < ApplicationController
|
|
4
4
|
skip_before_filter :verify_authenticity_token
|
5
5
|
|
6
6
|
def show
|
7
|
-
@data = @widget.data.call
|
7
|
+
@data = @widget.data.call(@auth)
|
8
8
|
render "#{@widget.type}.xml"
|
9
9
|
end
|
10
10
|
|
@@ -15,6 +15,12 @@ class WidgetsController < ApplicationController
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def validate_key
|
18
|
-
|
18
|
+
return if @widget.public
|
19
|
+
if @widget.auth
|
20
|
+
@auth = @widget.auth.call(self, request, params)
|
21
|
+
raise "Invalid authentication!" if !@auth
|
22
|
+
else
|
23
|
+
raise "Invalid key!" if params[@widget.key_parameter] != @widget.key
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
data/app/models/widget.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<root>
|
3
|
+
<% @data[:items].each do |item| %>
|
4
|
+
<item><%= item %></item>
|
5
|
+
<% end %>
|
6
|
+
<settings>
|
7
|
+
<% @data[:x_axis].each do |x| %>
|
8
|
+
<axisx><%= x %></axisx>
|
9
|
+
<% end %>
|
10
|
+
<% @data[:y_axis].each do |y| %>
|
11
|
+
<axisy><%= y %></axisy>
|
12
|
+
<% end %>
|
13
|
+
<colour><%= @data[:colour] || "ff9900" %></colour>
|
14
|
+
</settings>
|
15
|
+
</root>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<root>
|
3
3
|
<item>
|
4
|
-
<value><%= @data
|
4
|
+
<value><%= @data[:value] %></value>
|
5
5
|
<text></text>
|
6
6
|
</item>
|
7
7
|
<item>
|
8
|
-
<value><%= @data
|
8
|
+
<value><%= @data[:previous] %></value>
|
9
9
|
<text></text>
|
10
10
|
</item>
|
11
11
|
</root>
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Elliott Draper
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-04 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -45,51 +45,10 @@ files:
|
|
45
45
|
- README.rdoc
|
46
46
|
- app/controllers/widgets_controller.rb
|
47
47
|
- app/models/widget.rb
|
48
|
+
- app/views/widgets/line.xml.erb
|
48
49
|
- app/views/widgets/number_and_secondary.xml.erb
|
50
|
+
- app/views/widgets/pie.xml.erb
|
49
51
|
- config/routes.rb
|
50
|
-
- test/chameleon_test.rb
|
51
|
-
- test/dummy/app/controllers/application_controller.rb
|
52
|
-
- test/dummy/app/helpers/application_helper.rb
|
53
|
-
- test/dummy/app/views/layouts/application.html.erb
|
54
|
-
- test/dummy/app/widgets/test_widget.rb
|
55
|
-
- test/dummy/app/widgets/test_widget2.rb
|
56
|
-
- test/dummy/config/application.rb
|
57
|
-
- test/dummy/config/boot.rb
|
58
|
-
- test/dummy/config/database.yml
|
59
|
-
- test/dummy/config/environment.rb
|
60
|
-
- test/dummy/config/environments/development.rb
|
61
|
-
- test/dummy/config/environments/production.rb
|
62
|
-
- test/dummy/config/environments/test.rb
|
63
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
64
|
-
- test/dummy/config/initializers/inflections.rb
|
65
|
-
- test/dummy/config/initializers/mime_types.rb
|
66
|
-
- test/dummy/config/initializers/secret_token.rb
|
67
|
-
- test/dummy/config/initializers/session_store.rb
|
68
|
-
- test/dummy/config/locales/en.yml
|
69
|
-
- test/dummy/config/routes.rb
|
70
|
-
- test/dummy/config.ru
|
71
|
-
- test/dummy/db/test.sqlite3
|
72
|
-
- test/dummy/log/development.log
|
73
|
-
- test/dummy/log/production.log
|
74
|
-
- test/dummy/log/server.log
|
75
|
-
- test/dummy/log/test.log
|
76
|
-
- test/dummy/public/404.html
|
77
|
-
- test/dummy/public/422.html
|
78
|
-
- test/dummy/public/500.html
|
79
|
-
- test/dummy/public/favicon.ico
|
80
|
-
- test/dummy/public/javascripts/application.js
|
81
|
-
- test/dummy/public/javascripts/controls.js
|
82
|
-
- test/dummy/public/javascripts/dragdrop.js
|
83
|
-
- test/dummy/public/javascripts/effects.js
|
84
|
-
- test/dummy/public/javascripts/prototype.js
|
85
|
-
- test/dummy/public/javascripts/rails.js
|
86
|
-
- test/dummy/Rakefile
|
87
|
-
- test/dummy/script/rails
|
88
|
-
- test/functional/widgets_test.rb
|
89
|
-
- test/integration/navigation_test.rb
|
90
|
-
- test/support/integration_case.rb
|
91
|
-
- test/test_helper.rb
|
92
|
-
- test/unit/widget_test.rb
|
93
52
|
- lib/chameleon.rb
|
94
53
|
- lib/generators/chameleon/widget_generator.rb
|
95
54
|
has_rdoc: true
|
@@ -107,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
66
|
requirements:
|
108
67
|
- - ">="
|
109
68
|
- !ruby/object:Gem::Version
|
110
|
-
hash:
|
69
|
+
hash: 2842150292622897971
|
111
70
|
segments:
|
112
71
|
- 0
|
113
72
|
version: "0"
|
@@ -116,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
75
|
requirements:
|
117
76
|
- - ">="
|
118
77
|
- !ruby/object:Gem::Version
|
119
|
-
hash:
|
78
|
+
hash: 2842150292622897971
|
120
79
|
segments:
|
121
80
|
- 0
|
122
81
|
version: "0"
|
data/test/chameleon_test.rb
DELETED
data/test/dummy/Rakefile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
require File.expand_path('../config/application', __FILE__)
|
5
|
-
require 'rake'
|
6
|
-
|
7
|
-
Dummy::Application.load_tasks
|
data/test/dummy/config.ru
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require "active_model/railtie"
|
4
|
-
require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
require "action_view/railtie"
|
7
|
-
require "action_mailer/railtie"
|
8
|
-
|
9
|
-
Bundler.require
|
10
|
-
require "chameleon"
|
11
|
-
|
12
|
-
module Dummy
|
13
|
-
class Application < Rails::Application
|
14
|
-
# Settings in config/environments/* take precedence over those specified here.
|
15
|
-
# Application configuration should go into files in config/initializers
|
16
|
-
# -- all .rb files in that directory are automatically loaded.
|
17
|
-
|
18
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
-
|
21
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
-
|
25
|
-
# Activate observers that should always be running.
|
26
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
-
|
28
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
-
|
32
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
-
# config.i18n.default_locale = :de
|
35
|
-
|
36
|
-
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
-
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
-
|
39
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
-
config.encoding = "utf-8"
|
41
|
-
|
42
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
-
config.filter_parameters += [:password]
|
44
|
-
end
|
45
|
-
end
|
data/test/dummy/config/boot.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
-
development:
|
4
|
-
adapter: sqlite3
|
5
|
-
database: db/development.sqlite3
|
6
|
-
pool: 5
|
7
|
-
timeout: 5000
|
8
|
-
|
9
|
-
# Warning: The database defined as "test" will be erased and
|
10
|
-
# re-generated from your development database when you run "rake".
|
11
|
-
# Do not set this db to the same as development or production.
|
12
|
-
test:
|
13
|
-
adapter: sqlite3
|
14
|
-
database: db/test.sqlite3
|
15
|
-
pool: 5
|
16
|
-
timeout: 5000
|
17
|
-
|
18
|
-
production:
|
19
|
-
adapter: sqlite3
|
20
|
-
database: db/production.sqlite3
|
21
|
-
pool: 5
|
22
|
-
timeout: 5000
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the webserver when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
|
-
# Show full error reports and disable caching
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
|
-
config.action_controller.perform_caching = false
|
16
|
-
|
17
|
-
# Don't care if the mailer can't send
|
18
|
-
config.action_mailer.raise_delivery_errors = false
|
19
|
-
|
20
|
-
# Print deprecation notices to the Rails logger
|
21
|
-
config.active_support.deprecation = :log
|
22
|
-
|
23
|
-
# Only use best-standards-support built into browsers
|
24
|
-
config.action_dispatch.best_standards_support = :builtin
|
25
|
-
end
|
26
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# The production environment is meant for finished, "live" apps.
|
5
|
-
# Code is not reloaded between requests
|
6
|
-
config.cache_classes = true
|
7
|
-
|
8
|
-
# Full error reports are disabled and caching is turned on
|
9
|
-
config.consider_all_requests_local = false
|
10
|
-
config.action_controller.perform_caching = true
|
11
|
-
|
12
|
-
# Specifies the header that your server uses for sending files
|
13
|
-
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
-
|
15
|
-
# For nginx:
|
16
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
-
|
18
|
-
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
-
# just comment this out and Rails will serve the files
|
20
|
-
|
21
|
-
# See everything in the log (default is :info)
|
22
|
-
# config.log_level = :debug
|
23
|
-
|
24
|
-
# Use a different logger for distributed setups
|
25
|
-
# config.logger = SyslogLogger.new
|
26
|
-
|
27
|
-
# Use a different cache store in production
|
28
|
-
# config.cache_store = :mem_cache_store
|
29
|
-
|
30
|
-
# Disable Rails's static asset server
|
31
|
-
# In production, Apache or nginx will already do this
|
32
|
-
config.serve_static_assets = false
|
33
|
-
|
34
|
-
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
-
|
37
|
-
# Disable delivery errors, bad email addresses will be ignored
|
38
|
-
# config.action_mailer.raise_delivery_errors = false
|
39
|
-
|
40
|
-
# Enable threaded mode
|
41
|
-
# config.threadsafe!
|
42
|
-
|
43
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
-
# the I18n.default_locale when a translation can not be found)
|
45
|
-
config.i18n.fallbacks = true
|
46
|
-
|
47
|
-
# Send deprecation notices to registered listeners
|
48
|
-
config.active_support.deprecation = :notify
|
49
|
-
end
|