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
def content
self.file.read.force_encoding("UTF-8")
self.file.read.force_encoding("UTF-8") rescue ''
end
def self.exist_one?

View File

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

View File

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

View File

@ -113,7 +113,7 @@ module Parser
def parse_page(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)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
@ -122,7 +122,7 @@ module Parser
def parse_page_edit(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)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
@ -175,8 +175,8 @@ module Parser
end
c.define_tag 'stylesheets' do |tag|
res = ''
res << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />"
res << "<link href='#{page.design.default_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' />" if page.design.default_css
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

View File

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