From 2b2dd53218785575f012a8f122b39872d66bf2a2 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 24 Oct 2012 18:40:38 +0800 Subject: [PATCH] Edit uploaded package --- app/assets/javascripts/ajax_form.js.erb | 114 +----------------- app/assets/stylesheets/style.css.erb | 6 + app/controllers/admin/designs_controller.rb | 75 +++++++----- app/controllers/admin/purchases_controller.rb | 4 +- app/controllers/sessions_controller.rb | 2 +- app/helpers/application_helper.rb | 4 +- app/models/design/css_default.rb | 5 + app/models/design/css_reset.rb | 5 + app/models/design/design.rb | 34 +++--- app/models/design/design_file.rb | 11 +- app/models/design/image.rb | 24 +++- app/models/design/javascript.rb | 2 +- app/models/design/layout.rb | 2 +- app/models/design/stylesheet.rb | 6 +- app/models/design/theme.rb | 7 +- app/uploaders/image_uploader.rb | 4 +- app/views/admin/designs/_form.html.erb | 78 ++++-------- app/views/admin/designs/_image.html.erb | 6 + app/views/admin/designs/_images.html.erb | 40 ++++++ app/views/admin/designs/_tab_form.html.erb | 8 ++ app/views/admin/designs/edit.html.erb | 44 +++++-- app/views/admin/designs/update_file.js.erb | 1 + app/views/admin/designs/upload_image.html.erb | 9 ++ app/views/devise/sessions/new.html.erb | 4 +- config/routes.rb | 2 + lib/parsers/parser_layout.rb | 2 +- lib/tasks/dev.rake | 4 +- lib/tasks/pages.rake | 4 +- 28 files changed, 256 insertions(+), 251 deletions(-) create mode 100644 app/models/design/css_default.rb create mode 100644 app/models/design/css_reset.rb create mode 100644 app/views/admin/designs/_image.html.erb create mode 100644 app/views/admin/designs/_images.html.erb create mode 100644 app/views/admin/designs/_tab_form.html.erb create mode 100644 app/views/admin/designs/update_file.js.erb create mode 100644 app/views/admin/designs/upload_image.html.erb diff --git a/app/assets/javascripts/ajax_form.js.erb b/app/assets/javascripts/ajax_form.js.erb index 917c352d..80abe23f 100644 --- a/app/assets/javascripts/ajax_form.js.erb +++ b/app/assets/javascripts/ajax_form.js.erb @@ -1,111 +1,7 @@ -<%#= encoding: utf-8 %> -$(document).on('click', '#ajax_form_submit', function(){ - // $('#ajaxForm').ajaxSubmit({ - // beforeSubmit: function(a,f,o) { - // o.dataType = 'script'; - // if (o.dataType == 'script') { - // o.url = o.url.split('?'); // split on GET params - // if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js - // o.url = o.url.join('?'); // join on GET params - // } - // }, - // success: function(response,status,xhr){ - // alert(response); - // alert(status); - // alert(xhr); - // }, - // error:function(){ - // alert("error"); - // } - // }); - - - var o = { - // dataType: 'script', - dataType: 'html', - url:$("#ajaxForm").attr("action"), - beforeSubmit: function(){ - var sub = true; - $("span.error").remove(); - $("#dyn_error").empty(); - $("#ajaxForm input").each(function(){ - if($(this).val() == ""){ - $(" *").insertAfter($(this)); - sub = false; - } - }) - if(!sub){ - $("#dyn_error").text("Cannot be empty."); - $("#dyn_error").text("<%= I18n.t('cant_empty_star') %>"); - return false; - } - }, - success: function(response,status,xhr){ - if(typeof tinyMCEPopup != "undefined"){ - var x = response.split("#"); - var returnurl = x[0], - returntitle = x[1], - returndescription = x[2]; - var win = tinyMCEPopup.getWindowArg("window"); - win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl; - win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription; - win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle; - if (typeof(win.ImageDialog) != "undefined") { - // we are, so update image dimensions... - if (win.ImageDialog.getImageData) - win.ImageDialog.getImageData(); - - // ... and preview if necessary - if (win.ImageDialog.showPreviewImage) - win.ImageDialog.showPreviewImage(returnurl); - } - tinyMCEPopup.close(); - }else{ - //incase if we want to do something for quick edit file upload - // var modalvalues = ""; - // var r = ""; - // if(rcom.getInternetExplorerVersion() > -1){ - // r = "" + response + ""; - // r = r.replace("**",""); - // r = r.replace("**",""); - // r = $(r); - // modalvalues = r.find("span").attr("data-content").split("#"); - // r.attr("id",r.find("span").attr("for")); - // var table=document.getElementById(modalvalues[0]); - // //var tbody = table.getElementsByTagName("tbody"); - // var row = table.insertRow(table.rows.length-1); - // var c1 = row.insertCell(0), - // c2 = row.insertCell(1), - // c3 = row.insertCell(2); - // c1.innerHTML = r.find("td").eq(0).html(); - // c2.innerHTML = r.find("td").eq(1).html(); - // c3.innerHTML = r.find("td").eq(2).html(); - // var trow = $("#bulletin_files tfoot").find("tr").eq(0); - // $("#bulletin_files tbody").append(trow); - // }else{ - - // response = response.replace("**",""); - // response = response.replace("**",""); - // r = $(response); - // modalvalues = r.find("span").attr("data-content").split("#"); - // $('#' + modalvalues[0]+ ' tbody').append(r); - // } - // console.log(modalvalues[1]); - // $("#"+modalvalues[1]).modal('hide'); - //$('#bulletin_files tbody').append(r); - //$(response).fadeIn(); - } - }, - error:function(){ - alert("error"); - } - } - - if (o.dataType == 'script') { - o.url = o.url.split('?'); // split on GET params - if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js - o.url = o.url.join('?'); // join on GET params +$('#ajaxForm').ajaxForm({ + beforeSubmit: function(a,f,o) { + o.dataType = 'script'; + }, + success: function(data) { } - $('#ajaxForm').ajaxSubmit(o); - }); \ No newline at end of file diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index c1d6bdc9..5a8635d3 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -267,6 +267,12 @@ #post-body-content { padding: 8px 0 8px 6px; } +#post-body-content .middle { + width: 100%; + padding: 0; + border: none; + box-shadow: none; +} .filter .accordion-group { margin-bottom: 0; border: none; diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 9d434ff8..0b94317e 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -34,14 +34,37 @@ class Admin::DesignsController < OrbitBackendController def update @design = Design.find(params[:id]) - if @design.update_attributes(params[:design]) - flash[:notice] = "Successfully updated design and tasks." - redirect_to admin_designs_url(@design) - else - render :action => 'edit' + @design.update_attributes(params[:design]) + # if @design.update_attributes(params[:design]) + # flash[:notice] = "Successfully updated design and tasks." + # redirect_to admin_designs_url(@design) + # else + # render :action => 'edit' + # end + + respond_to do |format| + format.js {nil} end end + def update_file + @design = Design.find(params[:id]) + case params[:type] + when 'layout', 'css_default', 'css_reset' + @object = @design.send(params[:type]) + when 'image', 'javascript', 'theme' + @object = @design.send(params[:type]).find(params[:object_id]) + end + + Dir.mktmpdir('f_path') { |dir| + temp_file = File.new(dir + '/' + File.basename(@object.file.url), 'w+') + temp_file.write(params[:file][:content].force_encoding('UTF-8')) + @object.remove_file! + @object.file = temp_file + @object.save + } + end + def edit_file @design = Design.find(params[:id]) filename = params[:filename] @@ -91,6 +114,13 @@ class Admin::DesignsController < OrbitBackendController end redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) end + + def upload_image + @design = Design.find(params[:id]) + @image = @design.images.build(params[:image]) + @image.save + render :layout => false + end protected @@ -98,7 +128,6 @@ class Admin::DesignsController < OrbitBackendController Zip::ZipFile.open(file) { |zip_file| design = Design.new.from_json(zip_file.read("#{zip_name}/info.json")) Dir.mktmpdir('f_path') { |dir| - design.build_layout themes_entries = [] javascripts_entries = [] images_entries = [] @@ -106,25 +135,11 @@ class Admin::DesignsController < OrbitBackendController zip_file.entries.each do |entry| case (path = entry.to_s) when /\A(#{zip_name})\/(default\.css)\z/ #for default css - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - default_css = design.build_default_css - default_css.file = temp_file - default_css.to_save = true + design.build_css_default(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - reset_css = design.build_reset_css - reset_css.file = temp_file - reset_css.to_save = true + design.build_css_reset(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html - filename = File.basename(entry.to_s) - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry ).force_encoding('UTF-8') - design.layout.file = temp_file - design.layout.to_save=true + design.build_layout(:file => get_temp_file(zip_file, dir, entry)) when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css themes_entries << entry when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js @@ -136,12 +151,7 @@ class Admin::DesignsController < OrbitBackendController ['themes', 'javascripts', 'images'].each do |type| eval("#{type}_entries").each do |entry| - filename = File.basename entry.to_s - temp_file = File.new(dir + '/' + filename, 'w+') - temp_file.write (zip_file.read entry).force_encoding('UTF-8') - build_and_store = eval("design.#{type}").build - build_and_store.file = temp_file - build_and_store.to_save = true + eval("design.#{type}").build(:file => get_temp_file(zip_file, dir, entry)) end end } @@ -149,4 +159,11 @@ class Admin::DesignsController < OrbitBackendController } end + def get_temp_file(zip_file, dir, entry) + filename = File.basename(entry.to_s) + temp_file = File.new(dir + '/' + filename, 'w+') + temp_file.write (zip_file.read entry ).force_encoding('UTF-8') + temp_file + end + end diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index ab5b047d..b259c12f 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -71,8 +71,8 @@ class Admin::PurchasesController < ApplicationController Dir.mktmpdir('f_path') { |dir| build_file(orig_zip, zip_name, dir, design.layout) if design.layout - build_file(orig_zip, zip_name, dir, design.default_css) if design.default_css - build_file(orig_zip, zip_name, dir, design.reset_css) if design.reset_css + build_file(orig_zip, zip_name, dir, design.css_default) if design.css_default + build_file(orig_zip, zip_name, dir, design.css_reset) if design.css_reset ['themes', 'javascripts', 'images'].each do |type| design.send(type).each do |object| diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 32315aa5..929c316a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,7 +7,7 @@ class SessionsController < Devise::SessionsController # login_password = params[:user][:password] # login_uid = params[:user][:nccu_ldap_uid] login_password = params[:user][:password] - login_email = params[:user][:login] + login_email = params[:user][:email] result = false resource = User.first(conditions:{ email: login_email }) set_flash_message(:notice, :signed_in) if is_navigational_format? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b9522368..14103d00 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -181,13 +181,13 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end - stylesheets << "\n" if page.design.reset_css + stylesheets << "\n" if page.design.css_reset stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" stylesheets << "\n" - stylesheets << "\n" if page.design.default_css + stylesheets << "\n" if page.design.css_default theme = page.design.themes.detect{ |d| d.id == page.theme_id } stylesheets << "\n" if theme stylesheets diff --git a/app/models/design/css_default.rb b/app/models/design/css_default.rb new file mode 100644 index 00000000..3ee5a58c --- /dev/null +++ b/app/models/design/css_default.rb @@ -0,0 +1,5 @@ +class CssDefault < Stylesheet + + belongs_to :design + +end diff --git a/app/models/design/css_reset.rb b/app/models/design/css_reset.rb new file mode 100644 index 00000000..b2a14b60 --- /dev/null +++ b/app/models/design/css_reset.rb @@ -0,0 +1,5 @@ +class CssReset < Stylesheet + + belongs_to :design + +end diff --git a/app/models/design/design.rb b/app/models/design/design.rb index 58f95bd4..c9d87982 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -3,25 +3,27 @@ class Design include Mongoid::Timestamps include ParserLayout - field :title, :type => String field :author, :type => String field :intro, :type => String + field :title, :type => String field :version, :type => String + has_one :css_default, :autosave => true, :dependent => :destroy + has_one :layout, :autosave => true, :dependent => :destroy + has_one :css_reset, :autosave => true, :dependent => :destroy + has_many :images, :autosave => true, :dependent => :destroy + has_many :javascripts, :autosave => true, :dependent => :destroy has_many :pages - - embeds_one :layout, :cascade_callbacks => true - embeds_one :default_css, :class_name => "Stylesheet", :cascade_callbacks => true - embeds_one :reset_css, :class_name => "Stylesheet", :cascade_callbacks => true - embeds_many :themes, :cascade_callbacks => true - embeds_many :javascripts, :cascade_callbacks => true - embeds_many :images, :as => :design_image, :cascade_callbacks => true - # embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true - - validates_presence_of :title - validates_presence_of :author + has_many :themes, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :images, :allow_destroy => true + accepts_nested_attributes_for :javascripts, :allow_destroy => true + accepts_nested_attributes_for :themes, :allow_destroy => true + + validates_presence_of :author, :title after_save :parse_css_for_images + def new_files=(*attrs) attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs @@ -66,13 +68,9 @@ class Design protected def parse_css_for_images - if (self.default_css && self.default_css.changed) - self.default_css.parse_urls - end + self.css_default.parse_urls self.themes.each do |theme| - if theme.changed? - theme.parse_urls - end + theme.parse_urls end parse_body_for_images(self) end diff --git a/app/models/design/design_file.rb b/app/models/design/design_file.rb index 3aec9a0c..973313c4 100644 --- a/app/models/design/design_file.rb +++ b/app/models/design/design_file.rb @@ -4,7 +4,14 @@ class DesignFile mount_uploader :file, AssetUploader - field :to_save, :type => Boolean - field :to_destroy, :type => Boolean + field :name + + before_save :set_name + + protected + + def set_name + self.name = self.file_identifier + end end diff --git a/app/models/design/image.rb b/app/models/design/image.rb index 939095e8..91c4a733 100644 --- a/app/models/design/image.rb +++ b/app/models/design/image.rb @@ -1,11 +1,23 @@ -class Image < DesignFile +class Image + include Mongoid::Document + include Mongoid::Timestamps - field :in_css, :type => Boolean - field :name field :html_id field :html_class - - embedded_in :design_image, polymorphic: true + field :in_css, :type => Boolean, :default => false + field :in_html, :type => Boolean, :default => false + field :name mount_uploader :file, ImageUploader -end + + belongs_to :design + + before_save :set_name + + protected + + def set_name + self.name = self.file_identifier + end + +end \ No newline at end of file diff --git a/app/models/design/javascript.rb b/app/models/design/javascript.rb index 7bfd2c5a..439e3b98 100644 --- a/app/models/design/javascript.rb +++ b/app/models/design/javascript.rb @@ -1,3 +1,3 @@ class Javascript < DesignFile - embedded_in :design + belongs_to :design end diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index bf48415c..a782894d 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -6,7 +6,7 @@ class Layout < DesignFile field :body embeds_one :menu - embedded_in :design + belongs_to :design embeds_many :layout_parts before_save :parse_layout diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index bb2ec85e..525e40f3 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -1,5 +1,5 @@ class Stylesheet < DesignFile - embedded_in :design + belongs_to :design mount_uploader :file_orig, AssetUploader def parse_urls @@ -11,7 +11,9 @@ class Stylesheet < DesignFile content.scan(/(?<=url)(.*?)(?=\))/){ css_name = $1.gsub(' ','').gsub('(','') name = File.basename(css_name).gsub(/[\\\"]/, '') - file_name = images.detect{ |i| i.file_identifier.eql?(name) }.file_url rescue nil + image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil + image.update_attribute(:in_css, true) if image + file_name = image.file_url rescue nil names << [css_name, file_name] } names.each do |name| diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index 8aca324b..0935fe12 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -1,14 +1,11 @@ class Theme < Stylesheet - field :name - embedded_in :design - - before_save :set_name + belongs_to :design protected def set_name - self.name = File.basename(self.file_identifier,".css") + self.name = File.basename(self.file_identifier, ".css") end end diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 41480fd5..748bac16 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - "image/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + "#{model.id}" end # Provide a default URL as a default if there hasn't been a file uploaded: @@ -48,7 +48,7 @@ class ImageUploader < CarrierWave::Uploader::Base # end version :thumb do - process :resize_to_fit => [200, 200] + process :resize_to_limit => [200, 200] end # Add a white list of extensions which are allowed to be uploaded. diff --git a/app/views/admin/designs/_form.html.erb b/app/views/admin/designs/_form.html.erb index d787a58d..27f45f5f 100644 --- a/app/views/admin/designs/_form.html.erb +++ b/app/views/admin/designs/_form.html.erb @@ -1,60 +1,24 @@ -<% content_for :page_specific_css do %> - <%= stylesheet_link_tag "design" %> -<% end %> -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "design" %> +<%= form_for @design, :url => admin_design_path(@design), :html => {:class => 'form-horizontal'}, :remote => true do |f| %> + <%= f.error_messages %> +
+ <%= f.label :title, t('admin.title'), :class => "control-label" %> +
+ <%= f.text_field :title %> +
+
+
+ <%= f.label :author, t('admin.author'), :class => "control-label" %> +
+ <%= f.text_field :author %> +
+
+
+ <%= f.label :intro, t('admin.intro'), :class => "control-label" %> +
+ <%= f.text_field :intro %> +
+
+ <%= f.submit t('update') %> <% end %> -

