can seperate files as images and not. small css adjustments
Oleg
committed Oct 04, 2011
commit 4613e5efa392b337ceb624dd13d0ed2801daad5e
Showing 10
changed files with
72 additions
and 33 deletions
app/assets/stylesheets/comfortable_mexican_sofa/content.css
+24
-15
| @@ | @@ -37,14 +37,17 @@ |
| max-height: 500px; | |
| overflow-y: auto; | |
| } | |
| + | #cms_body #file_uploads #uploaded_files h3 { |
| + | margin-top: 5px; |
| + | font: 11px/20px Arial, sans-serif; |
| + | text-transform: uppercase; |
| + | } |
| #cms_body #file_uploads #uploaded_files .file { | |
| - | position: relative; |
| overflow: hidden; | |
| - | font-size: 11px; |
| + | font: 11px/11px Arial, serif; |
| background-color: #252525; | |
| - | margin-top: 2px; |
| - | padding: 0px 3px; |
| - | opacity: 0.5; |
| + | margin-top: 1px; |
| + | padding: 3px 5px; |
| border-radius: 2px; | |
| -moz-border-radius: 2px; | |
| } | |
| @@ | @@ -52,22 +55,28 @@ |
| opacity: 0.3; | |
| } | |
| #cms_body #file_uploads #uploaded_files .file:hover { | |
| - | opacity: 1; |
| + | background-color: #000; |
| } | |
| #cms_body #file_uploads #uploaded_files .file a { | |
| color: #fff; | |
| } | |
| + | #cms_body #file_uploads #uploaded_files .file a.filename { |
| + | float: left; |
| + | width: 175px; |
| + | overflow: hidden; |
| + | } |
| #cms_body #file_uploads #uploaded_files .file a.delete { | |
| - | position: absolute; |
| - | display: block; |
| - | right: 0px; |
| - | top: 0px; |
| - | height: 13px; |
| - | width: 13px; |
| - | font-weight: bold; |
| + | float: right; |
| + | margin-left: 7px; |
| + | background-color: #b7b7b7; |
| + | color: #000; |
| + | font: 8px/8px Arial, sans-serif; |
| + | padding: 1px 3px; |
| + | border-radius: 5px; |
| } | |
| - | #cms_body #file_uploads #uploaded_files .file:hover a.delete { |
| - | color: #9e0b0f; |
| + | #cms_body #file_uploads #uploaded_files .file a.delete:hover { |
| + | background-color: #fff; |
| + | color: #9E0B0F; |
| } | |
| /* -- Categories Widget -------------------------------------------------- */ | |
| #cms_body .categories_widget { | |
app/assets/stylesheets/comfortable_mexican_sofa/form.css
+6
-8
| @@ | @@ -19,8 +19,6 @@ |
| } | |
| #cms_body .form_element .value { | |
| margin-left: 150px; | |
| - | margin-right: -140px; |
| - | overflow: hidden; |
| } | |
| #cms_body .form_element .value input[type='text'], | |
| #cms_body .form_element .value input[type='password'], | |
| @@ | @@ -82,27 +80,26 @@ |
| background-color: #484848; | |
| border-radius: 3px; | |
| color: #fff; | |
| - | height: 9px; |
| + | height: 11px; |
| padding: 3px 5px; | |
| margin: 0px 5px 5px 0px; | |
| } | |
| #cms_body #form_blocks .files .file a { | |
| float: left; | |
| color: #fff; | |
| - | font: 9px/9px Arial, serif; |
| - | text-transform: uppercase; |
| + | font: 11px/11px Arial, serif; |
| } | |
| #cms_body #form_blocks .files .file:hover { | |
| background-color: #000; | |
| } | |
| #cms_body #form_blocks .files .file a.delete { | |
| float: right; | |
| - | margin-left: 5px; |
| + | margin-left: 7px; |
| background-color: #b7b7b7; | |
| color: #000; | |
| - | font: bold 7px/7px Arial, sans-serif; |
| + | font: 7px/8px Arial, sans-serif; |
| padding: 1px 3px; | |
| - | border-radius: 4px; |
| + | border-radius: 5px; |
| } | |
| #cms_body #form_blocks .files .file a.delete:hover { | |
| background-color: #fff; | |
| @@ | @@ -144,6 +141,7 @@ |
| margin-top: 10px; | |
| } | |
| #cms_body .form_element.submit_element .value { | |
| + | overflow: hidden; |
| background-color: #f1f1f1; | |
| border-radius: 3px; | |
| -moz-border-radius: 3px; | |
app/controllers/cms_admin/files_controller.rb
+1
-1
| @@ | @@ -6,7 +6,7 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController |
| def index | |
| return redirect_to :action => :new if @site.files.count == 0 | |
| - | @files = @site.files.includes(:categories).for_category(params[:category]).all(:order => 'cms_files.label') |
| + | @files = @site.files.includes(:categories).for_category(params[:category]).all(:order => 'cms_files.position') |
| end | |
| def new | |
app/models/cms/file.rb
+4
-1
| @@ | @@ -1,5 +1,7 @@ |
| class Cms::File < ActiveRecord::Base | |
| + | IMAGE_MIMETYPES = %w(gif jpeg pjpeg png svg+xml tiff).collect{|subtype| "image/#{subtype}"} |
| + | |
| ComfortableMexicanSofa.establish_connection(self) | |
| set_table_name :cms_files | |
| @@ | @@ -24,7 +26,8 @@ class Cms::File < ActiveRecord::Base |
| after_destroy :reload_page_cache | |
| # -- Scopes --------------------------------------------------------------- | |
| - | default_scope order(:position) |
| + | scope :images, where(:file_content_type => IMAGE_MIMETYPES) |
| + | scope :not_images, where('file_content_type NOT IN (?)', IMAGE_MIMETYPES) |
| protected | |
app/views/cms_admin/files/_index.html.erb
+15
-2
| @@ | @@ -6,8 +6,21 @@ |
| <% end %> | |
| <div id='uploaded_files'> | |
| - | <% Cms::File.order('label').all.each do |file| %> |
| - | <%= render :partial => 'cms_admin/files/file', :object => file %> |
| + | <% if (images = Cms::File.images.order(:label)).present? %> |
| + | <div class='section images'> |
| + | <h3>Images</h3> |
| + | <% images.each do |file| %> |
| + | <%= render :partial => 'cms_admin/files/file', :object => file %> |
| + | <% end %> |
| + | </div> |
| + | <% end %> |
| + | <% if (images = Cms::File.not_images.order(:label)).present? %> |
| + | <div class='section other'> |
| + | <h3>Files</h3> |
| + | <% images.each do |file| %> |
| + | <%= render :partial => 'cms_admin/files/file', :object => file %> |
| + | <% end %> |
| + | </div> |
| <% end %> | |
| </div> | |
| </div> | |
| \ No newline at end of file | |
config/routes.rb
+3
-3
| @@ | @@ -6,13 +6,13 @@ Rails.application.routes.draw do |
| resources :pages do | |
| get :form_blocks, :on => :member | |
| get :toggle_branch, :on => :member | |
| - | post :reorder, :on => :collection |
| + | put :reorder, :on => :collection |
| resources :revisions, :only => [:index, :show, :revert] do | |
| put :revert, :on => :member | |
| end | |
| end | |
| resources :files do | |
| - | post :reorder, :on => :collection |
| + | put :reorder, :on => :collection |
| end | |
| resources :layouts do | |
| post :reorder, :on => :collection | |
| @@ | @@ -21,7 +21,7 @@ Rails.application.routes.draw do |
| end | |
| end | |
| resources :snippets do | |
| - | post :reorder, :on => :collection |
| + | put :reorder, :on => :collection |
| resources :revisions, :only => [:index, :show, :revert] do | |
| put :revert, :on => :member | |
| end | |
test/functional/cms_admin/files_controller_test.rb
+1
-1
| @@ | @@ -173,7 +173,7 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase |
| assert_equal 0, file_one.position | |
| assert_equal 1, file_two.position | |
| - | post :reorder, :site_id => cms_sites(:default), :cms_file => [file_two.id, file_one.id] |
| + | put :reorder, :site_id => cms_sites(:default), :cms_file => [file_two.id, file_one.id] |
| assert_response :success | |
| file_one.reload | |
| file_two.reload | |
test/functional/cms_admin/layouts_controller_test.rb
+1
-1
| @@ | @@ -111,7 +111,7 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase |
| assert_equal 0, layout_one.position | |
| assert_equal 1, layout_two.position | |
| - | post :reorder, :site_id => cms_sites(:default), :cms_layout => [layout_two.id, layout_one.id] |
| + | put :reorder, :site_id => cms_sites(:default), :cms_layout => [layout_two.id, layout_one.id] |
| assert_response :success | |
| layout_one.reload | |
| layout_two.reload | |
test/functional/cms_admin/pages_controller_test.rb
+1
-1
| @@ | @@ -406,7 +406,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase |
| assert_equal 0, page_one.position | |
| assert_equal 1, page_two.position | |
| - | post :reorder, :site_id => cms_sites(:default), :cms_page => [page_two.id, page_one.id] |
| + | put :reorder, :site_id => cms_sites(:default), :cms_page => [page_two.id, page_one.id] |
| assert_response :success | |
| page_one.reload | |
| page_two.reload | |
test/unit/models/file_test.rb
+16
-0
| @@ | @@ -31,4 +31,20 @@ class CmsFileTest < ActiveSupport::TestCase |
| cms_sites(:default).files.create(:file => '') | |
| end | |
| end | |
| + | |
| + | def test_image_mimetypes |
| + | assert_equal %w(image/gif image/jpeg image/pjpeg image/png image/svg+xml image/tiff), |
| + | Cms::File::IMAGE_MIMETYPES |
| + | end |
| + | |
| + | def test_images_scope |
| + | file = cms_files(:default) |
| + | assert_equal 'image/jpeg', file.file_content_type |
| + | assert_equal 1, Cms::File.images.count |
| + | assert_equal 0, Cms::File.not_images.count |
| + | |
| + | file.update_attribute(:file_content_type, 'application/pdf') |
| + | assert_equal 0, Cms::File.images.count |
| + | assert_equal 1, Cms::File.not_images.count |
| + | end |
| end | |