diff --git a/Gemfile b/Gemfile index b7957c61..45efc228 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,8 @@ gem 'RedCloth' gem 'inherited_resources', '1.1.2' gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git' gem 'jeweler' +gem 'delayed_job', '2.1.0.pre2' +gem 'delayed_job_mongoid', '1.0.0.rc' # Development environment group :development do diff --git a/Gemfile.lock b/Gemfile.lock index dadf9dfa..c580f383 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,7 +63,7 @@ GEM arel (1.0.1) activesupport (~> 3.0.0) autotest (4.3.2) - aws (2.3.20) + aws (2.3.21) http_connection uuidtools xml-simple @@ -84,17 +84,23 @@ GEM columnize (0.3.1) configuration (1.1.0) crack (0.1.8) - cucumber (0.8.5) + cucumber (0.9.0) builder (~> 2.1.2) diff-lcs (~> 1.1.2) - gherkin (~> 2.1.4) - json_pure (~> 1.4.3) - term-ansicolor (~> 1.0.4) + gherkin (~> 2.2.2) + json (~> 1.4.6) + term-ansicolor (~> 1.0.5) cucumber-rails (0.3.2) cucumber (>= 0.8.0) culerity (0.2.12) daemons (1.1.0) database_cleaner (0.5.2) + delayed_job (2.1.0.pre2) + activesupport (~> 3.0) + daemons + delayed_job_mongoid (1.0.0.rc) + delayed_job (~> 2.1) + mongoid (~> 2.0) devise (1.1.2) bcrypt-ruby (~> 2.1.2) warden (~> 0.10.7) @@ -113,17 +119,19 @@ GEM activesupport (>= 3.0.0beta3) gem_plugin (0.2.3) gemcutter (0.6.1) - gherkin (2.1.5) + gherkin (2.2.3) + json (~> 1.4.6) + term-ansicolor (~> 1.0.5) trollop (~> 1.16.2) git (1.2.5) growl-glue (1.0.7) haml (3.0.18) has_scope (0.5.0) - heroku (1.10.2) + heroku (1.10.5) json_pure (>= 1.2.0, < 1.5.0) launchy (~> 0.3.2) rest-client (~> 1.4.0) - http_connection (1.3.0) + http_connection (1.3.1) httparty (0.6.1) crack (= 0.1.8) i18n (0.4.1) @@ -134,6 +142,7 @@ GEM gemcutter (>= 0.1.0) git (>= 1.2.5) rubyforge (>= 2.0.0) + json (1.4.6) json_pure (1.4.6) launchy (0.3.7) configuration (>= 0.0.5) @@ -216,7 +225,7 @@ GEM rubyzip spork (0.8.4) term-ansicolor (1.0.5) - thor (0.14.0) + thor (0.14.1) treetop (1.4.8) polyglot (>= 0.3.1) trollop (1.16.2) @@ -248,6 +257,8 @@ DEPENDENCIES cucumber-rails custom_fields! database_cleaner + delayed_job (= 2.1.0.pre2) + delayed_job_mongoid (= 1.0.0.rc) devise (= 1.1.2) factory_girl_rails fastthread diff --git a/app/controllers/admin/snippets_controller.rb b/app/controllers/admin/snippets_controller.rb index efab2e74..c9dbb1d3 100644 --- a/app/controllers/admin/snippets_controller.rb +++ b/app/controllers/admin/snippets_controller.rb @@ -1,12 +1,14 @@ module Admin class SnippetsController < BaseController - sections 'settings' + sections 'settings', 'theme_assets' respond_to :json, :only => :update - def index - @snippets = current_site.snippets.order_by([[:name, :asc]]) + def destroy + destroy! do |format| + format.html { redirect_to admin_theme_assets_url } + end end end diff --git a/app/controllers/admin/theme_assets_controller.rb b/app/controllers/admin/theme_assets_controller.rb index 9a9d614b..e4f79bd6 100644 --- a/app/controllers/admin/theme_assets_controller.rb +++ b/app/controllers/admin/theme_assets_controller.rb @@ -10,13 +10,15 @@ module Admin respond_to :json, :only => [:create, :update] def index - assets = current_site.theme_assets.all + assets = current_site.theme_assets.all.to_a @non_image_assets = assets.find_all { |a| a.stylesheet? || a.javascript? } @image_assets = assets.find_all { |a| a.image? } @flash_assets = assets.find_all { |a| a.movie? } if request.xhr? render :action => 'images', :layout => false and return + else + @snippets = current_site.snippets.order_by([[:name, :asc]]).all.to_a end end diff --git a/app/views/admin/shared/menu/_settings.html.haml b/app/views/admin/shared/menu/_settings.html.haml index 5aa5fda5..d929cea6 100644 --- a/app/views/admin/shared/menu/_settings.html.haml +++ b/app/views/admin/shared/menu/_settings.html.haml @@ -1,5 +1,5 @@ %ul = admin_submenu_item 'site', edit_admin_current_site_url - = admin_submenu_item 'snippets', admin_snippets_url + / = admin_submenu_item 'snippets', admin_snippets_url = admin_submenu_item 'theme_assets', admin_theme_assets_url = admin_submenu_item 'account', edit_admin_my_account_url \ No newline at end of file diff --git a/app/views/admin/snippets/_snippet.html.haml b/app/views/admin/snippets/_snippet.html.haml index 7ecd731a..7a389608 100644 --- a/app/views/admin/snippets/_snippet.html.haml +++ b/app/views/admin/snippets/_snippet.html.haml @@ -1,4 +1,16 @@ +/ - per_row = local_assigns[:per_row] || 6 +/ - snippet_counter = local_assigns[:snippet_counter] || 0 +/ +/ %li{ :class => "asset #{'last' if (snippet_counter + 1) % per_row == 0}"} +/ %h4= link_to truncate(snippet.slug, :length => 18), edit_admin_snippet_path(snippet) +/ .image +/ .inside +/ / = vignette_tag(asset) +/ .actions +/ = link_to image_tag('admin/list/icons/cross.png'), admin_snippet_path(snippet), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete + %li + %em %strong= link_to snippet.name, edit_admin_snippet_path(snippet) .more %span!= t('.updated_at') diff --git a/app/views/admin/snippets/edit.html.haml b/app/views/admin/snippets/edit.html.haml index 0db10f59..5f8b080d 100644 --- a/app/views/admin/snippets/edit.html.haml +++ b/app/views/admin/snippets/edit.html.haml @@ -12,4 +12,4 @@ = render 'form', :f => form - = render 'admin/shared/form_actions', :back_url => admin_snippets_url, :button_label => :update \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :update \ No newline at end of file diff --git a/app/views/admin/snippets/new.html.haml b/app/views/admin/snippets/new.html.haml index b29290c7..add05e7a 100644 --- a/app/views/admin/snippets/new.html.haml +++ b/app/views/admin/snippets/new.html.haml @@ -9,4 +9,4 @@ = render 'form', :f => form - = render 'admin/shared/form_actions', :back_url => admin_snippets_url, :button_label => :create \ No newline at end of file + = render 'admin/shared/form_actions', :back_url => admin_theme_assets_url, :button_label => :create \ No newline at end of file diff --git a/app/views/admin/theme_assets/index.html.haml b/app/views/admin/theme_assets/index.html.haml index ddee24cc..6607930b 100644 --- a/app/views/admin/theme_assets/index.html.haml +++ b/app/views/admin/theme_assets/index.html.haml @@ -4,10 +4,20 @@ = render 'admin/shared/menu/settings' - content_for :buttons do + = admin_button_tag t('admin.snippets.index.new'), new_admin_snippet_url, :class => 'new' = admin_button_tag :new, new_admin_theme_asset_url, :class => 'new' %p!= t('.help') +%h3!= t('.snippets') +- if @snippets.empty? + %p.no-items!= t('.no_items', :url => new_admin_snippet_url) +- else + %ul#snippets-list.list + = render @snippets + +%br + %h3!= t('.css_and_js') - if @non_image_assets.empty? %p.no-items!= t('.no_items', :url => new_admin_theme_asset_url) diff --git a/config/initializers/haml.rb b/config/initializers/haml.rb new file mode 100644 index 00000000..df0b4de4 --- /dev/null +++ b/config/initializers/haml.rb @@ -0,0 +1 @@ +Haml::Template.options[:ugly] = true # improve performance in dev \ No newline at end of file diff --git a/config/locales/admin_ui_en.yml b/config/locales/admin_ui_en.yml index aedf7912..bec51543 100644 --- a/config/locales/admin_ui_en.yml +++ b/config/locales/admin_ui_en.yml @@ -156,8 +156,9 @@ en: theme_assets: index: title: Listing theme files - help: "Theme assets represent files needed by layouts and snippets. If you need to manage an image gallery, go to the Assets section instead." + help: "The theme files section is the place where you manage the files needed by your layout, ...etc. If you need to manage an image gallery, go to the Assets section instead." new: new file + snippets: Snippets css_and_js: Style and javascript fonts: Fonts images: Images diff --git a/config/locales/admin_ui_fr.yml b/config/locales/admin_ui_fr.yml index 4c80982a..ef92c6f2 100644 --- a/config/locales/admin_ui_fr.yml +++ b/config/locales/admin_ui_fr.yml @@ -156,8 +156,9 @@ fr: theme_assets: index: title: Liste des fichiers du thème - help: "Les fichiers du thème sont utilisés par les gabarits et les snippets. Si vous avez besoin d'une galerie d'images, la section Média est plus adéquate." + help: "Les fichiers du thème sont utilisés pour construire le gabarit de vos pages. Si vous avez besoin d'une galerie d'images, la section Média est plus adéquate." new: nouveau fichier + snippets: Snippets css_and_js: Style et javascript images: Images flashes: Flash diff --git a/public/stylesheets/admin/application.css b/public/stylesheets/admin/application.css index a5f5eecb..5c3b2654 100644 --- a/public/stylesheets/admin/application.css +++ b/public/stylesheets/admin/application.css @@ -120,6 +120,22 @@ div#uploadAssetsInputQueue { display: none; } background: transparent url(/images/admin/list/item-right.png) no-repeat right 0; } +/* ___ snippets ___ */ + +#snippets-list { margin-left: 40px; } + +#snippets-list li { background: none; } + +#snippets-list li em { + background-position: left 0px; +} + +#snippets-list li strong { + margin-left: 18px; + display: block; + height: 31px; + background: transparent url(/images/admin/list/item-right.png) no-repeat right 0; +} /* ___ pages ___ */