- <%= f.label :title, t('admin.title') %> - <%= f.text_field :title, :class => 'text' %> -

-

- <%= f.label :author, t('admin.author') %> - <%= f.text_field :author, :class => 'text' %> -

-

- <%= f.label :intro, t('admin.intro') %> - <%= f.text_field :intro, :class => 'text' %> -

- -

- <%= f.label "layout", t('admin.layout') %> - <% if @design.layout.blank? %> - <%= fields_for 'design[layout]' do |f| %> - <%= f.file_field :file %> - <%#= f.hidden_field :to_save, :value => true %> - <% end %> - <% else %> - <%= File.basename (@design.layout.file.url) %> - <% end %> -

-

- <%= f.label "default_css", t('admin.default_css') %> - <% if @design.default_css.blank? %> - <%= fields_for 'design[default_css]' do |f| %> - <%= f.file_field :file %> - <%#= f.hidden_field :to_save, :value => true %> - <% end %> - <% else %> - <%= File.basename (@design.default_css.file.url) rescue "" %> - <% end %> -

-

- <%= f.label :themes, t('admin.themes') %> -

- <%= render :partial => 'new_design_file', :object => @design.themes.build, :locals => { :field_name => "themes", :f => f, :classes => "r_destroy" } %> -

- -

- <%#= render :partial => 'design_file', :locals => { :object => @design, :field_name => "javascripts", :f => f, :classes => "r_destroy, r_edit" } %> -

