high_voltage 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +73 -0
- data/app/controllers/high_voltage/pages_controller.rb +21 -0
- data/config/routes.rb +3 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/high_voltage.rb +3 -0
- data/lib/high_voltage/engine.rb +6 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
High Voltage
|
2
|
+
============
|
3
|
+
|
4
|
+
Rails engine for static pages.
|
5
|
+
|
6
|
+
... but be careful. [Danger!](http://www.youtube.com/watch?v=HD5tnb2RBYg)
|
7
|
+
|
8
|
+
Static pages?
|
9
|
+
-------------
|
10
|
+
|
11
|
+
Yeah, like "About us", "Directions", marketing pages, etc.
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
$ gem install high_voltage
|
17
|
+
|
18
|
+
Usage
|
19
|
+
-----
|
20
|
+
|
21
|
+
Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
|
22
|
+
|
23
|
+
mkdir app/views/pages
|
24
|
+
touch app/views/pages/about.html.erb
|
25
|
+
|
26
|
+
After putting something interesting there, you can link to it from anywhere in your app with:
|
27
|
+
|
28
|
+
link_to "About", page_path("about")
|
29
|
+
|
30
|
+
Bam.
|
31
|
+
|
32
|
+
Override
|
33
|
+
--------
|
34
|
+
|
35
|
+
Most common reasons to override? Authentication, layouts.
|
36
|
+
|
37
|
+
Create a PagesController of your own:
|
38
|
+
|
39
|
+
script/generate controller pages
|
40
|
+
|
41
|
+
Then modify it to subclass from High Voltage, adding whatever you need:
|
42
|
+
|
43
|
+
class PagesController < HighVoltage::PagesController
|
44
|
+
before_filter :authenticate
|
45
|
+
layout "danger"
|
46
|
+
end
|
47
|
+
|
48
|
+
Testing
|
49
|
+
-------
|
50
|
+
|
51
|
+
Just a suggestion, but you can test your pages using Shoulda pretty easily:
|
52
|
+
|
53
|
+
class PagesControllerTest < ActionController::TestCase
|
54
|
+
tests PagesController
|
55
|
+
|
56
|
+
%w(earn_money screencast about contact).each do |page|
|
57
|
+
context "on GET to /pages/#{page}" do
|
58
|
+
setup { get :show, :id => page }
|
59
|
+
|
60
|
+
should_respond_with :success
|
61
|
+
should_render_template page
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
If you're not using a custom PagesController be sure to test <code>HighVoltage::PagesController</code> instead.
|
67
|
+
|
68
|
+
Enjoy!
|
69
|
+
|
70
|
+
License
|
71
|
+
-------
|
72
|
+
|
73
|
+
Copyright (c) thoughtbot, inc -- released under the MIT license.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class HighVoltage::PagesController < ApplicationController
|
2
|
+
|
3
|
+
unloadable
|
4
|
+
|
5
|
+
rescue_from ActionView::MissingTemplate, :with => :invalid_page
|
6
|
+
|
7
|
+
def show
|
8
|
+
render :template => current_page
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def invalid_page
|
14
|
+
render :nothing => true, :status => 404
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_page
|
18
|
+
"pages/#{params[:id].to_s.downcase}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/config/routes.rb
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'high_voltage'
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/lib/high_voltage.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: high_voltage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 0
|
9
|
+
version: 0.9.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dan Croak
|
13
|
+
- Matt Jankowski
|
14
|
+
- Tammer Saleh
|
15
|
+
- Nick Quaranto
|
16
|
+
- Tristan Dunn
|
17
|
+
autorequire:
|
18
|
+
bindir: bin
|
19
|
+
cert_chain: []
|
20
|
+
|
21
|
+
date: 2010-04-20 00:00:00 -04:00
|
22
|
+
default_executable:
|
23
|
+
dependencies: []
|
24
|
+
|
25
|
+
description: Fire in the disco. Fire in the ... taco bell.
|
26
|
+
email: support@thoughtbot.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- app/controllers/high_voltage/pages_controller.rb
|
35
|
+
- config/routes.rb
|
36
|
+
- init.rb
|
37
|
+
- install.rb
|
38
|
+
- lib/high_voltage/engine.rb
|
39
|
+
- lib/high_voltage.rb
|
40
|
+
- MIT-LICENSE
|
41
|
+
- README.markdown
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/thoughtbot/high_voltage
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.6
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Simple static page rendering controller
|
72
|
+
test_files: []
|
73
|
+
|