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 << "
+ <%= f.submit t(:update) %> <%= link_back %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 4afc26e7..54ee892f 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -15,14 +15,8 @@ <% end %>- <%= t('admin.design_name') %> - <%= f.select :design_id, @designs.collect { |d| [d.title, d.id] }, :selected => @default_design.id %> -
-- <%= @item.design.inspect %> - <%= t('admin.theme') %> - <%= f.select :theme_id, @default_design.themes.collect { |t| [t.name, t.id] }, :selected => @default_design.themes.detect {|t| t.file_filename.to_s == 'default.css' }.id %> - <%#= f.collection_select :design, @designs, :id, :title %> +<%= f.label :design_id, t('admin.design_name') %> +<%= f.select :design_id, Design.all.map{ |l| [l.title, l.id] } %>
diff --git a/app/views/admin/pages/_form_code.html.erb b/app/views/admin/pages/_form_code.html.erb new file mode 100644 index 00000000..ad0e55ed --- /dev/null +++ b/app/views/admin/pages/_form_code.html.erb @@ -0,0 +1,3 @@ +<%= f.error_messages %> + +<%= f.text_area :content %> \ No newline at end of file diff --git a/app/views/admin/pages/edit.html.erb b/app/views/admin/pages/edit.html.erb new file mode 100644 index 00000000..b4bfc607 --- /dev/null +++ b/app/views/admin/pages/edit.html.erb @@ -0,0 +1,15 @@ +<% content_for :sidebar do %> + <%= render 'admin/items/site_map_left_bar' %> +<% end -%> + +
+ <%= f.submit t('update') %> <%= link_back %> + +
+<% end %> diff --git a/app/views/admin/pages/edit.js.erb b/app/views/admin/pages/edit.js.erb new file mode 100644 index 00000000..9c61245e --- /dev/null +++ b/app/views/admin/pages/edit.js.erb @@ -0,0 +1 @@ +$('#panel_main').html("<%= escape_javascript(render(:partial => @code ? 'edit_code' : 'edit')) %>"); \ No newline at end of file diff --git a/app/views/admin/pages/show.html.erb b/app/views/admin/pages/show.html.erb index d6b6a8a2..6dd0f923 100644 --- a/app/views/admin/pages/show.html.erb +++ b/app/views/admin/pages/show.html.erb @@ -2,4 +2,4 @@ <%= render 'admin/items/site_map_left_bar' %> <% end -%> -<%= render 'show' %> \ No newline at end of file +<%= render @code ? 'show_code' : 'show' %> \ No newline at end of file diff --git a/app/views/admin/pages/update.js.erb b/app/views/admin/pages/update.js.erb new file mode 100644 index 00000000..20cb22c1 --- /dev/null +++ b/app/views/admin/pages/update.js.erb @@ -0,0 +1,2 @@ +$('#panel_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); +history.pushState(null, document.title, "<%= escape_javascript(admin_page_url(@item)) %>"); diff --git a/lib/fraisier/themes/red.css b/lib/fraisier/themes/red.css deleted file mode 100644 index 97097ed2..00000000 --- a/lib/fraisier/themes/red.css +++ /dev/null @@ -1 +0,0 @@ -/* Some css */ \ No newline at end of file diff --git a/lib/parser.rb b/lib/parser.rb index a5299af3..83e5bcf8 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -105,6 +105,12 @@ module Parser end end + def parse_content(page_content, attributes = {}) + context = parser_context(page_content, attributes) + parser = Radius::Parser.new(context, :tag_prefix => 'r') + parser.parse(page_content) + end + def parse_page(page) if page._type == 'Page' layout_content = page.design.layout.content @@ -208,6 +214,33 @@ module Parser end end + def parse_page_code(page) + layout_content = page.design.layout.content + context = parser_context_code(page) + parser = Radius::Parser.new(context, :tag_prefix => 'r') + parser.parse(layout_content) + end + + def parser_context_code(page) #context should be interpretd as the orginally one + Radius::Context.new do |c| + c.define_tag 'stylesheets' do |tag| + res << "