Add MongoMapper key_i18n support

This commit is contained in:
Wen-Tien Chang committed 2010-01-08 15:32:44 +08:00
1 parent a674e46c91
commit 5ab32baf88
7 files changed
+23 -36

No files matched your search

+2 -2
View File
@@ -13,8 +13,8 @@ class ApplicationController < ActionController::Base
if @page
@layout = @page.layout
@page_options ||= {}
@page_content = Liquid::Template.parse( @page.send( "content_#{I18n.locale}" ) ).render(@page_options)
@layout_content = (@page.layout)? @layout.send( "content_#{I18n.locale}" ) : "{{page_content}}"
@page_content = Liquid::Template.parse( @page.content ).render(@page_options)
@layout_content = (@page.layout)? @layout.content : "{{page_content}}"
render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content )
else
render :text => '404 Not Found'
+3 -13
View File
@@ -2,21 +2,11 @@ class Announcement
include MongoMapper::Document
key :title_en, String
key :title_zh_tw, String
key :content_en, String
key :content_zh_tw, String
key_i18n :title, String
key_i18n :content, String
def to_liquid
{ "id" => self.id, "title" => self.send("title_#{I18n.locale}"), "content" => self.send("content_#{I18n.locale}") }
end
def title
self.send("title_#{I18n.locale}")
end
def content
self.send("content_#{I18n.locale}")
{ "id" => self.id, "title" => self.title, "content" => self.content }
end
end
+1 -2
View File
@@ -3,8 +3,7 @@ class Layout
include MongoMapper::Document
key :name, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
validates_presence_of :name
+2 -3
View File
@@ -3,9 +3,8 @@ class Page
key :name, String
key :parent_page_id, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
key :layout_id, String
key :layout_name, String
+1 -2
View File
@@ -3,8 +3,7 @@ class Snippet
include MongoMapper::Document
key :name, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
validates_presence_of :name
+1 -1
View File
@@ -4,7 +4,7 @@ module SnippetFilter
snippet = Snippet.find_by_name(snippet_name)
if snippet
return Liquid::Template.parse( snippet.send( "content_#{I18n.locale}" ) ).render
return Liquid::Template.parse( snippet.content ).render
else
return "nothing"
end