blue_sparks 0.1.3 → 0.1.4
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.md +16 -6
- data/app/controllers/blue_sparks/pages_controller.rb +0 -14
- metadata +1 -1
data/README.md
CHANGED
@@ -4,6 +4,16 @@ BlueSparks
|
|
4
4
|
Epic static page rendering controller with support for nested pages, and
|
5
5
|
routes at the root. Heavily inspired by [thoughtbot's high_voltage](/thoughtbot/high_voltage).
|
6
6
|
|
7
|
+
Downsides
|
8
|
+
---------
|
9
|
+
|
10
|
+
Downsides, you say? Yeah, unfortunately the only downside is that we
|
11
|
+
have to use a wildcard route to accomplish the "routes at the root"
|
12
|
+
thing. This means that requests that would normally result in a 404 get
|
13
|
+
routed through BlueSparks::PagesController first. This shouldn't cause
|
14
|
+
any major hiccups, though. If you're still interested, read on for great
|
15
|
+
justice!!!
|
16
|
+
|
7
17
|
Routes at the root?
|
8
18
|
-------------------
|
9
19
|
|
@@ -66,11 +76,11 @@ By default, the static page routes will be like /:slug (where :slug is the view
|
|
66
76
|
|
67
77
|
If you want to route to a static page in another location (for example, a homepage), do this:
|
68
78
|
|
69
|
-
match '/
|
79
|
+
match '/my/crazy/page/of/doom' => 'blue_sparks/pages#show', :slug => 'mycrazypageofdoom'
|
70
80
|
|
71
|
-
In that case, you'd need an app/views/pages/
|
81
|
+
In that case, you'd need an app/views/pages/mycrazypageofdoom.html.erb file.
|
72
82
|
|
73
|
-
Generally speaking, you need to route to the 'show' action with
|
83
|
+
Generally speaking, you need to route to the 'show' action with a :slug param of the view filename.
|
74
84
|
|
75
85
|
You can route the root url to a high voltage page like this:
|
76
86
|
|
@@ -88,14 +98,14 @@ Most common reasons to override?
|
|
88
98
|
|
89
99
|
Create a PagesController of your own:
|
90
100
|
|
91
|
-
|
101
|
+
% rails generate controller pages
|
92
102
|
|
93
103
|
Override the default route:
|
94
104
|
|
95
105
|
# in config/routes.rb
|
96
|
-
|
106
|
+
match '/*slug' => 'pages#show'
|
97
107
|
|
98
|
-
Then modify it to subclass from
|
108
|
+
Then modify it to subclass from BlueSparks, adding whatever you need:
|
99
109
|
|
100
110
|
class PagesController < BlueSparks::PagesController
|
101
111
|
before_filter :authenticate
|
@@ -20,20 +20,6 @@ class BlueSparks::PagesController < ApplicationController
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def subnav
|
24
|
-
# magic method to render a given folder's subnav partial
|
25
|
-
begin
|
26
|
-
subnav = render :partial => "#{current_page}/menu", :layout => "menu_template"
|
27
|
-
subnav.first unless subnav.nil?
|
28
|
-
rescue
|
29
|
-
begin
|
30
|
-
subnav = render :partial => "#{page_root}/menu", :layout => "menu_template"
|
31
|
-
rescue
|
32
|
-
end
|
33
|
-
end
|
34
|
-
subnav.first unless subnav.nil?
|
35
|
-
end
|
36
|
-
|
37
23
|
protected
|
38
24
|
|
39
25
|
def current_page
|