high_voltage 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -4
- data/.travis.yml +15 -5
- data/Appraisals +7 -10
- data/CONTRIBUTING.md +4 -1
- data/Gemfile +4 -1
- data/Gemfile.lock +65 -43
- data/MIT-LICENSE +1 -1
- data/NEWS.md +18 -0
- data/README.md +86 -18
- data/Rakefile +9 -4
- data/app/controllers/concerns/high_voltage/static_page.rb +8 -11
- data/gemfiles/rails4.0.gemfile +9 -0
- data/gemfiles/rails4.1.gemfile +9 -0
- data/gemfiles/rails4.2.gemfile +9 -0
- data/gemfiles/rails50.gemfile +10 -0
- data/high_voltage.gemspec +0 -2
- data/lib/high_voltage/configuration.rb +4 -22
- data/lib/high_voltage/constraints/root_route.rb +17 -10
- data/lib/high_voltage/engine.rb +10 -3
- data/lib/high_voltage/page.rb +44 -0
- data/lib/high_voltage/page_collector.rb +23 -0
- data/lib/high_voltage/page_finder.rb +16 -2
- data/lib/high_voltage/version.rb +1 -1
- data/lib/high_voltage.rb +2 -0
- data/spec/constraints/root_route_spec.rb +23 -8
- data/spec/controllers/pages_controller_spec.rb +57 -52
- data/spec/fake_app.rb +15 -0
- data/spec/fixtures/app/views/pages/_partial.html.erb +1 -0
- data/spec/fixtures/app/views/pages/text.txt.erb +1 -0
- data/spec/fixtures/config/database.yml +3 -0
- data/spec/high_voltage/configuration_spec.rb +0 -57
- data/spec/high_voltage/page_collector_spec.rb +36 -0
- data/spec/high_voltage/page_finder_spec.rb +34 -14
- data/spec/high_voltage/page_spec.rb +65 -0
- data/spec/spec_helper.rb +21 -8
- data/spec/support/http_method_shim.rb +15 -0
- metadata +57 -127
- data/spec/controllers/action_caching_controller_spec.rb +0 -38
- data/spec/controllers/page_caching_controller_spec.rb +0 -37
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/config/application.rb +0 -43
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -25
- data/spec/dummy/config/environments/production.rb +0 -49
- data/spec/dummy/config/environments/test.rb +0 -30
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_key_base.rb +0 -1
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -191
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +0 -6
- /data/spec/{dummy → fixtures}/app/views/layouts/alternate.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/layouts/application.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other/wrong.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_dir/also_nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_dir/also_nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/dir/nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/rot13.html.erb +0 -0
- /data/spec/{dummy → fixtures}/config/routes.rb +0 -0
- /data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
- /data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
- /data/spec/{dummy → support}/app/controllers/subclassed_pages_controller.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6fe8331cf7311ae941daea7a313a66e350a5565
|
|
4
|
+
data.tar.gz: d1f5bb5ec3984ce97f167a7e4b56c9936ff1a788
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b5f88d3c1b88243befa89c0e1c8e1640b9b1556ea070dcbb7eff8bfeab51c88d6907e6746730d9318c4a276f026f45695eefc800e9aba078bc4ee48714860a8
|
|
7
|
+
data.tar.gz: 949ae450736d58557bc15ecdcd6f33098ae2ada670563b9440e8b65e7883d12154ddc170d3f42d1147133d4452ccabe7d771707eef320779113e32bdccc636a7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
1
|
+
gemfile:
|
|
2
|
+
- gemfiles/rails4.0.gemfile
|
|
3
|
+
- gemfiles/rails4.1.gemfile
|
|
4
|
+
- gemfiles/rails4.2.gemfile
|
|
3
5
|
install:
|
|
4
6
|
- 'travis_retry bundle install'
|
|
7
|
+
language:
|
|
8
|
+
- ruby
|
|
5
9
|
rvm:
|
|
6
|
-
-
|
|
7
|
-
- 2.
|
|
8
|
-
- 2.
|
|
10
|
+
- 2.0.0-p648
|
|
11
|
+
- 2.1.8
|
|
12
|
+
- 2.2.4
|
|
13
|
+
- 2.3.0
|
|
14
|
+
script: 'bundle exec rake spec'
|
|
15
|
+
notifications:
|
|
16
|
+
email: false
|
|
17
|
+
sudo: false
|
|
18
|
+
cache: bundler
|
data/Appraisals
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
rails_versions = ['~> 3.2.13', '~> 4.0.0', '~> 4.1.0']
|
|
3
|
-
else
|
|
4
|
-
rails_versions = ['~> 3.1.12', '~> 3.2.13']
|
|
5
|
-
end
|
|
1
|
+
rails_versions = ['~> 4.0.0', '~> 4.1.0', '~> 4.2.0']
|
|
6
2
|
|
|
7
3
|
rails_versions.each do |rails_version|
|
|
8
4
|
appraise "rails#{rails_version.slice(/\d+\.\d+/)}" do
|
|
9
5
|
gem 'rails', rails_version
|
|
10
|
-
|
|
11
|
-
if ['~> 4.0.0', '~> 4.1.0'].include? rails_version
|
|
12
|
-
gem 'actionpack-action_caching'
|
|
13
|
-
gem 'actionpack-page_caching'
|
|
14
|
-
end
|
|
15
6
|
end
|
|
16
7
|
end
|
|
8
|
+
|
|
9
|
+
appraise "rails50" do
|
|
10
|
+
gem "rails", "~> 5.0.0.beta3"
|
|
11
|
+
gem "rspec-rails", "3.5.0.beta1"
|
|
12
|
+
gem "rails-controller-testing"
|
|
13
|
+
end
|
data/CONTRIBUTING.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
We love pull requests.
|
|
1
|
+
We love pull requests from everyone. By participating in this project, you
|
|
2
|
+
agree to abide by the thoughtbot [code of conduct].
|
|
3
|
+
|
|
4
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
|
2
5
|
|
|
3
6
|
1. Fork the repo.
|
|
4
7
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
high_voltage (
|
|
4
|
+
high_voltage (3.0.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
|
-
remote:
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
actionpack (4.
|
|
10
|
-
actionview (= 4.
|
|
11
|
-
activesupport (= 4.
|
|
12
|
-
rack (~> 1.
|
|
9
|
+
actionpack (4.2.5.2)
|
|
10
|
+
actionview (= 4.2.5.2)
|
|
11
|
+
activesupport (= 4.2.5.2)
|
|
12
|
+
rack (~> 1.6)
|
|
13
13
|
rack-test (~> 0.6.2)
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
16
|
+
actionview (4.2.5.2)
|
|
17
|
+
activesupport (= 4.2.5.2)
|
|
16
18
|
builder (~> 3.1)
|
|
17
19
|
erubis (~> 2.7.0)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
i18n (~> 0.6, >= 0.6.9)
|
|
20
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
22
|
+
activesupport (4.2.5.2)
|
|
23
|
+
i18n (~> 0.7)
|
|
23
24
|
json (~> 1.7, >= 1.7.7)
|
|
24
25
|
minitest (~> 5.1)
|
|
25
|
-
thread_safe (~> 0.
|
|
26
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
26
27
|
tzinfo (~> 1.1)
|
|
27
|
-
appraisal (1.0.
|
|
28
|
+
appraisal (1.0.2)
|
|
28
29
|
bundler
|
|
29
30
|
rake
|
|
30
31
|
thor (>= 0.14.0)
|
|
@@ -32,39 +33,57 @@ GEM
|
|
|
32
33
|
coderay (1.1.0)
|
|
33
34
|
diff-lcs (1.2.5)
|
|
34
35
|
erubis (2.7.0)
|
|
35
|
-
i18n (0.
|
|
36
|
-
json (1.8.
|
|
36
|
+
i18n (0.7.0)
|
|
37
|
+
json (1.8.3)
|
|
38
|
+
loofah (2.0.3)
|
|
39
|
+
nokogiri (>= 1.5.9)
|
|
37
40
|
method_source (0.8.2)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
mini_portile2 (2.0.0)
|
|
42
|
+
minitest (5.8.4)
|
|
43
|
+
nokogiri (1.6.7.2)
|
|
44
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
45
|
+
pry (0.10.1)
|
|
46
|
+
coderay (~> 1.1.0)
|
|
47
|
+
method_source (~> 0.8.1)
|
|
42
48
|
slop (~> 3.4)
|
|
43
|
-
rack (1.
|
|
44
|
-
rack-test (0.6.
|
|
49
|
+
rack (1.6.4)
|
|
50
|
+
rack-test (0.6.3)
|
|
45
51
|
rack (>= 1.0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
53
|
+
activesupport (>= 4.2.0.alpha)
|
|
54
|
+
rails-dom-testing (1.0.7)
|
|
55
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
56
|
+
nokogiri (~> 1.6.0)
|
|
57
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
58
|
+
rails-html-sanitizer (1.0.3)
|
|
59
|
+
loofah (~> 2.0)
|
|
60
|
+
railties (4.2.5.2)
|
|
61
|
+
actionpack (= 4.2.5.2)
|
|
62
|
+
activesupport (= 4.2.5.2)
|
|
49
63
|
rake (>= 0.8.7)
|
|
50
64
|
thor (>= 0.18.1, < 2.0)
|
|
51
|
-
rake (10.
|
|
52
|
-
rspec-core (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
rake (10.5.0)
|
|
66
|
+
rspec-core (3.4.3)
|
|
67
|
+
rspec-support (~> 3.4.0)
|
|
68
|
+
rspec-expectations (3.4.0)
|
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
70
|
+
rspec-support (~> 3.4.0)
|
|
71
|
+
rspec-mocks (3.4.1)
|
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
73
|
+
rspec-support (~> 3.4.0)
|
|
74
|
+
rspec-rails (3.4.2)
|
|
75
|
+
actionpack (>= 3.0, < 4.3)
|
|
76
|
+
activesupport (>= 3.0, < 4.3)
|
|
77
|
+
railties (>= 3.0, < 4.3)
|
|
78
|
+
rspec-core (~> 3.4.0)
|
|
79
|
+
rspec-expectations (~> 3.4.0)
|
|
80
|
+
rspec-mocks (~> 3.4.0)
|
|
81
|
+
rspec-support (~> 3.4.0)
|
|
82
|
+
rspec-support (3.4.1)
|
|
83
|
+
slop (3.6.0)
|
|
65
84
|
thor (0.19.1)
|
|
66
|
-
thread_safe (0.3.
|
|
67
|
-
tzinfo (1.
|
|
85
|
+
thread_safe (0.3.5)
|
|
86
|
+
tzinfo (1.2.2)
|
|
68
87
|
thread_safe (~> 0.1)
|
|
69
88
|
|
|
70
89
|
PLATFORMS
|
|
@@ -75,4 +94,7 @@ DEPENDENCIES
|
|
|
75
94
|
appraisal
|
|
76
95
|
high_voltage!
|
|
77
96
|
pry
|
|
78
|
-
rspec-rails
|
|
97
|
+
rspec-rails (~> 3.2)
|
|
98
|
+
|
|
99
|
+
BUNDLED WITH
|
|
100
|
+
1.11.2
|
data/MIT-LICENSE
CHANGED
data/NEWS.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
New for 3.0.0
|
|
2
|
+
+ HighVoltage now supports Rails 5.0.0.beta3 and up.
|
|
3
|
+
+ Properly handle extensions in root route constraint requests.
|
|
4
|
+
+ Removes caching in preparation for Rails 5.
|
|
5
|
+
|
|
6
|
+
New for 2.4.0
|
|
7
|
+
+ Retrieve a list of available static pages via `HighVoltage.page_ids`.
|
|
8
|
+
+ Properly handle page ids which are blank when being sanitized.
|
|
9
|
+
+ Only provide deprecation warnings around caching when caching is enabled.
|
|
10
|
+
|
|
11
|
+
New for 2.3.0:
|
|
12
|
+
+ Ruby 2.2 and Rails 4.2 testing
|
|
13
|
+
+ Raise InvalidPageIdError when visiting a page with invalid characters
|
|
14
|
+
+ Code of Conduct added to Contributing guide
|
|
15
|
+
|
|
16
|
+
New for 2.2.1:
|
|
17
|
+
+ Resolve issue with require statements for Rails 3.x projects
|
|
18
|
+
|
|
1
19
|
New for 2.2.0:
|
|
2
20
|
+ Deprecate caching because page and action caching was removed in Rails 4
|
|
3
21
|
+ Refactor test suite to use rspec `expect` syntax consistently.
|
data/README.md
CHANGED
|
@@ -15,13 +15,9 @@ Yeah, like "About us", "Directions", marketing pages, etc.
|
|
|
15
15
|
Include in your Gemfile:
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
|
-
gem 'high_voltage', '~>
|
|
18
|
+
gem 'high_voltage', '~> 3.0.0'
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
|
|
22
|
-
|
|
23
|
-
https://github.com/thoughtbot/high_voltage/tree/v0.9.2
|
|
24
|
-
|
|
25
21
|
## Usage
|
|
26
22
|
|
|
27
23
|
Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
|
|
@@ -32,17 +28,28 @@ Write your static pages and put them in the RAILS_ROOT/app/views/pages directory
|
|
|
32
28
|
After putting something interesting there, you can link to it from anywhere in your app with:
|
|
33
29
|
|
|
34
30
|
```ruby
|
|
35
|
-
link_to 'About', page_path('about')
|
|
31
|
+
<%= link_to 'About', page_path('about') %>
|
|
36
32
|
```
|
|
37
33
|
|
|
38
34
|
You can nest pages in a directory structure, if that makes sense from a URL perspective for you:
|
|
39
35
|
|
|
40
36
|
```ruby
|
|
41
|
-
link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four')
|
|
37
|
+
<%= link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four') %>
|
|
42
38
|
```
|
|
43
39
|
|
|
44
40
|
Bam.
|
|
45
41
|
|
|
42
|
+
You can also get a list of your static pages by calling `HighVoltage.page_ids`
|
|
43
|
+
This might be useful if you need to build a sitemap. For example, if you are
|
|
44
|
+
using the [sitemap_generator](https://github.com/kjvarga/sitemap_generator) gem,
|
|
45
|
+
you could add something like this to your sitemap config file:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
HighVoltage.page_ids.each do |page|
|
|
49
|
+
add page, changefreq: 'monthly'
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
46
53
|
## Configuration
|
|
47
54
|
|
|
48
55
|
#### Routing overview
|
|
@@ -157,7 +164,7 @@ end
|
|
|
157
164
|
|
|
158
165
|
#### Caching
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
Built in caching support has been removed in HighVoltage. See [PR 221](https://github.com/thoughtbot/high_voltage/pull/221).
|
|
161
168
|
|
|
162
169
|
Page caching and action caching can be done via Rails. Visit the [Caching with
|
|
163
170
|
Rails: An overview](http://guides.rubyonrails.org/caching_with_rails.html) guide
|
|
@@ -263,6 +270,58 @@ end
|
|
|
263
270
|
Use this to create a custom file mapping, clean filenames for your file
|
|
264
271
|
system, A/B test, and so on.
|
|
265
272
|
|
|
273
|
+
## Localization
|
|
274
|
+
|
|
275
|
+
[Rails I18n guides](http://guides.rubyonrails.org/i18n.html).
|
|
276
|
+
|
|
277
|
+
Add a before filter to the Application controller
|
|
278
|
+
|
|
279
|
+
```ruby
|
|
280
|
+
# app/controllers/application_controller.rb
|
|
281
|
+
before_action :set_locale
|
|
282
|
+
|
|
283
|
+
def set_locale
|
|
284
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
|
285
|
+
end
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Disable the default High Voltage routes
|
|
289
|
+
|
|
290
|
+
```ruby
|
|
291
|
+
# config/initializers/high_voltage.rb
|
|
292
|
+
HighVoltage.configure do |config|
|
|
293
|
+
config.routes = false
|
|
294
|
+
end
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
```ruby
|
|
298
|
+
# config/routes.rb
|
|
299
|
+
scope "/:locale", locale: /en|bn|hi/ do
|
|
300
|
+
get "/pages/:id" => "high_voltage/pages#show", :as => :page, :format => false
|
|
301
|
+
end
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Add a static page to the project
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
# app/views/pages/about.html.erb
|
|
308
|
+
<%= t "hello" %>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Make sure that there are corresponding locale files
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
/config/locale/bn.yml
|
|
315
|
+
/config/locale/en.yml
|
|
316
|
+
/config/locale/hi.yml
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
One last note is there is a [know
|
|
320
|
+
issue](https://github.com/thoughtbot/high_voltage/issues/59) with High Voltage.
|
|
321
|
+
|
|
322
|
+
You'll need to specify routes like this `<%= link_to "About Us", page_path(id:
|
|
323
|
+
"about") %>`
|
|
324
|
+
|
|
266
325
|
## Testing
|
|
267
326
|
|
|
268
327
|
You can test your static pages using [RSpec](https://github.com/rspec/rspec-rails)
|
|
@@ -272,7 +331,7 @@ and [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers):
|
|
|
272
331
|
# spec/controllers/pages_controller_spec.rb
|
|
273
332
|
describe PagesController, '#show' do
|
|
274
333
|
%w(earn_money screencast about contact).each do |page|
|
|
275
|
-
context
|
|
334
|
+
context "on GET to /pages/#{page}" do
|
|
276
335
|
before do
|
|
277
336
|
get :show, id: page
|
|
278
337
|
end
|
|
@@ -291,20 +350,29 @@ Enjoy!
|
|
|
291
350
|
|
|
292
351
|
## Contributing
|
|
293
352
|
|
|
294
|
-
Please see [CONTRIBUTING.md]
|
|
295
|
-
|
|
353
|
+
Please see [CONTRIBUTING.md].
|
|
354
|
+
Thank you, [contributors]!
|
|
355
|
+
|
|
356
|
+
[CONTRIBUTING.md]: /CONTRIBUTING.md
|
|
357
|
+
[contributors]: https://github.com/thoughtbot/high_voltage/graphs/contributors
|
|
296
358
|
|
|
297
|
-
##
|
|
359
|
+
## License
|
|
298
360
|
|
|
299
|
-
|
|
361
|
+
High Voltage is copyright © 2009-2016 thoughtbot. It is free software, and may
|
|
362
|
+
be redistributed under the terms specified in the [`LICENSE`] file.
|
|
300
363
|
|
|
301
|
-
|
|
364
|
+
[`LICENSE`]: /MIT-LICENSE
|
|
302
365
|
|
|
303
|
-
|
|
366
|
+
## About thoughtbot
|
|
304
367
|
|
|
368
|
+

|
|
369
|
+
|
|
370
|
+
High Voltage is maintained and funded by thoughtbot, inc.
|
|
305
371
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
|
306
372
|
|
|
307
|
-
|
|
373
|
+
We love open source software!
|
|
374
|
+
See [our other projects][community].
|
|
375
|
+
We are [available for hire][hire].
|
|
308
376
|
|
|
309
|
-
|
|
310
|
-
|
|
377
|
+
[community]: https://thoughtbot.com/community?utm_source=github
|
|
378
|
+
[hire]: https://thoughtbot.com/hire-us?utm_source=github
|
data/Rakefile
CHANGED
|
@@ -11,9 +11,14 @@ require 'appraisal'
|
|
|
11
11
|
RSpec::Core::RakeTask.new(:spec)
|
|
12
12
|
|
|
13
13
|
desc 'Default'
|
|
14
|
-
task :default
|
|
14
|
+
task :default do
|
|
15
|
+
if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
|
|
16
|
+
Rake::Task['spec'].invoke
|
|
17
|
+
else
|
|
18
|
+
Rake::Task['appraise'].invoke
|
|
19
|
+
end
|
|
20
|
+
end
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exec 'rake appraisal spec'
|
|
22
|
+
task :appraise do
|
|
23
|
+
exec 'appraisal install && appraisal rake'
|
|
19
24
|
end
|
|
@@ -6,28 +6,25 @@ module HighVoltage::StaticPage
|
|
|
6
6
|
|
|
7
7
|
rescue_from ActionView::MissingTemplate do |exception|
|
|
8
8
|
if exception.message =~ %r{Missing template #{page_finder.content_path}}
|
|
9
|
-
|
|
9
|
+
invalid_page
|
|
10
10
|
else
|
|
11
11
|
raise exception
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
caches_action :show, layout: HighVoltage.action_caching_layout,
|
|
17
|
-
if: -> { HighVoltage.action_caching }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
if respond_to?(:caches_page)
|
|
21
|
-
caches_page :show, if: -> { HighVoltage.page_caching }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
hide_action :current_page, :page_finder, :page_finder_factory
|
|
15
|
+
rescue_from HighVoltage::InvalidPageIdError, with: :invalid_page
|
|
25
16
|
end
|
|
26
17
|
|
|
27
18
|
def show
|
|
28
19
|
render template: current_page
|
|
29
20
|
end
|
|
30
21
|
|
|
22
|
+
def invalid_page
|
|
23
|
+
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
31
28
|
def current_page
|
|
32
29
|
page_finder.find
|
|
33
30
|
end
|
data/high_voltage.gemspec
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
module HighVoltage
|
|
2
2
|
module Configuration
|
|
3
|
-
CACHING_DEPRECATION_WARNING = <<-WARNING.strip_heredoc.squish
|
|
4
|
-
Caching support has been deprecated and will be removed
|
|
5
|
-
in the next release.
|
|
6
|
-
WARNING
|
|
7
|
-
|
|
8
3
|
attr_accessor(
|
|
9
4
|
:content_path,
|
|
10
5
|
:home_page,
|
|
@@ -14,8 +9,6 @@ module HighVoltage
|
|
|
14
9
|
:routes,
|
|
15
10
|
)
|
|
16
11
|
|
|
17
|
-
attr_reader :action_caching, :action_caching_layout, :page_caching
|
|
18
|
-
|
|
19
12
|
def configure
|
|
20
13
|
yield self
|
|
21
14
|
end
|
|
@@ -24,26 +17,15 @@ module HighVoltage
|
|
|
24
17
|
base.set_default_configuration
|
|
25
18
|
end
|
|
26
19
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
@action_caching = value
|
|
20
|
+
def page_ids
|
|
21
|
+
HighVoltage::PageCollector.new(HighVoltage.full_path).page_ids
|
|
30
22
|
end
|
|
31
23
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
@action_caching_layout = value
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def page_caching=(value)
|
|
38
|
-
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
|
39
|
-
@page_caching = value
|
|
24
|
+
def full_path
|
|
25
|
+
Rails.root.join("app", "views", HighVoltage.content_path)
|
|
40
26
|
end
|
|
41
27
|
|
|
42
28
|
def set_default_configuration
|
|
43
|
-
@action_caching = false
|
|
44
|
-
@action_caching_layout = true
|
|
45
|
-
@page_caching = false
|
|
46
|
-
|
|
47
29
|
self.content_path = 'pages/'
|
|
48
30
|
self.home_page = nil
|
|
49
31
|
self.layout = 'application'
|
|
@@ -2,20 +2,27 @@ module HighVoltage
|
|
|
2
2
|
module Constraints
|
|
3
3
|
# Routing constraint to validate request.path has a corresponding view
|
|
4
4
|
class RootRoute
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
class << self
|
|
6
|
+
def matches?(request)
|
|
7
|
+
page_id = clean_page_path(request.path)
|
|
8
|
+
pattern = file_pattern(page_id)
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
Dir.glob(pattern).any?
|
|
11
|
+
end
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
private
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
def clean_page_path(request_path)
|
|
16
|
+
request_path.sub(/\.html$/, "")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def file_pattern(page_id)
|
|
20
|
+
"#{content_path}#{page_id}.html*"
|
|
21
|
+
end
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
def content_path
|
|
24
|
+
Rails.root.join("app", "views", HighVoltage.content_path).to_s
|
|
25
|
+
end
|
|
19
26
|
end
|
|
20
27
|
end
|
|
21
28
|
end
|
data/lib/high_voltage/engine.rb
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
module HighVoltage
|
|
2
2
|
class Engine < Rails::Engine
|
|
3
|
-
initializer
|
|
3
|
+
initializer "Set up default parent engine" do |app|
|
|
4
4
|
HighVoltage.parent_engine ||= Rails.application
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
initializer
|
|
8
|
-
concerns_path =
|
|
7
|
+
initializer "Require concerns path" do |app|
|
|
8
|
+
concerns_path = "app/controllers/concerns"
|
|
9
9
|
|
|
10
10
|
unless app.paths.keys.include?(concerns_path)
|
|
11
11
|
app.paths.add(concerns_path)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
initializer "Require for Rails 3" do |app|
|
|
16
|
+
if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
|
17
|
+
require "concerns/high_voltage/static_page"
|
|
18
|
+
require "high_voltage/pages_controller"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
14
21
|
end
|
|
15
22
|
end
|