diff --git a/Gemfile b/Gemfile index 9ed5793..08d319d 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,7 @@ gem 'slim-rails' gem 'paperclip' gem 'email_validator' gem 'actionpack-page_caching' +gem 'font-awesome-rails' # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or # Git. Remember to move these dependencies to your gemspec before releasing diff --git a/Gemfile.lock b/Gemfile.lock index 0447ffc..3974b48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,12 +118,14 @@ GEM activemodel erubis (2.7.0) eventmachine (1.0.7) - execjs (2.3.0) + execjs (2.4.0) factory_girl (4.5.0) activesupport (>= 3.0.0) factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) + font-awesome-rails (4.3.0.0) + railties (>= 3.2, < 5.0) foundation-rails (5.5.1.0) railties (>= 3.1.0) sass (>= 3.3.0, < 3.5) @@ -271,6 +273,7 @@ DEPENDENCIES devise_simply_stored! email_validator factory_girl_rails + font-awesome-rails foundation-rails jquery-rails orm_adapter! diff --git a/app/assets/stylesheets/cmtool/application.css.sass b/app/assets/stylesheets/cmtool/application.css.sass index a22e6af..ec42c37 100644 --- a/app/assets/stylesheets/cmtool/application.css.sass +++ b/app/assets/stylesheets/cmtool/application.css.sass @@ -1,5 +1,6 @@ // require 'bootstrap-devise-rails' // require_directory . +@import font-awesome @import ./foundation_and_overrides @import ./structure @import ./components/* diff --git a/app/controllers/cmtool/images_controller.rb b/app/controllers/cmtool/images_controller.rb index 64b2dd6..40bac1b 100644 --- a/app/controllers/cmtool/images_controller.rb +++ b/app/controllers/cmtool/images_controller.rb @@ -75,10 +75,11 @@ module Cmtool # DELETE /images/1.xml def destroy @image = Cmtool::Image.find(params[:id]) + directory = @image.directory @image.destroy respond_to do |format| - format.html { redirect_to(cmtool.images_url) } + format.html { redirect_to([cmtool, directory || :images]) } format.xml { head :ok } end end diff --git a/app/helpers/cmtool/application_helper.rb b/app/helpers/cmtool/application_helper.rb index 660c71b..cb211a7 100644 --- a/app/helpers/cmtool/application_helper.rb +++ b/app/helpers/cmtool/application_helper.rb @@ -119,15 +119,15 @@ module Cmtool def edit_td(obj) content_tag( - :td, - link_to((content_tag(:span, t('cmtool.table.index.edit'), class: [:edit, 'icon-pencil'])), cmtool.url_for([:edit, obj]), class: [:edit, :btn, 'btn-warning', 'btn-mini']), + :td, + link_to((content_tag(:span, '', class: [:edit, 'fa fa-lg fa-pencil'])), cmtool.url_for([:edit, obj]), class: 'tiny warning button'), class: [:action, :edit] ) end def destroy_td(obj) content_tag( - :td, - link_to(content_tag(:span, t('cmtool.table.index.destroy'), class: [:destroy, 'icon-trash']), cmtool.url_for(obj), method: :delete, confirm: are_you_sure(obj), class: [:destroy, :btn, 'btn-danger', 'btn-mini']), + :td, + link_to(content_tag(:span, '', class: [:destroy, 'fa fa-lg fa-trash']), cmtool.url_for(obj), method: :delete, class: 'tiny alert button', data: {confirm: are_you_sure(obj) }), class: [:action, :destroy] ) end diff --git a/app/models/cmtool/image.rb b/app/models/cmtool/image.rb index c222668..135d18f 100644 --- a/app/models/cmtool/image.rb +++ b/app/models/cmtool/image.rb @@ -7,10 +7,10 @@ module Cmtool property :file_content_type property :file_file_size, type: Fixnum property :file_updated_at, type: Time - has_attached_file :file, styles: { page: '675x10000>', medium: "354x1000>", thumb: "150x1250>" }, + has_attached_file :file, styles: { page: '728x10000>', medium: "354x1000>", thumb: "160x1250>" }, path: ":rails_root/public/system/:attachment/:id/:style.:extension", url: "/system/:attachment/:id/:style.:extension" - do_not_validate_attachment_file_type :file + validates_attachment :file, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] } belongs_to :directory diff --git a/app/views/cmtool/application/_error_messages.html.slim b/app/views/cmtool/application/_error_messages.html.slim index e8c78ad..5f557f8 100644 --- a/app/views/cmtool/application/_error_messages.html.slim +++ b/app/views/cmtool/application/_error_messages.html.slim @@ -1,6 +1,6 @@ -if target.errors.any? - #errorExplanation - h2= t('cmtool.errors.form.title', :count => target.errors.count) + .alert-box.alert + h2= t('cmtool.errors.form.title', count: target.errors.count) ul - target.errors.full_messages.each do |msg| li= msg diff --git a/app/views/cmtool/directories/_image.html.slim b/app/views/cmtool/directories/_image.html.slim index 7158db8..7b1d05b 100644 --- a/app/views/cmtool/directories/_image.html.slim +++ b/app/views/cmtool/directories/_image.html.slim @@ -2,4 +2,4 @@ tr td.image.thumb= link_to(image_tag(image.file.url(:thumb)), cmtool.image_path(image)) td= link_to image.clean_name, cmtool.image_path(image) td - td.action.destroy.directory= link_to link_to_destroy_content(image), cmtool.image_path(image), :method => :delete, :confirm => are_you_sure(image) + = destroy_td(image) diff --git a/app/views/cmtool/directories/show.html.slim b/app/views/cmtool/directories/show.html.slim index edeeefc..4bb25ab 100644 --- a/app/views/cmtool/directories/show.html.slim +++ b/app/views/cmtool/directories/show.html.slim @@ -1,16 +1,15 @@ - title :show, Cmtool::Directory - content_for :onload_javascript do | $('.add-image-container').dialog({modal: true, autoOpen: false, width: 400}) -#add-image-container.modal.hide.fade +#add-image-container.reveal-modal data-reveal=true .modal-header= t('cmtool.directory.add_file') - = form_for [cmtool, Cmtool::Image.new(directory_id: @directory.id)], :html => { :multipart => true, :id => 'add_image_form' } do |f| + = form_for [cmtool, Cmtool::Image.new(directory_id: @directory.id)], html: { multipart: true, id: 'add_image_form' } do |f| .modal-body = f.hidden_field :directory_id = f.file_field :file - .modal-footer - a.secondary.button href: '#', role: :button, data: {dismiss: :modal}, 'aria-hidden' => true x - = f.submit t('cmtool.directory.add_image.label', image: Cmtool::Image.model_name.human), class: 'record-new-button' -.directory.caption= "/# @directory.tree_path.map{|d| link_to(d.name, cmtool.directory_path(d))}.join('/') ".html_safe + .modal-footer= f.submit t('cmtool.directory.add_image.label', image: Cmtool::Image.model_name.human), class: 'record-new-button' + a.close-reveal-modal × +.directory.caption= "/#{@directory.tree_path.map{|d| link_to(d.name, cmtool.directory_path(d))}.join('/')}".html_safe table#directory-view.table.table-striped.table-hover thead tbody @@ -24,13 +23,13 @@ table#directory-view.table.table-striped.table-hover td.directory.child= link_to child.name, cmtool.directory_path(child) td td - td.action.destroy.directory= link_to link_to_destroy_content(child), cmtool.directory_path(child), :method => :delete, :confirm => are_you_sure(child) + td.action.destroy.directory= link_to link_to_destroy_content(child), cmtool.directory_path(child), method: :delete, confirm: are_you_sure(child) - for image in @directory.images - = render 'image', :image => image + = render 'image', image: image - content_for :page_links do ul - if @directory.parent li= link_to '..', cmtool.directory_path(@directory.parent) li= link_to link_to_edit_content(@directory), cmtool.edit_directory_path(@directory), class: 'record-edit-button' li= link_to link_to_index_content(Cmtool::Directory), cmtool.directories_path, class: 'to-index-button' - li= link_to t('cmtool.directory.add_file'), '#add-image-container', class: 'record-new-button', role: :button, data: toggle: :modal + li= link_to t('cmtool.directory.add_file'), '#', class: 'record-new-button', data: {'reveal-id' => 'add-image-container'} diff --git a/app/views/cmtool/images/_form.html.slim b/app/views/cmtool/images/_form.html.slim index 0f2b10c..e2c5227 100644 --- a/app/views/cmtool/images/_form.html.slim +++ b/app/views/cmtool/images/_form.html.slim @@ -1,12 +1,12 @@ -= form_for [cmtool, @image], :html => {:multipart => true} do |f| - = render 'error_messages', :target => @image += form_for [cmtool, @image], html: {multipart: true} do |f| + = render 'error_messages', target: @image .field = f.label :file, Cmtool::Image.model_name.human = f.file_field :file .field = f.label :directory_id, Cmtool::Directory.model_name.human - = f.select :directory_id, Cmtool::Directory.all.map{|d| ["-"*d.depth + ' ' + d.name.to_s, d.id]} + = f.select :directory_id, Cmtool::Directory.all.map{|d| ["-"*d.tree_depth + ' ' + d.name.to_s, d.id]} .actions = f.submit @submit || update_button_text(@image) diff --git a/app/views/cmtool/images/index.js.erb b/app/views/cmtool/images/index.js.erb index 2c699b8..248041d 100644 --- a/app/views/cmtool/images/index.js.erb +++ b/app/views/cmtool/images/index.js.erb @@ -1,8 +1,8 @@ <%=raw Cmtool::Image.active.map{|i| [ {title: "#{i.clean_name} (Origineel)", value: i.file.url(:original)}, - {title: "#{i.clean_name} (Pagina)", value: i.file.url(:page)}, - {title: "#{i.clean_name} (Medium)", value: i.file.url(:medium)}, - {title: "#{i.clean_name} (Thumb)", value: i.file.url(:thumb)} + {title: "#{i.clean_name} (728)", value: i.file.url(:page)}, + {title: "#{i.clean_name} (354)", value: i.file.url(:medium)}, + {title: "#{i.clean_name} (160)", value: i.file.url(:thumb)} ] }.flatten.to_json %> diff --git a/app/views/cmtool/users/edit.html.slim b/app/views/cmtool/users/edit.html.slim index a60e188..ae080dd 100644 --- a/app/views/cmtool/users/edit.html.slim +++ b/app/views/cmtool/users/edit.html.slim @@ -3,6 +3,5 @@ - content_for :page_links do ul - li= link_to link_to_show_content(@user), cmtool.user_path(@user) - - li= link_to link_to_index_content(User), cmtool.users_path + li= link_to link_to_show_content(@user), cmtool.user_path(@user), class: 'record-show-button' + li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button' diff --git a/app/views/cmtool/users/index.html.slim b/app/views/cmtool/users/index.html.slim index f4e56ba..6b6a6f8 100644 --- a/app/views/cmtool/users/index.html.slim +++ b/app/views/cmtool/users/index.html.slim @@ -17,4 +17,4 @@ - content_for :page_links do ul - li= link_to link_to_new_content(User), cmtool.new_user_path + li= link_to link_to_new_content(User), cmtool.new_user_path, class: 'record-new-button' diff --git a/app/views/cmtool/users/new.html.slim b/app/views/cmtool/users/new.html.slim index a6ede4b..b532f7c 100644 --- a/app/views/cmtool/users/new.html.slim +++ b/app/views/cmtool/users/new.html.slim @@ -3,4 +3,4 @@ - content_for :page_links do ul - li= link_to link_to_index_content(User), cmtool.users_path + li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button' diff --git a/app/views/cmtool/users/show.html.slim b/app/views/cmtool/users/show.html.slim index 79262c7..c813e31 100644 --- a/app/views/cmtool/users/show.html.slim +++ b/app/views/cmtool/users/show.html.slim @@ -33,6 +33,5 @@ span.show_value.boolean= boolean_text(@user.active?) - content_for :page_links do ul - li= link_to link_to_edit_content(@user), cmtool.edit_user_path(@user) - - li= link_to link_to_index_content(User), cmtool.users_path + li= link_to link_to_edit_content(@user), cmtool.edit_user_path(@user), class: 'record-edit-button' + li= link_to link_to_index_content(User), cmtool.users_path, class: 'to-index-button'