From 00813c906053bd375af06b825e80d47aafeeb55b Mon Sep 17 00:00:00 2001 From: chris2tof Date: Wed, 24 Aug 2011 02:04:54 +0800 Subject: [PATCH] Revert "Clean code and add 'name' in theme.rb" This reverts commit 608180646b76871282d58d9c06459f523b5ad8a6. --- Gemfile | 2 +- Gemfile.lock | 4 +- app/controllers/admin/pages_controller.rb | 20 ++++- app/helpers/admin/item_helper.rb | 1 + app/models/design/theme.rb | 12 --- app/models/page.rb | 15 +++- app/views/admin/pages/_edit_code.html.erb | 8 ++ app/views/admin/pages/_form.html.erb | 10 +-- app/views/admin/pages/_form_code.html.erb | 3 + app/views/admin/pages/edit.html.erb | 15 ++++ app/views/admin/pages/edit.js.erb | 1 + app/views/admin/pages/show.html.erb | 2 +- app/views/admin/pages/update.js.erb | 2 + lib/fraisier/themes/red.css | 1 - lib/parser.rb | 104 +++++++++++++++++++++- lib/tasks/dev.rake | 36 ++------ 16 files changed, 177 insertions(+), 59 deletions(-) create mode 100644 app/views/admin/pages/_edit_code.html.erb create mode 100644 app/views/admin/pages/_form_code.html.erb create mode 100644 app/views/admin/pages/edit.html.erb create mode 100644 app/views/admin/pages/edit.js.erb create mode 100644 app/views/admin/pages/update.js.erb delete mode 100644 lib/fraisier/themes/red.css diff --git a/Gemfile b/Gemfile index 1e6ce8fc..a9813caa 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'rails', '>=3.1.0.rc4' gem 'yajl-ruby', :require => 'yajl' gem 'bson_ext' -gem 'carrierwave', '0.5.4' +gem 'carrierwave', '0.5.6' gem 'ckeditor' gem 'devise' gem 'mini_magick' diff --git a/Gemfile.lock b/Gemfile.lock index 74e4c8c1..7177ff7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,7 +36,7 @@ GEM bson (1.3.1) bson_ext (1.3.1) builder (3.0.0) - carrierwave (0.5.4) + carrierwave (0.5.6) activesupport (~> 3.0) chronic (0.6.2) ckeditor (3.6.1) @@ -171,7 +171,7 @@ PLATFORMS DEPENDENCIES bson_ext - carrierwave (= 0.5.4) + carrierwave (= 0.5.6) ckeditor coffee-rails (~> 3.1.0.rc) delorean diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index a0f4231e..d6992c71 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -21,11 +21,14 @@ class Admin::PagesController < ApplicationController @item = Page.new @item.is_published = true @item.parent_id = @parent_item.id rescue nil - @designs = Design.all.entries - @default_design = @designs.detect {|d| d.title.to_s == 'Bob' } end def edit + @item = Page.find(params[:id]) + # @item.content = parse_content(@item.content, {:locale => 'show'}) + @item.content = parse_page_code(@item) + @i18n_variable = @item.i18n_variable + @code = params[:code] end def create @@ -48,6 +51,19 @@ class Admin::PagesController < ApplicationController end def update + @item = Page.find(params[:id]) + parse_content_update_code(@item, params[:page][:content]) + if @item.update_attributes(params[:item]) + flash[:notice] = t('admin.update_success_page') + respond_to do |format| + format.html { + redirect_to admin_page_url(@item) + } + format.js {} + end + else + render :action => "edit" + end end def destroy diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index e91265fc..7994cb25 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -12,6 +12,7 @@ module Admin::ItemHelper ret << "