From 32fdf99833056430f5fb796d59b902a983c4d5c8 Mon Sep 17 00:00:00 2001 From: Wen-Tien Chang Date: Fri, 22 May 2009 14:51:32 +0800 Subject: [PATCH] Add Page external_link --- app/controllers/pages_controller.rb | 4 +++- app/models/page.rb | 5 +++-- app/views/admin/pages/_form.html.erb | 5 +++++ app/views/admin/snippets/index.html.erb | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) 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 @@
-<%= link_to 'New snippets', new_admin_snippet_path, :class => 'button positive' %> \ No newline at end of file +<%= link_to 'New snippets', new_admin_snippet_path, :class => 'button positive' %> +<%= link_to 'New menu snippets', new_admin_snippet_path, :class => 'button positive' %> \ No newline at end of file