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.
@@ -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
- unless @page
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
 
@@ -10,5 +10,7 @@ module BluePages
10
10
  end
11
11
 
12
12
  mattr_accessor :route_prefix
13
+
14
+ mattr_accessor :model_includes
13
15
 
14
16
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Ji\xC5\x99\xC3\xAD Zajpt"