high_voltage 0.9.3 → 1.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.
@@ -1,14 +1,17 @@
1
- = High Voltage
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
- == Static pages?
8
+ Static pages?
9
+ -------------
8
10
 
9
11
  Yeah, like "About us", "Directions", marketing pages, etc.
10
12
 
11
- == Installation
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
- == Usage
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
- == Routes
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
 
@@ -54,7 +63,8 @@ You can route the root url to a high voltage page like this:
54
63
 
55
64
  Which will render a homepage from app/views/pages/home.html.erb
56
65
 
57
- == Override
66
+ Override
67
+ --------
58
68
 
59
69
  Most common reasons to override?
60
70
 
@@ -63,7 +73,12 @@ Most common reasons to override?
63
73
 
64
74
  Create a PagesController of your own:
65
75
 
66
- script/generate controller pages
76
+ $ rails generate controller pages
77
+
78
+ Override the default route:
79
+
80
+ # in config/routes.rb
81
+ resources :pages
67
82
 
68
83
  Then modify it to subclass from High Voltage, adding whatever you need:
69
84
 
@@ -82,7 +97,8 @@ Then modify it to subclass from High Voltage, adding whatever you need:
82
97
  end
83
98
  end
84
99
 
85
- == Testing
100
+ Testing
101
+ -------
86
102
 
87
103
  Just a suggestion, but you can test your pages using Shoulda pretty easily:
88
104
 
@@ -103,6 +119,18 @@ If you're not using a custom PagesController be sure to test <code>HighVoltage::
103
119
 
104
120
  Enjoy!
105
121
 
106
- == License
122
+ Credits
123
+ -------
124
+
125
+ ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
126
+
127
+ High Voltage is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
128
+
129
+ Thank you to all [the contributors](https://github.com/thoughtbot/high_voltage/contributors)!
130
+
131
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
132
+
133
+ License
134
+ -------
107
135
 
108
- Copyright (c) thoughtbot, inc -- released under the MIT license.
136
+ 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, :with => :invalid_page
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 invalid_page
14
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
19
+ def current_page
20
+ "pages/#{clean_path}"
15
21
  end
16
22
 
17
- def current_page
18
- "pages/#{params[:id].to_s.downcase}"
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
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- resources :pages, :controller => 'high_voltage/pages', :only => :show
2
+ match '/pages/*id' => 'high_voltage/pages#show', :as => :page
3
3
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: high_voltage
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 9
8
- - 3
9
- version: 0.9.3
4
+ prerelease:
5
+ version: 1.0.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Dan Croak
@@ -20,7 +16,7 @@ autorequire:
20
16
  bindir: bin
21
17
  cert_chain: []
22
18
 
23
- date: 2010-12-30 00:00:00 -05:00
19
+ date: 2011-06-29 00:00:00 -04:00
24
20
  default_executable:
25
21
  dependencies: []
26
22
 
@@ -34,7 +30,7 @@ extra_rdoc_files: []
34
30
 
35
31
  files:
36
32
  - MIT-LICENSE
37
- - README.rdoc
33
+ - README.md
38
34
  - app/controllers/high_voltage/pages_controller.rb
39
35
  - config/routes.rb
40
36
  - lib/high_voltage/engine.rb
@@ -53,21 +49,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
49
  requirements:
54
50
  - - ">="
55
51
  - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
52
  version: "0"
59
53
  required_rubygems_version: !ruby/object:Gem::Requirement
60
54
  none: false
61
55
  requirements:
62
56
  - - ">="
63
57
  - !ruby/object:Gem::Version
64
- segments:
65
- - 0
66
58
  version: "0"
67
59
  requirements: []
68
60
 
69
61
  rubyforge_project:
70
- rubygems_version: 1.3.7
62
+ rubygems_version: 1.6.2
71
63
  signing_key:
72
64
  specification_version: 3
73
65
  summary: Simple static page rendering controller