blue_pages 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/blue_pages/pages_controller.rb +10 -4
- data/app/models/blue_pages/page.rb +10 -2
- data/lib/blue_pages.rb +2 -0
- metadata +2 -2
@@ -6,15 +6,21 @@ class BluePages::PagesController < ::ApplicationController
|
|
6
6
|
|
7
7
|
def show
|
8
8
|
@page = BluePages::Page.where(:path => params[:path]).first
|
9
|
-
|
9
|
+
if @page
|
10
|
+
render_page
|
11
|
+
else
|
10
12
|
render_404
|
11
13
|
end
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
protected
|
15
|
-
|
17
|
+
|
18
|
+
def render_page
|
19
|
+
render 'pages/show'
|
20
|
+
end
|
21
|
+
|
16
22
|
def render_404
|
17
|
-
render :file => File.join(Rails.root, "/public/404.html"),
|
23
|
+
render :file => File.join(Rails.root, "/public/404.html"),
|
18
24
|
:status => :not_found,
|
19
25
|
:layout => false
|
20
26
|
end
|
@@ -6,6 +6,10 @@ class BluePages::Page
|
|
6
6
|
include Mongoid::Timestamps
|
7
7
|
include Mongoid::Tree
|
8
8
|
|
9
|
+
BluePages.model_includes.each do |mod|
|
10
|
+
include mod
|
11
|
+
end
|
12
|
+
|
9
13
|
store_in :blue_pages
|
10
14
|
|
11
15
|
field :title
|
@@ -13,11 +17,11 @@ class BluePages::Page
|
|
13
17
|
field :path
|
14
18
|
field :metadata, :type => Hash
|
15
19
|
field :content
|
16
|
-
field :published, :type => Boolean, :default => true
|
20
|
+
field :published, :type => Boolean, :default => true
|
17
21
|
|
18
22
|
validates_presence_of :title
|
19
23
|
validates_uniqueness_of :title
|
20
|
-
|
24
|
+
|
21
25
|
scope :published, where(:published => true)
|
22
26
|
scope :unpublished, where(:published => false)
|
23
27
|
|
@@ -27,6 +31,10 @@ class BluePages::Page
|
|
27
31
|
write_attribute(:permalink, Permalink.from(new_title))
|
28
32
|
write_attribute(:title, new_title)
|
29
33
|
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
title
|
37
|
+
end
|
30
38
|
|
31
39
|
protected
|
32
40
|
|
data/lib/blue_pages.rb
CHANGED