more crap
Oleg
committed Oct 14, 2011
commit 7666b9e84c1859e348cc5d01650c6511bd11f9bf
Showing 16
changed files with
124 additions
and 103 deletions
app/assets/images/comfortable_mexican_sofa/x.png
+0
-0
app/assets/javascripts/comfortable_mexican_sofa/application.js
+5
-4
| @@ | @@ -79,12 +79,13 @@ $.CMS = function(){ |
| }, | |
| enable_rich_text: function(){ | |
| - | elRTE.prototype.options.panels.sofa_style = ['bold', 'italic', 'underline', 'strikethrough']; |
| + | elRTE.prototype.options.panels.sofa_style = ['bold', 'italic', 'underline']; |
| + | elRTE.prototype.options.panels.sofa_alignment = ['justifyleft', 'justifycenter', 'justifyright']; |
| elRTE.prototype.options.panels.sofa_format = ['formatblock']; | |
| elRTE.prototype.options.panels.sofa_copypaste = ['pasteformattext']; | |
| elRTE.prototype.options.panels.sofa_links = ['sofa_link', 'unlink']; | |
| - | elRTE.prototype.options.toolbars.sofa = ['undoredo', 'sofa_format', 'sofa_style', 'alignment', 'lists', 'sofa_copypaste', 'sofa_links', 'sofa_image']; |
| + | elRTE.prototype.options.toolbars.sofa = ['undoredo', 'sofa_format', 'sofa_style', 'sofa_alignment', 'lists', 'sofa_copypaste', 'sofa_links', 'sofa_image']; |
| $('textarea.rich_text').elrte({ | |
| height: 300, | |
| @@ | @@ -161,8 +162,8 @@ $.CMS = function(){ |
| }, | |
| enable_uploader : function(){ | |
| - | var action = $('#file_uploads form').attr('action'); |
| - | $('#file_uploads input#file_file').change(function(){ |
| + | var action = $('.file_uploads form').attr('action'); |
| + | $('.file_uploads input[type=file]').change(function(){ |
| var files = $($(this).get(0).files); | |
| files.each(function(i, file){ | |
| var xhr = new XMLHttpRequest(); | |
app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
+8
-5
| @@ | @@ -7,19 +7,22 @@ |
| var cms_dialog = jQuery(jQuery('#cms_dialog').get(0) || jQuery('<div id="cms_dialog"></div>')); | |
| cms_dialog.dialog({ | |
| + | title : rte.i18n('Image'), |
| modal : true, | |
| resizable : false, | |
| + | width : 800, |
| closeOnEscape : true, | |
| autoOpen : false | |
| }); | |
| jQuery.ajax({ | |
| - | url: '/' + $('meta[name="cms-admin-path"]').attr('content') + |
| - | '/sites/' + |
| - | $('meta[name="cms-site-id"]').attr('content') + |
| - | '/dialogs/images' |
| + | url: '/' + $('meta[name="cms-admin-path"]').attr('content') + '/sites/' + $('meta[name="cms-site-id"]').attr('content') + '/dialog/image', |
| + | success: function(data){ |
| + | cms_dialog.html(data); |
| + | cms_dialog.dialog('open'); |
| + | $.CMS.enable_uploader(); |
| + | } |
| }) | |
| - | |
| } | |
| this.update = function(){ | |
app/assets/stylesheets/comfortable_mexican_sofa/application.css
+1
-0
| @@ | @@ -4,6 +4,7 @@ |
| = require comfortable_mexican_sofa/structure.css | |
| = require comfortable_mexican_sofa/form.css | |
| = require comfortable_mexican_sofa/content.css | |
| + | = require comfortable_mexican_sofa/files.css |
| = require comfortable_mexican_sofa/codemirror.css | |
| = require comfortable_mexican_sofa/jquery_ui.css | |
| = require comfortable_mexican_sofa/widgets.css | |
app/assets/stylesheets/comfortable_mexican_sofa/content.css
+0
-65
| @@ | @@ -13,71 +13,6 @@ |
| #cms_body #page_save input { | |
| margin-right: 5px; | |
| } | |
| - | /* -- File Upload widget ------------------------------------------------- */ |
| - | #cms_body #file_uploads form { |
| - | position: relative; |
| - | height: 21px; |
| - | overflow: hidden |
| - | } |
| - | #cms_body #file_uploads form input { |
| - | position: absolute; |
| - | margin-top: -1px; |
| - | right: 0px; |
| - | top: 0px; |
| - | font-size: 220px; |
| - | opacity: 0; |
| - | } |
| - | #cms_body #file_uploads .actions { |
| - | overflow: hidden; |
| - | } |
| - | #cms_body #file_uploads .actions a.button { |
| - | float: right; |
| - | } |
| - | #cms_body #file_uploads #uploaded_files { |
| - | 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 { |
| - | overflow: hidden; |
| - | font: 11px/11px Arial, sans-serif; |
| - | background-color: #252525; |
| - | margin-top: 1px; |
| - | padding: 3px 5px; |
| - | border-radius: 2px; |
| - | -moz-border-radius: 2px; |
| - | } |
| - | #cms_body #file_uploads #uploaded_files .file.pending { |
| - | opacity: 0.3; |
| - | } |
| - | #cms_body #file_uploads #uploaded_files .file:hover { |
| - | 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 { |
| - | 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 a.delete:hover { |
| - | background-color: #fff; |
| - | color: #9E0B0F; |
| - | } |
| /* -- Categories Widget -------------------------------------------------- */ | |
| #cms_body .categories_widget { | |
| margin-bottom: 10px; | |
app/assets/stylesheets/comfortable_mexican_sofa/files.css
+66
-0
| @@ | @@ -0,0 +1,66 @@ |
| + | #cms_body .right_column_content .file_uploads.box { |
| + | overflow: visible; |
| + | } |
| + | #cms_body .file_uploads form { |
| + | position: relative; |
| + | height: 21px; |
| + | overflow: hidden |
| + | } |
| + | #cms_body .file_uploads form input { |
| + | position: absolute; |
| + | margin-top: -1px; |
| + | right: 0px; |
| + | top: 0px; |
| + | font-size: 220px; |
| + | opacity: 0; |
| + | } |
| + | /* -- Right Column Widget ------------------------------------------------ */ |
| + | #cms_body .right_column_content .file_uploads .file { |
| + | position: relative; |
| + | background-color: #252525; |
| + | font: 12px/12px Arial, sans-serif; |
| + | height: 11px; |
| + | margin-top: 1px; |
| + | padding: 3px 5px; |
| + | border-radius: 2px; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file a { |
| + | color: #f1f1f1; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file a.filename { |
| + | float: left; |
| + | width: 190px; |
| + | overflow: hidden; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file a.delete { |
| + | float: right; |
| + | font: 9px/7px Arial, sans-serif; |
| + | padding: 2px 3px; |
| + | border-radius: 5px; |
| + | color: #000; |
| + | background-color: #b7b7b7; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file .thumb { |
| + | display: none; |
| + | position: absolute; |
| + | top: -35px; |
| + | left: -118px; |
| + | padding: 5px; |
| + | z-index: 99; |
| + | background-color: #e6e6e6; |
| + | border: 1px solid #bbb; |
| + | border-radius: 3px; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file .thumb img { |
| + | display: block; |
| + | border: 1px dotted #bbb; |
| + | height: 75px; |
| + | width: 100px; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file:hover { |
| + | background-color: #000; |
| + | } |
| + | #cms_body .right_column_content .file_uploads .file:hover .thumb { |
| + | display: block; |
| + | } |
| + | /* -- Dialog Widget ------------------------------------------------------ */ |
app/assets/stylesheets/comfortable_mexican_sofa/structure.css
+1
-1
| @@ | @@ -64,7 +64,7 @@ html, body#cms_body { |
| border-radius: 3px; | |
| -moz-border-radius: 3px; | |
| margin-bottom: 10px; | |
| - | overflow: hidden; |
| + | overflow: auto; |
| color: #fff; | |
| } | |
| /* -- Flash Messages ----------------------------------------------------- */ | |
app/controllers/cms_admin/dialogs_controller.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | class CmsAdmin::DialogsController < CmsAdmin::BaseController |
| + | |
| + | TEMPLATES = %w(image) |
| + | |
| + | def show |
| + | if template = TEMPLATES.include?(params[:type])? params[:type] : nil |
| + | render :template => "cms_admin/dialogs/#{template}", :layout => false |
| + | else |
| + | render :nothing => true |
| + | end |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
app/models/cms/file.rb
+8
-1
| @@ | @@ -14,7 +14,9 @@ class Cms::File < ActiveRecord::Base |
| has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options.merge( | |
| # dimensions accessor needs to be set before file assignment for this to work | |
| :styles => lambda { |f| | |
| - | f.instance.dimensions.blank?? { } : { :original => f.instance.dimensions } |
| + | (f.instance.dimensions.blank?? { } : { :original => f.instance.dimensions }).merge( |
| + | :cms_thumb => '100x75#' |
| + | ) |
| } | |
| ) | |
| @@ | @@ -36,6 +38,11 @@ class Cms::File < ActiveRecord::Base |
| scope :images, where(:file_content_type => IMAGE_MIMETYPES) | |
| scope :not_images, where('file_content_type NOT IN (?)', IMAGE_MIMETYPES) | |
| + | # -- Instance Methods ----------------------------------------------------- |
| + | def is_image? |
| + | IMAGE_MIMETYPES.include?(file_content_type) |
| + | end |
| + | |
| protected | |
| def assign_label | |
app/views/cms_admin/dialogs/image.html.erb
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | <%= render :partial => 'cms_admin/files/index' %> |
| \ No newline at end of file | |
app/views/cms_admin/files/_file.html.erb
+7
-8
| @@ | @@ -1,10 +1,9 @@ |
| - | <div class='file <%= dom_id(file) %>'> |
| - | <% file_name = file.file_file_name |
| - | file_ext = file.file_file_name.split('.').last |
| - | if (file_name.size - file_ext.size) > 30 |
| - | file_name = file_name.truncate(30) + file_ext |
| - | end |
| - | %> |
| - | <%= link_to file_name, file.file.url, :target => '_blank', :class => 'filename' %> |
| + | <div class='file <%= dom_id(file) %> <%= file.is_image?? 'image' : nil %>'> |
| + | <% if file.is_image? %> |
| + | <div class='thumb'> |
| + | <%= image_tag file.file.url(:cms_thumb) %> |
| + | </div> |
| + | <% end %> |
| + | <%= link_to file.file_file_name, file.file.url, :target => '_blank', :class => 'filename' %> |
| <%= link_to span_tag('x'), cms_admin_site_file_path(@site, file), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %> | |
| </div> | |
| \ No newline at end of file | |
app/views/cms_admin/files/_index.html.erb
+5
-18
| @@ | @@ -1,26 +1,13 @@ |
| - | <div id='file_uploads' class='box'> |
| + | <div class='box file_uploads'> |
| <%= form_for :file, :url => cms_admin_site_files_path(@site), :html => {:multipart => true} do |form| %> | |
| <a id='uploader_button' href='#' class='big button'><%= t('.button') %></a> | |
| - | <%= form.file_field :file, :multiple => true %> |
| + | <%= form.file_field :file, :multiple => true, :id => false %> |
| <% end %> | |
| - | <div id='uploaded_files'> |
| - | <% 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> |
| + | <div class='uploaded_files'> |
| + | <% @site.files.each do |file| %> |
| + | <%= render :partial => 'cms_admin/files/file', :object => file %> |
| <% end %> | |
| </div> | |
| </div> | |
| \ No newline at end of file | |
app/views/cms_admin/files/create.js.erb
+1
-1
| @@ | @@ -1,3 +1,3 @@ |
| - | $('#uploaded_files').prepend( |
| + | $('.uploaded_files').prepend( |
| '<%= escape_javascript(render :partial => "file", :object => @file ) %>' | |
| ); | |
| \ No newline at end of file | |
app/views/layouts/cms_admin/_head.html.erb
+1
-0
| @@ | @@ -19,6 +19,7 @@ |
| 'comfortable_mexican_sofa/typography', | |
| 'comfortable_mexican_sofa/form', | |
| 'comfortable_mexican_sofa/content', | |
| + | 'comfortable_mexican_sofa/files', |
| 'comfortable_mexican_sofa/elrte', | |
| 'comfortable_mexican_sofa/codemirror', | |
| 'comfortable_mexican_sofa/jquery_ui', | |
config/routes.rb
+1
-0
| @@ | @@ -27,6 +27,7 @@ Rails.application.routes.draw do |
| end | |
| end | |
| resources :categories | |
| + | get 'dialog/:type' => 'dialogs#show', :as => 'dialog' |
| end | |
| end unless ComfortableMexicanSofa.config.admin_route_prefix.blank? | |
test/unit/models/file_test.rb
+6
-0
| @@ | @@ -64,4 +64,10 @@ class CmsFileTest < ActiveSupport::TestCase |
| assert_equal 0, Cms::File.images.count | |
| assert_equal 1, Cms::File.not_images.count | |
| end | |
| + | |
| + | def test_image? |
| + | file = cms_files(:default) |
| + | assert_equal 'image/jpeg', file.file_content_type |
| + | assert file.is_image? |
| + | end |
| end | |