- -

- <%#= render :partial => 'design_file', :locals => { :object => @design, :field_name => "images", :f => f, :classes => "r_destroy, r_snapshot" } %> -

diff --git a/app/views/admin/designs/_image.html.erb b/app/views/admin/designs/_image.html.erb new file mode 100644 index 00000000..03482991 --- /dev/null +++ b/app/views/admin/designs/_image.html.erb @@ -0,0 +1,6 @@ + + <%= image.name %> + <%= image_tag image.file.thumb %> + <%= number_to_human_size(image.file.file.file_length) %> + <%= image.file.url %> + \ No newline at end of file diff --git a/app/views/admin/designs/_images.html.erb b/app/views/admin/designs/_images.html.erb new file mode 100644 index 00000000..67d25b17 --- /dev/null +++ b/app/views/admin/designs/_images.html.erb @@ -0,0 +1,40 @@ + + + + + + + + + + + <%= render :partial => 'image', :collection => @design.images %> + +
<%= t(:name) %><%= t(:image) %><%= t(:size) %><%= t(:url) %>
+ + + + + +
+ +
diff --git a/app/views/admin/designs/_tab_form.html.erb b/app/views/admin/designs/_tab_form.html.erb new file mode 100644 index 00000000..e46428ab --- /dev/null +++ b/app/views/admin/designs/_tab_form.html.erb @@ -0,0 +1,8 @@ +<%= form_for :file, :url => update_file_admin_design_path(:type => type, :object_id => object.id), :remote => true, :method => :post do |f| %> +
+ <%= f.text_area :content, :class => 'middle', :value => object.file.read.force_encoding('UTF-8') %> +
+
+ +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/designs/edit.html.erb b/app/views/admin/designs/edit.html.erb index 6ed2287e..7e275111 100644 --- a/app/views/admin/designs/edit.html.erb +++ b/app/views/admin/designs/edit.html.erb @@ -4,10 +4,40 @@

