high_voltage 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
data/{README.rdoc → README.md}
RENAMED
@@ -1,14 +1,17 @@
|
|
1
|
-
|
1
|
+
High Voltage
|
2
|
+
============
|
2
3
|
|
3
4
|
Rails engine for static pages.
|
4
5
|
|
5
6
|
... but be careful. [Danger!](http://www.youtube.com/watch?v=HD5tnb2RBYg)
|
6
7
|
|
7
|
-
|
8
|
+
Static pages?
|
9
|
+
-------------
|
8
10
|
|
9
11
|
Yeah, like "About us", "Directions", marketing pages, etc.
|
10
12
|
|
11
|
-
|
13
|
+
Installation
|
14
|
+
------------
|
12
15
|
|
13
16
|
$ gem install high_voltage
|
14
17
|
|
@@ -19,12 +22,13 @@ Include in your Gemfile:
|
|
19
22
|
For Rails versions prior to 3.0, use the rails2 branch of high_voltage:
|
20
23
|
https://github.com/thoughtbot/high_voltage/tree/rails2
|
21
24
|
|
22
|
-
|
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
|
|
@@ -36,7 +40,8 @@ This will also work, if you like the more explicit style:
|
|
36
40
|
|
37
41
|
Bam.
|
38
42
|
|
39
|
-
|
43
|
+
Routes
|
44
|
+
------
|
40
45
|
|
41
46
|
By default, the static page routes will be like /pages/:id (where :id is the view filename).
|
42
47
|
|
@@ -54,7 +59,8 @@ You can route the root url to a high voltage page like this:
|
|
54
59
|
|
55
60
|
Which will render a homepage from app/views/pages/home.html.erb
|
56
61
|
|
57
|
-
|
62
|
+
Override
|
63
|
+
--------
|
58
64
|
|
59
65
|
Most common reasons to override?
|
60
66
|
|
@@ -63,7 +69,12 @@ Most common reasons to override?
|
|
63
69
|
|
64
70
|
Create a PagesController of your own:
|
65
71
|
|
66
|
-
|
72
|
+
$ rails generate controller pages
|
73
|
+
|
74
|
+
Override the default route:
|
75
|
+
|
76
|
+
# in config/routes.rb
|
77
|
+
resources :pages
|
67
78
|
|
68
79
|
Then modify it to subclass from High Voltage, adding whatever you need:
|
69
80
|
|
@@ -82,7 +93,8 @@ Then modify it to subclass from High Voltage, adding whatever you need:
|
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
85
|
-
|
96
|
+
Testing
|
97
|
+
-------
|
86
98
|
|
87
99
|
Just a suggestion, but you can test your pages using Shoulda pretty easily:
|
88
100
|
|
@@ -103,6 +115,18 @@ If you're not using a custom PagesController be sure to test <code>HighVoltage::
|
|
103
115
|
|
104
116
|
Enjoy!
|
105
117
|
|
106
|
-
|
118
|
+
Credits
|
119
|
+
-------
|
120
|
+
|
121
|
+
![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
|
122
|
+
|
123
|
+
High Voltage is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
|
124
|
+
|
125
|
+
Thank you to all [the contributors](https://github.com/thoughtbot/high_voltage/contributors)!
|
126
|
+
|
127
|
+
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
128
|
+
|
129
|
+
License
|
130
|
+
-------
|
107
131
|
|
108
|
-
Copyright
|
132
|
+
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,10 +16,6 @@ class HighVoltage::PagesController < ApplicationController
|
|
10
16
|
|
11
17
|
protected
|
12
18
|
|
13
|
-
def invalid_page
|
14
|
-
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
15
|
-
end
|
16
|
-
|
17
19
|
def current_page
|
18
20
|
"pages/#{params[:id].to_s.downcase}"
|
19
21
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: high_voltage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 51
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Dan Croak
|
@@ -20,7 +21,7 @@ autorequire:
|
|
20
21
|
bindir: bin
|
21
22
|
cert_chain: []
|
22
23
|
|
23
|
-
date:
|
24
|
+
date: 2011-04-09 00:00:00 -04:00
|
24
25
|
default_executable:
|
25
26
|
dependencies: []
|
26
27
|
|
@@ -34,7 +35,7 @@ extra_rdoc_files: []
|
|
34
35
|
|
35
36
|
files:
|
36
37
|
- MIT-LICENSE
|
37
|
-
- README.
|
38
|
+
- README.md
|
38
39
|
- app/controllers/high_voltage/pages_controller.rb
|
39
40
|
- config/routes.rb
|
40
41
|
- lib/high_voltage/engine.rb
|
@@ -53,6 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
54
|
requirements:
|
54
55
|
- - ">="
|
55
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
56
58
|
segments:
|
57
59
|
- 0
|
58
60
|
version: "0"
|
@@ -61,13 +63,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
63
|
requirements:
|
62
64
|
- - ">="
|
63
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
64
67
|
segments:
|
65
68
|
- 0
|
66
69
|
version: "0"
|
67
70
|
requirements: []
|
68
71
|
|
69
72
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.6.2
|
71
74
|
signing_key:
|
72
75
|
specification_version: 3
|
73
76
|
summary: Simple static page rendering controller
|