about_page 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +7 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +140 -0
  5. data/LICENSE +5 -0
  6. data/README.md +21 -0
  7. data/Rakefile +8 -0
  8. data/about_page.gemspec +25 -0
  9. data/app/assets/javascripts/about_page.js +7 -0
  10. data/app/assets/stylesheets/about_page.scss +16 -0
  11. data/app/controllers/about_page/about_controller.rb +19 -0
  12. data/app/helpers/about_page/about_helper.rb +19 -0
  13. data/app/views/about_page/about/_app.html.erb +1 -0
  14. data/app/views/about_page/about/_dependencies.html.erb +9 -0
  15. data/app/views/about_page/about/_dependency_tree.html.erb +10 -0
  16. data/app/views/about_page/about/_environment.html.erb +11 -0
  17. data/app/views/about_page/about/_exception.html.erb +2 -0
  18. data/app/views/about_page/about/_generic_hash.html.erb +6 -0
  19. data/app/views/about_page/about/index.html.erb +8 -0
  20. data/config/routes.rb +3 -0
  21. data/lib/about_page.rb +22 -0
  22. data/lib/about_page/configuration.rb +69 -0
  23. data/lib/about_page/dependencies.rb +33 -0
  24. data/lib/about_page/engine.rb +4 -0
  25. data/lib/about_page/environment.rb +38 -0
  26. data/lib/about_page/fedora.rb +15 -0
  27. data/lib/about_page/request_environment.rb +14 -0
  28. data/lib/about_page/solr.rb +41 -0
  29. data/lib/about_page/version.rb +3 -0
  30. data/lib/generators/about_page/about_page_generator.rb +13 -0
  31. data/lib/generators/about_page/templates/about_page.rb +14 -0
  32. data/lib/tasks/about_page_tasks.rake +4 -0
  33. data/script/rails +8 -0
  34. data/spec/dummy/README.rdoc +261 -0
  35. data/spec/dummy/Rakefile +7 -0
  36. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/mailers/.gitkeep +0 -0
  41. data/spec/dummy/app/models/.gitkeep +0 -0
  42. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/config/application.rb +56 -0
  45. data/spec/dummy/config/boot.rb +10 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +37 -0
  49. data/spec/dummy/config/environments/production.rb +67 -0
  50. data/spec/dummy/config/environments/test.rb +37 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/inflections.rb +15 -0
  53. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  54. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  55. data/spec/dummy/config/initializers/session_store.rb +8 -0
  56. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  57. data/spec/dummy/config/locales/en.yml +5 -0
  58. data/spec/dummy/config/routes.rb +4 -0
  59. data/spec/dummy/db/.gitkeep +0 -0
  60. data/spec/dummy/db/schema.rb +16 -0
  61. data/spec/dummy/lib/assets/.gitkeep +0 -0
  62. data/spec/dummy/log/.gitkeep +0 -0
  63. data/spec/dummy/public/404.html +26 -0
  64. data/spec/dummy/public/422.html +26 -0
  65. data/spec/dummy/public/500.html +25 -0
  66. data/spec/dummy/public/favicon.ico +0 -0
  67. data/spec/dummy/script/rails +6 -0
  68. data/spec/integration/about_page_spec.rb +61 -0
  69. data/spec/lib/about_page_configuration.rb +8 -0
  70. data/spec/lib/configuration_environment_spec.rb +13 -0
  71. data/spec/lib/solr_spec.rb +80 -0
  72. data/spec/spec_helper.rb +23 -0
  73. metadata +246 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ spec/dummy/db/*.sqlite3
5
+ spec/dummy/log/*.log
6
+ spec/dummy/tmp/
7
+ spec/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in about_page.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ gem "jquery-rails"
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use debugger
17
+ # gem 'ruby-debug'
18
+ gem 'sqlite3'
data/Gemfile.lock ADDED
@@ -0,0 +1,140 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ about_page (0.0.1)
5
+ rails (~> 3.2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.3)
11
+ actionpack (= 3.2.3)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.3)
14
+ activemodel (= 3.2.3)
15
+ activesupport (= 3.2.3)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.1)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.2)
23
+ activemodel (3.2.3)
24
+ activesupport (= 3.2.3)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.3)
27
+ activemodel (= 3.2.3)
28
+ activesupport (= 3.2.3)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.3)
32
+ activemodel (= 3.2.3)
33
+ activesupport (= 3.2.3)
34
+ activesupport (3.2.3)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ addressable (2.2.7)
38
+ arel (3.0.2)
39
+ builder (3.0.0)
40
+ capybara (1.1.2)
41
+ mime-types (>= 1.16)
42
+ nokogiri (>= 1.3.3)
43
+ rack (>= 1.0.0)
44
+ rack-test (>= 0.5.4)
45
+ selenium-webdriver (~> 2.0)
46
+ xpath (~> 0.1.4)
47
+ childprocess (0.3.2)
48
+ ffi (~> 1.0.6)
49
+ diff-lcs (1.1.3)
50
+ erubis (2.7.0)
51
+ ffi (1.0.11)
52
+ hike (1.2.1)
53
+ i18n (0.6.0)
54
+ journey (1.0.3)
55
+ jquery-rails (2.0.2)
56
+ railties (>= 3.2.0, < 5.0)
57
+ thor (~> 0.14)
58
+ json (1.6.6)
59
+ launchy (2.1.0)
60
+ addressable (~> 2.2.6)
61
+ libwebsocket (0.1.3)
62
+ addressable
63
+ mail (2.4.4)
64
+ i18n (>= 0.4.0)
65
+ mime-types (~> 1.16)
66
+ treetop (~> 1.4.8)
67
+ mime-types (1.18)
68
+ multi_json (1.3.2)
69
+ nokogiri (1.5.2)
70
+ polyglot (0.3.3)
71
+ rack (1.4.1)
72
+ rack-cache (1.2)
73
+ rack (>= 0.4)
74
+ rack-ssl (1.3.2)
75
+ rack
76
+ rack-test (0.6.1)
77
+ rack (>= 1.0)
78
+ rails (3.2.3)
79
+ actionmailer (= 3.2.3)
80
+ actionpack (= 3.2.3)
81
+ activerecord (= 3.2.3)
82
+ activeresource (= 3.2.3)
83
+ activesupport (= 3.2.3)
84
+ bundler (~> 1.0)
85
+ railties (= 3.2.3)
86
+ railties (3.2.3)
87
+ actionpack (= 3.2.3)
88
+ activesupport (= 3.2.3)
89
+ rack-ssl (~> 1.3.2)
90
+ rake (>= 0.8.7)
91
+ rdoc (~> 3.4)
92
+ thor (~> 0.14.6)
93
+ rake (0.9.2.2)
94
+ rdoc (3.12)
95
+ json (~> 1.4)
96
+ rspec (2.9.0)
97
+ rspec-core (~> 2.9.0)
98
+ rspec-expectations (~> 2.9.0)
99
+ rspec-mocks (~> 2.9.0)
100
+ rspec-core (2.9.0)
101
+ rspec-expectations (2.9.1)
102
+ diff-lcs (~> 1.1.3)
103
+ rspec-mocks (2.9.0)
104
+ rspec-rails (2.9.0)
105
+ actionpack (>= 3.0)
106
+ activesupport (>= 3.0)
107
+ railties (>= 3.0)
108
+ rspec (~> 2.9.0)
109
+ rubyzip (0.9.7)
110
+ selenium-webdriver (2.21.2)
111
+ childprocess (>= 0.2.5)
112
+ ffi (~> 1.0)
113
+ libwebsocket (~> 0.1.3)
114
+ multi_json (~> 1.0)
115
+ rubyzip
116
+ sprockets (2.1.2)
117
+ hike (~> 1.2)
118
+ rack (~> 1.0)
119
+ tilt (~> 1.1, != 1.3.0)
120
+ sqlite3 (1.3.6)
121
+ thor (0.14.6)
122
+ tilt (1.3.3)
123
+ treetop (1.4.10)
124
+ polyglot
125
+ polyglot (>= 0.3.1)
126
+ tzinfo (0.3.33)
127
+ xpath (0.1.4)
128
+ nokogiri (~> 1.3)
129
+
130
+ PLATFORMS
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ about_page!
135
+ capybara
136
+ jquery-rails
137
+ launchy
138
+ rspec
139
+ rspec-rails
140
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2012. The Board of Trustees of the Leland Stanford Junior University. All rights reserved.
2
+
3
+ Redistribution and use of this distribution in source and binary forms, with or without modification, are permitted provided that: The above copyright notice and this permission notice appear in all copies and supporting documentation; The name, identifiers, and trademarks of The Board of Trustees of the Leland Stanford Junior University are not used in advertising or publicity without the express prior written permission of The Board of Trustees of the Leland Stanford Junior University; Recipients acknowledge that this distribution is made available as a research courtesy, "as is", potentially with defects, without any obligation on the part of The Board of Trustees of the Leland Stanford Junior University to provide support, services, or repair;
4
+
5
+ THE BOARD OF TRUSTEES OF THE LELAND STANFORD JUNIOR UNIVERSITY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE BOARD OF TRUSTEES OF THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # AboutPage
2
+
3
+ To use in a Hydra app:
4
+
5
+ # In Gemfile
6
+ gem 'about_page', :git => 'git://github.com/sul-dlss/about_page.git'
7
+
8
+ # In config/initializers/about_page.rb
9
+ AboutPage.configure do |config|
10
+ config.app_name = MyApplication.name # Application Name
11
+ config.app_version = MyApplication::VERSION # Application Version
12
+ config.fedora = AboutPage::Fedora.new(ActiveFedora::Base.connection_for_pid(0)) # Rubydora::Repository instance
13
+ config.solr = AboutPage::Solr.new(ActiveFedora.solr) # RSolr instance
14
+ end
15
+
16
+ # In config/routes.rb
17
+ mount AboutPage::Engine => '/about(.:format)' # Or whever you want to access the about page
18
+
19
+ ## Known Issues
20
+
21
+ * Solr must have LukeHandler enabled on /luke
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "about_page/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "about_page"
9
+ s.version = AboutPage::VERSION
10
+ s.authors = ["Michael B. Klein", "Chris Beer"]
11
+ s.email = ["mbklein@stanford.edu", "cabeer@stanford.edu"]
12
+ s.homepage = "http://github.com/sul-dlss/about_page"
13
+ s.summary = "Summary of AboutPage."
14
+ s.description = "Description of AboutPage."
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+
19
+ s.add_dependency "rails", "~> 3.2"
20
+ s.add_development_dependency "rspec"
21
+ s.add_development_dependency "rspec-rails"
22
+ s.add_development_dependency "capybara"
23
+ s.add_development_dependency "launchy"
24
+ # s.add_dependency "jquery-rails"
25
+ end
@@ -0,0 +1,7 @@
1
+ $(function() {
2
+ $('.about_page .pane-dependencies .dependency.group ul ul').each(function() {
3
+ var that = $(this);
4
+ that.prev('b').click(function() { that.toggle(5); });
5
+ that.hide();
6
+ });
7
+ });
@@ -0,0 +1,16 @@
1
+ .about_page .pane-dependencies .dependencies {
2
+ -moz-column-count:3; /* Firefox */
3
+ -webkit-column-count:3; /* Safari and Chrome */
4
+ column-count:3;
5
+ }
6
+
7
+ .about_page .pane.not-ok {
8
+ border: 3px solid #f00;
9
+ background-color: rgba(255,0,0,0.5);
10
+ margin-left: -1em;
11
+ padding-left: 1em;
12
+ margin-right: -1em;
13
+ padding-right: 1em;
14
+ padding-top: 1em;
15
+ padding-bottom: 1em;
16
+ }
@@ -0,0 +1,19 @@
1
+ module AboutPage
2
+ class AboutController < ApplicationController
3
+ before_filter :only => :index do
4
+ AboutPage.configuration.preflight(request)
5
+ end
6
+
7
+ def index
8
+ @configuration = AboutPage.configuration
9
+
10
+ AboutPage.configuration.set_headers!(response)
11
+
12
+ respond_to do |format|
13
+ format.html { render :status => @configuration.ok? ? 200 : 417 } # about_page.html.erb
14
+ format.json { render :json => @configuration.to_json }
15
+ format.xml { render :xml => @configuration.to_xml }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module AboutPage
2
+ module AboutHelper
3
+ def render_about_pane key, profile
4
+ render :partial => partial_for_about_key(key), :locals => { :key => key, :profile => profile }
5
+ rescue
6
+ render :partial => 'exception', :locals => { :key => key, :profile => profile, :exception => $! }
7
+ end
8
+
9
+ def partial_for_about_key key
10
+ about_page_partials[key] || key.to_s
11
+ end
12
+
13
+ private
14
+
15
+ def about_page_partials
16
+ { :solr => 'generic_hash', :fedora => 'generic_hash', :request => 'environment' }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ <h1><%= profile[:name]%> (<%= profile[:version] %>)</h1>
@@ -0,0 +1,9 @@
1
+ <h1>Dependency Versions</h1>
2
+ <div class="dependencies">
3
+ <ul>
4
+ <% profile.each_pair do |group,deps| %>
5
+ <li class="dependency group"><%= group %><%= render :partial => 'dependency_tree', :locals => { :graph => deps } %></li>
6
+ <% end %>
7
+ </ul>
8
+ </div>
9
+
@@ -0,0 +1,10 @@
1
+ <ul class="dependency">
2
+ <% graph.keys.sort.each do |name| spec = graph[name] %>
3
+ <li class="dependency">
4
+ <b><%= name %></b> (<%= spec[:version] %>)
5
+ <% if spec[:dependencies] %>
6
+ <%= render :partial => 'dependency_tree', :locals => { :graph => spec[:dependencies] }%>
7
+ <% end %>
8
+ </li>
9
+ <% end %>
10
+ </ul>
@@ -0,0 +1,11 @@
1
+ <h1><%= key.to_s.humanize %></h1>
2
+ <% profile.each_pair do |section,env| %>
3
+ <h3><%= section %></h3>
4
+ <div class="environment">
5
+ <ul>
6
+ <% env.keys.sort.each do |key| %>
7
+ <li><%= [key,env[key]].join('=') %></li>
8
+ <% end %>
9
+ </ul>
10
+ </div>
11
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <h1><%= key %></h1>
2
+ <%= exception %>
@@ -0,0 +1,6 @@
1
+ <h1><%= key.to_s.humanize %></h1>
2
+ <ul>
3
+ <% profile.each_pair do |k,v| %>
4
+ <li><%= [k,v].join(': ') %></li>
5
+ <% end %>
6
+ </ul>
@@ -0,0 +1,8 @@
1
+ <div class="about_page">
2
+ <% @configuration.each do |key, profile| %>
3
+ <div class="pane pane-<%= key.to_s.parameterize %> <%= 'not-ok' if profile.respond_to? :ok? and !profile.ok? %>">
4
+ <%= render_about_pane(key, profile) %>
5
+ </div>
6
+ <% end %>
7
+ </div>
8
+
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ AboutPage::Engine.routes.draw do
2
+ root :to => 'about_page/about#index'
3
+ end
data/lib/about_page.rb ADDED
@@ -0,0 +1,22 @@
1
+ require "about_page/engine"
2
+ require "about_page/configuration"
3
+ require "about_page/dependencies"
4
+ require "about_page/environment"
5
+ require "about_page/request_environment"
6
+
7
+ module AboutPage
8
+ autoload :Fedora, "about_page/fedora"
9
+ autoload :Solr, "about_page/solr"
10
+
11
+ def self.configure
12
+ yield(self.configuration)
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.reset!
20
+ @configuration = nil
21
+ end
22
+ end
@@ -0,0 +1,69 @@
1
+ require 'ostruct'
2
+
3
+ module AboutPage
4
+
5
+ class OpenStructWithHashAccess < OpenStruct
6
+ delegate :each, :map, :to => :to_h
7
+ def to_json(options = {})
8
+ Hash[*@table.map { |k, v| [k, (v.to_h if v.respond_to? :to_h || v) ] }.flatten ]
9
+ end
10
+
11
+ def to_xml(options = {})
12
+ @table
13
+ end
14
+
15
+ def to_h
16
+ @table
17
+ end
18
+ end
19
+
20
+ class Configuration
21
+ attr_accessor :hash
22
+ delegate :to_xml, :to_h, :to_json, :to => :hash
23
+ delegate :each, :map, :to => :to_h
24
+
25
+ def initialize
26
+ @hash = OpenStructWithHashAccess.new
27
+ end
28
+
29
+ def method_missing *args
30
+ @hash.send(*args)
31
+ end
32
+
33
+ def preflight request
34
+ self.nodes.each { |key, profile| profile.preflight(request) }
35
+ end
36
+
37
+ def ok?
38
+ self.nodes.select { |key, profile| profile.respond_to? :ok? }.all? { |key, profile| profile.ok? }
39
+ end
40
+
41
+ def nodes
42
+ self.to_h.select { |key, profile| profile.is_a? AboutPage::Configuration::Node }
43
+ end
44
+
45
+ def set_headers! response
46
+ self.nodes.each { |key, profile| profile.set_headers! response }
47
+ end
48
+
49
+ class Node
50
+ def preflight request
51
+
52
+ end
53
+
54
+ def set_headers! response
55
+
56
+ end
57
+
58
+ def add_header response, text
59
+ response.headers['X-AboutPage-Warning'] ||= ""
60
+ response.headers['X-AboutPage-Warning'] += "#{text};"
61
+
62
+ end
63
+
64
+ def ok?
65
+ true
66
+ end
67
+ end
68
+ end
69
+ end