high_voltage 0.9.3 → 1.0.1
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.
- data/{README.rdoc → README.md} +55 -14
- data/app/controllers/high_voltage/pages_controller.rb +12 -5
- data/config/routes.rb +1 -1
- metadata +25 -42
data/{README.rdoc → README.md}
RENAMED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
# High Voltage [](http://travis-ci.org/thoughtbot/high_voltage)
|
|
2
2
|
|
|
3
3
|
Rails engine for static pages.
|
|
4
4
|
|
|
5
5
|
... but be careful. [Danger!](http://www.youtube.com/watch?v=HD5tnb2RBYg)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Static pages?
|
|
8
|
+
-------------
|
|
8
9
|
|
|
9
10
|
Yeah, like "About us", "Directions", marketing pages, etc.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Installation
|
|
13
|
+
------------
|
|
12
14
|
|
|
13
15
|
$ gem install high_voltage
|
|
14
16
|
|
|
@@ -16,15 +18,17 @@ Include in your Gemfile:
|
|
|
16
18
|
|
|
17
19
|
gem "high_voltage"
|
|
18
20
|
|
|
19
|
-
For Rails versions prior to 3.0, use the
|
|
20
|
-
https://github.com/thoughtbot/high_voltage/tree/rails2
|
|
21
|
+
For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
https://github.com/thoughtbot/high_voltage/tree/v0.9.2
|
|
24
|
+
|
|
25
|
+
Usage
|
|
26
|
+
-----
|
|
23
27
|
|
|
24
28
|
Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
|
|
25
29
|
|
|
26
|
-
mkdir app/views/pages
|
|
27
|
-
touch app/views/pages/about.html.erb
|
|
30
|
+
$ mkdir app/views/pages
|
|
31
|
+
$ touch app/views/pages/about.html.erb
|
|
28
32
|
|
|
29
33
|
After putting something interesting there, you can link to it from anywhere in your app with:
|
|
30
34
|
|
|
@@ -34,9 +38,14 @@ This will also work, if you like the more explicit style:
|
|
|
34
38
|
|
|
35
39
|
link_to "About", page_path(:id => "about")
|
|
36
40
|
|
|
41
|
+
You can nest pages in a directory structure, if that makes sense from a URL perspective for you:
|
|
42
|
+
|
|
43
|
+
link_to "Q4 Reports", page_path("about/corporate/policies/HR/en_US/biz/sales/Quarter-Four")
|
|
44
|
+
|
|
37
45
|
Bam.
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
Routes
|
|
48
|
+
------
|
|
40
49
|
|
|
41
50
|
By default, the static page routes will be like /pages/:id (where :id is the view filename).
|
|
42
51
|
|
|
@@ -48,13 +57,22 @@ In that case, you'd need an app/views/pages/home.html.erb file.
|
|
|
48
57
|
|
|
49
58
|
Generally speaking, you need to route to the 'show' action with an :id param of the view filename.
|
|
50
59
|
|
|
60
|
+
High Voltage will generate a named route method of `page_path` which you can use, as well. If you
|
|
61
|
+
want to generate a named route (with the :as routing option) for some route which will be handled
|
|
62
|
+
by High Voltage, make sure not to use :page as the name, because that will conflict with the named
|
|
63
|
+
route generated by High Voltage itself. For example, this will work for top-level routes (we will
|
|
64
|
+
get a named route called `static_path` which does not conflict with the generated `page_path` method):
|
|
65
|
+
|
|
66
|
+
match '/:id' => 'high_voltage/pages#show', :as => :static, :via => :get
|
|
67
|
+
|
|
51
68
|
You can route the root url to a high voltage page like this:
|
|
52
69
|
|
|
53
70
|
root :to => 'high_voltage/pages#show', :id => 'home'
|
|
54
71
|
|
|
55
72
|
Which will render a homepage from app/views/pages/home.html.erb
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
Override
|
|
75
|
+
--------
|
|
58
76
|
|
|
59
77
|
Most common reasons to override?
|
|
60
78
|
|
|
@@ -63,7 +81,12 @@ Most common reasons to override?
|
|
|
63
81
|
|
|
64
82
|
Create a PagesController of your own:
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
$ rails generate controller pages
|
|
85
|
+
|
|
86
|
+
Override the default route:
|
|
87
|
+
|
|
88
|
+
# in config/routes.rb
|
|
89
|
+
resources :pages
|
|
67
90
|
|
|
68
91
|
Then modify it to subclass from High Voltage, adding whatever you need:
|
|
69
92
|
|
|
@@ -82,7 +105,8 @@ Then modify it to subclass from High Voltage, adding whatever you need:
|
|
|
82
105
|
end
|
|
83
106
|
end
|
|
84
107
|
|
|
85
|
-
|
|
108
|
+
Testing
|
|
109
|
+
-------
|
|
86
110
|
|
|
87
111
|
Just a suggestion, but you can test your pages using Shoulda pretty easily:
|
|
88
112
|
|
|
@@ -103,6 +127,23 @@ If you're not using a custom PagesController be sure to test <code>HighVoltage::
|
|
|
103
127
|
|
|
104
128
|
Enjoy!
|
|
105
129
|
|
|
106
|
-
|
|
130
|
+
Contributing
|
|
131
|
+
------------
|
|
132
|
+
|
|
133
|
+
Please see CONTRIBUTING.md for details.
|
|
134
|
+
|
|
135
|
+
Credits
|
|
136
|
+
-------
|
|
137
|
+
|
|
138
|
+

|
|
139
|
+
|
|
140
|
+
High Voltage is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
|
|
141
|
+
|
|
142
|
+
Thank you to all [the contributors](https://github.com/thoughtbot/high_voltage/contributors)!
|
|
143
|
+
|
|
144
|
+
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
|
145
|
+
|
|
146
|
+
License
|
|
147
|
+
-------
|
|
107
148
|
|
|
108
|
-
Copyright
|
|
149
|
+
High Voltage is Copyright © 2009-2011 thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
|
@@ -2,7 +2,13 @@ class HighVoltage::PagesController < ApplicationController
|
|
|
2
2
|
|
|
3
3
|
unloadable
|
|
4
4
|
|
|
5
|
-
rescue_from ActionView::MissingTemplate
|
|
5
|
+
rescue_from ActionView::MissingTemplate do |exception|
|
|
6
|
+
if exception.message =~ %r{Missing template pages/}
|
|
7
|
+
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
|
8
|
+
else
|
|
9
|
+
raise exception
|
|
10
|
+
end
|
|
11
|
+
end
|
|
6
12
|
|
|
7
13
|
def show
|
|
8
14
|
render :template => current_page
|
|
@@ -10,12 +16,13 @@ class HighVoltage::PagesController < ApplicationController
|
|
|
10
16
|
|
|
11
17
|
protected
|
|
12
18
|
|
|
13
|
-
def
|
|
14
|
-
|
|
19
|
+
def current_page
|
|
20
|
+
"pages/#{clean_path}"
|
|
15
21
|
end
|
|
16
22
|
|
|
17
|
-
def
|
|
18
|
-
"
|
|
23
|
+
def clean_path
|
|
24
|
+
path = Pathname.new "/#{params[:id]}"
|
|
25
|
+
path.cleanpath.to_s[1..-1]
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
end
|
data/config/routes.rb
CHANGED
metadata
CHANGED
|
@@ -1,75 +1,58 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: high_voltage
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- 0
|
|
7
|
-
- 9
|
|
8
|
-
- 3
|
|
9
|
-
version: 0.9.3
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
prerelease:
|
|
10
6
|
platform: ruby
|
|
11
|
-
authors:
|
|
12
|
-
- Dan Croak
|
|
7
|
+
authors:
|
|
13
8
|
- Matt Jankowski
|
|
14
|
-
-
|
|
9
|
+
- Dan Croak
|
|
15
10
|
- Nick Quaranto
|
|
16
|
-
- Tristan Dunn
|
|
17
11
|
- Chad Pytel
|
|
18
12
|
- Joe Ferris
|
|
13
|
+
- J. Edward Dewyea
|
|
14
|
+
- Tammer Saleh
|
|
15
|
+
- Mike Burns
|
|
16
|
+
- Tristan Dunn
|
|
19
17
|
autorequire:
|
|
20
18
|
bindir: bin
|
|
21
19
|
cert_chain: []
|
|
22
|
-
|
|
23
|
-
date: 2010-12-30 00:00:00 -05:00
|
|
24
|
-
default_executable:
|
|
20
|
+
date: 2011-09-04 00:00:00.000000000Z
|
|
25
21
|
dependencies: []
|
|
26
|
-
|
|
27
22
|
description: Fire in the disco. Fire in the ... taco bell.
|
|
28
23
|
email: support@thoughtbot.com
|
|
29
24
|
executables: []
|
|
30
|
-
|
|
31
25
|
extensions: []
|
|
32
|
-
|
|
33
26
|
extra_rdoc_files: []
|
|
34
|
-
|
|
35
|
-
files:
|
|
27
|
+
files:
|
|
36
28
|
- MIT-LICENSE
|
|
37
|
-
- README.
|
|
29
|
+
- README.md
|
|
38
30
|
- app/controllers/high_voltage/pages_controller.rb
|
|
39
31
|
- config/routes.rb
|
|
40
32
|
- lib/high_voltage/engine.rb
|
|
41
33
|
- lib/high_voltage.rb
|
|
42
|
-
has_rdoc: true
|
|
43
34
|
homepage: http://github.com/thoughtbot/high_voltage
|
|
44
35
|
licenses: []
|
|
45
|
-
|
|
46
36
|
post_install_message:
|
|
47
37
|
rdoc_options: []
|
|
48
|
-
|
|
49
|
-
require_paths:
|
|
38
|
+
require_paths:
|
|
50
39
|
- lib
|
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
41
|
none: false
|
|
53
|
-
requirements:
|
|
54
|
-
- -
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
version: "0"
|
|
59
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
47
|
none: false
|
|
61
|
-
requirements:
|
|
62
|
-
- -
|
|
63
|
-
- !ruby/object:Gem::Version
|
|
64
|
-
|
|
65
|
-
- 0
|
|
66
|
-
version: "0"
|
|
48
|
+
requirements:
|
|
49
|
+
- - ! '>='
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
67
52
|
requirements: []
|
|
68
|
-
|
|
69
53
|
rubyforge_project:
|
|
70
|
-
rubygems_version: 1.
|
|
54
|
+
rubygems_version: 1.8.10
|
|
71
55
|
signing_key:
|
|
72
56
|
specification_version: 3
|
|
73
57
|
summary: Simple static page rendering controller
|
|
74
58
|
test_files: []
|
|
75
|
-
|