Fix bug when editing a page, the theme wasn't including blank

This commit is contained in:
chris2tof 2011-09-13 14:03:03 +08:00
parent 4db88282a1
commit f2e3cb00db
5 changed files with 13 additions and 13 deletions

View File

@ -12,7 +12,7 @@ class Layout < DesignFile
after_save :parse_layout after_save :parse_layout
def content def content
self.file.read.force_encoding("UTF-8") self.file.read.force_encoding("UTF-8") rescue ''
end end
def self.exist_one? def self.exist_one?

View File

@ -6,6 +6,6 @@ class Purchase
field :title field :title
field :author field :author
field :intro field :intro
field :downloaded field :downloaded, :type => Boolean
end end

View File

@ -25,7 +25,7 @@
<p> <p>
<%= t('admin.theme') %> <%= t('admin.theme') %>
<% if @design %> <% if @design %>
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }%> <%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
<% else %> <% else %>
<%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> <%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
<% end %> <% end %>

View File

@ -113,7 +113,7 @@ module Parser
def parse_page(page) def parse_page(page)
if page._type == 'Page' if page._type == 'Page'
layout_content = page.design.layout.content.force_encoding('UTF-8') layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
context = parser_context(page) context = parser_context(page)
parser = Radius::Parser.new(context, :tag_prefix => 'r') parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content)) parser.parse(parser.parse(layout_content))
@ -122,7 +122,7 @@ module Parser
def parse_page_edit(page) def parse_page_edit(page)
if page._type == 'Page' if page._type == 'Page'
layout_content = page.design.layout.content.force_encoding('UTF-8') layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
context = parser_context_edit(page) context = parser_context_edit(page)
parser = Radius::Parser.new(context, :tag_prefix => 'r') parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content)) parser.parse(parser.parse(layout_content))
@ -175,8 +175,8 @@ module Parser
end end
c.define_tag 'stylesheets' do |tag| c.define_tag 'stylesheets' do |tag|
res = '' res = ''
res << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />" res << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />" if page.design.reset_css
res << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />" res << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />" if page.design.default_css
theme = page.design.themes.detect{ |d| d.id == page.theme_id } theme = page.design.themes.detect{ |d| d.id == page.theme_id }
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme
res res

View File

@ -81,9 +81,9 @@ namespace :dev do
design.build_layout design.build_layout
design.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html") design.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html")
design.layout design.layout.save
theme theme.save
theme_1 theme_1.save
# image.save # image.save
# js.save # js.save
@ -105,9 +105,9 @@ namespace :dev do
design_1.build_layout design_1.build_layout
design_1.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html") design_1.layout.file = File.open("#{Rails.root}/lib/fraisier/layout.html")
design_1.layout design_1.layout.save
theme theme.save
theme_1 theme_1.save
# image.save # image.save
# js.save # js.save