Add Page external_link

This commit is contained in:
Wen-Tien Chang 2009-05-22 14:51:32 +08:00
parent a4c900af4d
commit 32fdf99833
4 changed files with 13 additions and 4 deletions

View File

@ -6,7 +6,9 @@ class PagesController < ApplicationController
@page = Page.find_by_name(params[:page_name]) @page = Page.find_by_name(params[:page_name])
@layout = @page.layout @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 @page_content = Liquid::Template.parse(@page.content).render
@layout_content = (@page.layout)? @layout.content : "{{page_content}}" @layout_content = (@page.layout)? @layout.content : "{{page_content}}"
render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content ) render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content )

View File

@ -5,6 +5,7 @@ class Page < CouchFoo::Base
property :content, String property :content, String
property :layout_id, String property :layout_id, String
property :layout_name, String property :layout_name, String
property :external_link, String
property :position, Integer property :position, Integer
property :is_published, Boolean property :is_published, Boolean
@ -30,12 +31,12 @@ class Page < CouchFoo::Base
protected protected
def setup_default_value def setup_default_value
unless self.position if self.position.blank?
max_page = Page.last( :use_key => 'position') max_page = Page.last( :use_key => 'position')
self.position = (max_page)? max_page.position.to_i + 1 : 1 self.position = (max_page)? max_page.position.to_i + 1 : 1
end end
unless self.parent_page_id if self.parent_page_id.blank?
self.parent_page_id = "root" self.parent_page_id = "root"
end end
end end

View File

@ -16,4 +16,9 @@
<p> <p>
<%= f.label :is_published, "Is Published" %> <%= f.label :is_published, "Is Published" %>
<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No <%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
</p>
<p>
<%= f.label :external_link, "External Link" %>
<%= f.text_field :external_link %>
</p> </p>

View File

@ -15,4 +15,5 @@
<br /> <br />
<%= link_to 'New snippets', new_admin_snippet_path, :class => 'button positive' %> <%= link_to 'New snippets', new_admin_snippet_path, :class => 'button positive' %>
<%= link_to 'New menu snippets', new_admin_snippet_path, :class => 'button positive' %>