<%= t('admin.editing_design') %>

-<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %> - <%= f.error_messages %> - <%= render :partial => "form", :locals => { :f => f } %> -

- <%= f.submit t('update') %> <%= link_back %> -

-<% end %> + + +
+
<%= render :partial => 'form' %>
+
<%= render :partial => 'tab_form', :locals => {:type => :layout, :object => @design.layout} %>
+
<%= render :partial => 'tab_form', :locals => {:type => :css_default, :object => @design.css_default} %>
+
<%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => @design.css_reset} %>
+ <% @design.themes.each do |theme| %> +
<%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => theme} %>
+ <% end %> + <% @design.javascripts.each do |js| %> +
<%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => js} %>
+ <% end %> +
<%= render :partial => 'images' %>
+
\ No newline at end of file diff --git a/app/views/admin/designs/update_file.js.erb b/app/views/admin/designs/update_file.js.erb new file mode 100644 index 00000000..012aa8a6 --- /dev/null +++ b/app/views/admin/designs/update_file.js.erb @@ -0,0 +1 @@ +// $('.modal').modal('hide') \ No newline at end of file diff --git a/app/views/admin/designs/upload_image.html.erb b/app/views/admin/designs/upload_image.html.erb new file mode 100644 index 00000000..4fb75b8e --- /dev/null +++ b/app/views/admin/designs/upload_image.html.erb @@ -0,0 +1,9 @@ +<% if !request.xhr? %> + +<% end %> \ No newline at end of file diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 8f2be3e9..1ab2e89b 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -11,8 +11,8 @@

