From f2e3cb00db7ec65d3f2c406352cc4d2b437a091d Mon Sep 17 00:00:00 2001 From: chris2tof Date: Tue, 13 Sep 2011 14:03:03 +0800 Subject: [PATCH] Fix bug when editing a page, the theme wasn't including blank --- app/models/design/layout.rb | 2 +- app/models/purchase/purchase.rb | 2 +- app/views/admin/pages/_form.html.erb | 2 +- lib/parser.rb | 8 ++++---- lib/tasks/dev.rake | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index dae1c43b..e27ca0bb 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -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? diff --git a/app/models/purchase/purchase.rb b/app/models/purchase/purchase.rb index 760724a2..cc52c2d5 100644 --- a/app/models/purchase/purchase.rb +++ b/app/models/purchase/purchase.rb @@ -6,6 +6,6 @@ class Purchase field :title field :author field :intro - field :downloaded + field :downloaded, :type => Boolean end diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 19e7c1a6..845e4d37 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -25,7 +25,7 @@

<%= 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 %> diff --git a/lib/parser.rb b/lib/parser.rb index 3eddbdca..51e3e273 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -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 << "" - res << "" + res << "" if page.design.reset_css + res << "" if page.design.default_css theme = page.design.themes.detect{ |d| d.id == page.theme_id } res << "" if theme res diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 36b6952a..0ccb4177 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -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