high_voltage 0.9.2 → 0.9.3

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,4 +1,4 @@
1
- Copyright (c) 2009 [name of plugin creator]
1
+ Copyright 2010 thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,22 +1,25 @@
1
- High Voltage
2
- ============
1
+ = High Voltage
3
2
 
4
3
  Rails engine for static pages.
5
4
 
6
5
  ... but be careful. [Danger!](http://www.youtube.com/watch?v=HD5tnb2RBYg)
7
6
 
8
- Static pages?
9
- -------------
7
+ == Static pages?
10
8
 
11
9
  Yeah, like "About us", "Directions", marketing pages, etc.
12
10
 
13
- Installation
14
- ------------
11
+ == Installation
15
12
 
16
13
  $ gem install high_voltage
17
14
 
18
- Usage
19
- -----
15
+ Include in your Gemfile:
16
+
17
+ gem "high_voltage"
18
+
19
+ For Rails versions prior to 3.0, use the rails2 branch of high_voltage:
20
+ https://github.com/thoughtbot/high_voltage/tree/rails2
21
+
22
+ == Usage
20
23
 
21
24
  Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
22
25
 
@@ -27,29 +30,36 @@ After putting something interesting there, you can link to it from anywhere in y
27
30
 
28
31
  link_to "About", page_path("about")
29
32
 
33
+ This will also work, if you like the more explicit style:
34
+
35
+ link_to "About", page_path(:id => "about")
36
+
30
37
  Bam.
31
38
 
32
- Routes
33
- ------
39
+ == Routes
34
40
 
35
41
  By default, the static page routes will be like /pages/:id (where :id is the view filename).
36
42
 
37
43
  If you want to route to a static page in another location (for example, a homepage), do this:
38
44
 
39
- map.root :controller => 'pages', :action => 'show', :id => 'home'
45
+ match 'pages/home' => 'high_voltage/pages#show', :id => 'home'
40
46
 
41
47
  In that case, you'd need an app/views/pages/home.html.erb file.
42
48
 
43
49
  Generally speaking, you need to route to the 'show' action with an :id param of the view filename.
44
50
 
45
- You'll notice in your config/routes.rb file that the High Voltage routes are generated by:
51
+ You can route the root url to a high voltage page like this:
52
+
53
+ root :to => 'high_voltage/pages#show', :id => 'home'
46
54
 
47
- HighVoltage::Routes.draw(map)
55
+ Which will render a homepage from app/views/pages/home.html.erb
48
56
 
49
- Override
50
- --------
57
+ == Override
51
58
 
52
- Most common reasons to override? Authentication, layouts.
59
+ Most common reasons to override?
60
+
61
+ * You need authentication around the pages to make sure a user is signed in.
62
+ * You need to render different layouts for different pages.
53
63
 
54
64
  Create a PagesController of your own:
55
65
 
@@ -59,11 +69,20 @@ Then modify it to subclass from High Voltage, adding whatever you need:
59
69
 
60
70
  class PagesController < HighVoltage::PagesController
61
71
  before_filter :authenticate
62
- layout "danger"
72
+ layout :layout_for_page
73
+
74
+ protected
75
+ def layout_for_page
76
+ case params[:id]
77
+ when 'home'
78
+ 'home'
79
+ else
80
+ 'application'
81
+ end
82
+ end
63
83
  end
64
84
 
65
- Testing
66
- -------
85
+ == Testing
67
86
 
68
87
  Just a suggestion, but you can test your pages using Shoulda pretty easily:
69
88
 
@@ -84,7 +103,6 @@ If you're not using a custom PagesController be sure to test <code>HighVoltage::
84
103
 
85
104
  Enjoy!
86
105
 
87
- License
88
- -------
106
+ == License
89
107
 
90
108
  Copyright (c) thoughtbot, inc -- released under the MIT license.
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: high_voltage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 9
9
- - 2
10
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Dan Croak
@@ -21,7 +20,7 @@ autorequire:
21
20
  bindir: bin
22
21
  cert_chain: []
23
22
 
24
- date: 2010-10-25 00:00:00 -04:00
23
+ date: 2010-12-30 00:00:00 -05:00
25
24
  default_executable:
26
25
  dependencies: []
27
26
 
@@ -34,14 +33,12 @@ extensions: []
34
33
  extra_rdoc_files: []
35
34
 
36
35
  files:
36
+ - MIT-LICENSE
37
+ - README.rdoc
37
38
  - app/controllers/high_voltage/pages_controller.rb
38
39
  - config/routes.rb
39
- - init.rb
40
- - install.rb
41
40
  - lib/high_voltage/engine.rb
42
41
  - lib/high_voltage.rb
43
- - MIT-LICENSE
44
- - README.markdown
45
42
  has_rdoc: true
46
43
  homepage: http://github.com/thoughtbot/high_voltage
47
44
  licenses: []
@@ -56,7 +53,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
53
  requirements:
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
- hash: 3
60
56
  segments:
61
57
  - 0
62
58
  version: "0"
@@ -65,7 +61,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
61
  requirements:
66
62
  - - ">="
67
63
  - !ruby/object:Gem::Version
68
- hash: 3
69
64
  segments:
70
65
  - 0
71
66
  version: "0"
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'high_voltage'
data/install.rb DELETED
@@ -1,7 +0,0 @@
1
- line = "HighVoltage::Routes.draw(map)"
2
- path = "config/routes.rb"
3
-
4
- puts "inserting #{line} into #{path}"
5
-
6
- content = File.read(path).sub(/^(end\s*)$/) {|match| " #{line}\n#{match}" }
7
- File.open(path, 'wb') { |file| file.write(content) }