You need to sign in or sign up before continuing.

- <%= f.label :login ,t("admin.user_new_interface.email")%> - <%= f.text_field :login, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %> + <%= f.label :email ,t("admin.user_new_interface.email")%> + <%= f.text_field :email, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %> Please correct the error
diff --git a/config/routes.rb b/config/routes.rb index 525d6808..88a39f42 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,6 +58,8 @@ Orbit::Application.routes.draw do end member do post 'edit_file' => 'designs#edit_file' + post 'update_file' => 'designs#update_file' + post 'upload_image' => 'designs#upload_image' end end resources :infos do diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb index 3379c487..817bf327 100644 --- a/lib/parsers/parser_layout.rb +++ b/lib/parsers/parser_layout.rb @@ -22,7 +22,7 @@ module ParserLayout body.css('.page_image').each do |page_image| image = design.images.where( file: File.basename(page_image['src']))[0] - image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image + image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image end end diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 70776ed9..60a7ec93 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -71,7 +71,7 @@ namespace :dev do design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake") - design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # @@ -89,7 +89,7 @@ namespace :dev do design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran") - design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # diff --git a/lib/tasks/pages.rake b/lib/tasks/pages.rake index 8a43f420..598d4b53 100644 --- a/lib/tasks/pages.rake +++ b/lib/tasks/pages.rake @@ -13,7 +13,7 @@ namespace :pages do design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake") - design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) # @@ -37,7 +37,7 @@ namespace :pages do design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran") - design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) + design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css")) # image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif")) #