diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 8a06afee..5b01f182 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -6,7 +6,9 @@ class PagesController < ApplicationController @page = Page.find_by_name(params[:page_name]) @layout = @page.layout - if @page + if @page && @page.external_link + redirect_to @page.external_link + elsif @page @page_content = Liquid::Template.parse(@page.content).render @layout_content = (@page.layout)? @layout.content : "{{page_content}}" render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content ) diff --git a/app/models/page.rb b/app/models/page.rb index 4ed3ff24..dde0dd4e 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -5,6 +5,7 @@ class Page < CouchFoo::Base property :content, String property :layout_id, String property :layout_name, String + property :external_link, String property :position, Integer property :is_published, Boolean @@ -30,12 +31,12 @@ class Page < CouchFoo::Base protected def setup_default_value - unless self.position + if self.position.blank? max_page = Page.last( :use_key => 'position') self.position = (max_page)? max_page.position.to_i + 1 : 1 end - unless self.parent_page_id + if self.parent_page_id.blank? self.parent_page_id = "root" end end diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index f180be1a..1e733a4a 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -16,4 +16,9 @@
<%= f.label :is_published, "Is Published" %> <%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No +
+ ++<%= f.label :external_link, "External Link" %> +<%= f.text_field :external_link %>
\ No newline at end of file diff --git a/app/views/admin/snippets/index.html.erb b/app/views/admin/snippets/index.html.erb index 40eba30b..354f0f9a 100644 --- a/app/views/admin/snippets/index.html.erb +++ b/app/views/admin/snippets/index.html.erb @@ -15,4 +15,5 @@