Commit d4568ddd40bd68c206a1b62067ed582eb3a90b45
1 parent
d5780eb7
Exists in
master
and in
29 other branches
Remove old crappy media panel
Showing
11 changed files
with
15 additions
and
483 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -177,8 +177,7 @@ class CmsController < MyProfileController | @@ -177,8 +177,7 @@ class CmsController < MyProfileController | ||
| 177 | @article = @parent = check_parent(params[:parent_id]) | 177 | @article = @parent = check_parent(params[:parent_id]) |
| 178 | @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier | 178 | @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier |
| 179 | @folders = Folder.find(:all, :conditions => { :profile_id => profile }) | 179 | @folders = Folder.find(:all, :conditions => { :profile_id => profile }) |
| 180 | - @media_listing = params[:media_listing] | ||
| 181 | - if @article && !@media_listing | 180 | + if @article |
| 182 | record_coming | 181 | record_coming |
| 183 | end | 182 | end |
| 184 | if request.post? && params[:uploaded_files] | 183 | if request.post? && params[:uploaded_files] |
| @@ -187,28 +186,17 @@ class CmsController < MyProfileController | @@ -187,28 +186,17 @@ class CmsController < MyProfileController | ||
| 187 | end | 186 | end |
| 188 | @errors = @uploaded_files.select { |f| f.errors.any? } | 187 | @errors = @uploaded_files.select { |f| f.errors.any? } |
| 189 | if @errors.any? | 188 | if @errors.any? |
| 190 | - if @media_listing | ||
| 191 | - flash[:notice] = _('Could not upload all files') | ||
| 192 | - redirect_to :action => 'media_listing' | ||
| 193 | - else | ||
| 194 | - render :action => 'upload_files', :parent_id => @parent_id | ||
| 195 | - end | 189 | + render :action => 'upload_files', :parent_id => @parent_id |
| 196 | else | 190 | else |
| 197 | - if @media_listing | ||
| 198 | - flash[:notice] = _('All files were uploaded successfully') | ||
| 199 | - redirect_to :action => 'media_listing' | 191 | + if @back_to |
| 192 | + redirect_to @back_to | ||
| 193 | + elsif @parent | ||
| 194 | + redirect_to :action => 'view', :id => @parent.id | ||
| 200 | else | 195 | else |
| 201 | - if @back_to | ||
| 202 | - redirect_to @back_to | ||
| 203 | - else | ||
| 204 | - redirect_to( if @parent | ||
| 205 | - {:action => 'view', :id => @parent.id} | ||
| 206 | - else | ||
| 207 | - {:action => 'index'} | ||
| 208 | - end) | ||
| 209 | - end | 196 | + redirect_to :action => 'index' |
| 210 | end | 197 | end |
| 211 | end | 198 | end |
| 199 | + end | ||
| 212 | end | 200 | end |
| 213 | end | 201 | end |
| 214 | 202 | ||
| @@ -302,39 +290,6 @@ class CmsController < MyProfileController | @@ -302,39 +290,6 @@ class CmsController < MyProfileController | ||
| 302 | end | 290 | end |
| 303 | end | 291 | end |
| 304 | 292 | ||
| 305 | - def media_listing | ||
| 306 | - if params[:image_folder_id] | ||
| 307 | - folder = profile.articles.find(params[:image_folder_id]) if !params[:image_folder_id].blank? | ||
| 308 | - @images = (folder ? folder.children : profile.top_level_articles).images | ||
| 309 | - elsif params[:document_folder_id] | ||
| 310 | - folder = profile.articles.find(params[:document_folder_id]) if !params[:document_folder_id].blank? | ||
| 311 | - @documents = (folder ? folder.children : profile.top_level_articles) | ||
| 312 | - else | ||
| 313 | - @documents = profile.articles | ||
| 314 | - @images = @documents.images | ||
| 315 | - @documents -= @images | ||
| 316 | - end | ||
| 317 | - | ||
| 318 | - @images = @images.paginate(:per_page => per_page, :page => params[:ipage], :order => "updated_at desc") if @images | ||
| 319 | - @documents = @documents.paginate(:per_page => per_page, :page => params[:dpage], :order => "updated_at desc", :conditions => {:is_image => false}) if @documents | ||
| 320 | - | ||
| 321 | - @folders = profile.folders | ||
| 322 | - @image_folders = @folders.select {|f| f.children.any? {|c| c.image?} } | ||
| 323 | - @document_folders = @folders.select {|f| f.children.any? {|c| !c.image? && c.kind_of?(UploadedFile) } } | ||
| 324 | - | ||
| 325 | - @media_listing = true | ||
| 326 | - | ||
| 327 | - respond_to do |format| | ||
| 328 | - format.html { render :layout => false} | ||
| 329 | - format.js { | ||
| 330 | - render :update do |page| | ||
| 331 | - page.replace_html 'media-listing-folder-images', :partial => 'image_thumb', :locals => {:images => @images } if !@images.blank? | ||
| 332 | - page.replace_html 'media-listing-folder-documents', :partial => 'document_link', :locals => {:documents => @documents } if !@documents.blank? | ||
| 333 | - end | ||
| 334 | - } | ||
| 335 | - end | ||
| 336 | - end | ||
| 337 | - | ||
| 338 | def search | 293 | def search |
| 339 | query = params[:q] | 294 | query = params[:q] |
| 340 | results = query.blank? ? [] : profile.articles.published.find_by_contents(query) | 295 | results = query.blank? ? [] : profile.articles.published.find_by_contents(query) |
app/views/cms/_document_link.rhtml
| @@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
| 1 | -<div id='media-listing-folder-documents' > | ||
| 2 | - <ul> | ||
| 3 | - <% documents.each do |document| %> | ||
| 4 | - <li><%= link_to(document.name, document.view_url, :class => icon_for_article(document)) %></li> | ||
| 5 | - <% end %> | ||
| 6 | - </ul> | ||
| 7 | - <div id='pagination-documents'> | ||
| 8 | - <%= pagination_links documents, :param_name => 'dpage', :params => {:document_folder_id => params[:document_folder_id]} %> | ||
| 9 | - </div> | ||
| 10 | -</div> |
app/views/cms/_image_thumb.rhtml
| @@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
| 1 | -<div id='media-listing-folder-images' > | ||
| 2 | - <ul> | ||
| 3 | - <% images.each do |image| %> | ||
| 4 | - <li><%= image_tag image.public_filename %></li> | ||
| 5 | - <% end %> | ||
| 6 | - </ul> | ||
| 7 | - <div id='pagination-images'> | ||
| 8 | - <%= pagination_links images, :param_name => 'ipage', :params => {:image_folder_id => params[:image_folder_id]} %> | ||
| 9 | - </div> | ||
| 10 | -</div> |
app/views/cms/_media_listing.rhtml
app/views/cms/_select_folder.rhtml
| @@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
| 1 | -<%= select('folder', 'folder_id', @image_folders.collect {|f| [ f.name, f.id ] }, {:include_blank => "#{profile.identifier}"}, :onchange => remote_function(:update => 'media-listing-folder-images', :with => "'folder_id=' + value", :url => { :action => :get_images }) ) %> |
app/views/cms/_text_editor_sidebar.rhtml
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <div class='text-editor-sidebar-box' id='media-upload-box'> | 3 | <div class='text-editor-sidebar-box' id='media-upload-box'> |
| 4 | <p><strong>Media upload</strong></p> | 4 | <p><strong>Media upload</strong></p> |
| 5 | <div id='media-upload-form'> | 5 | <div id='media-upload-form'> |
| 6 | - <% form_tag({ :action => 'media_upload' }, :multipart => true) do |f| %> | 6 | + <% form_tag({ :action => 'media_upload' }, :multipart => true) do %> |
| 7 | <div class='formfield'> | 7 | <div class='formfield'> |
| 8 | <%# TODO duplicated from partial upload_file_form %> | 8 | <%# TODO duplicated from partial upload_file_form %> |
| 9 | <%= labelled_form_field(_('Choose folder to upload files:'), select_tag('parent_id', options_for_select([[profile.identifier, '']] + profile.folders.collect {|f| [ profile.identifier + '/' + f.full_name, f.id ] }))) %> | 9 | <%= labelled_form_field(_('Choose folder to upload files:'), select_tag('parent_id', options_for_select([[profile.identifier, '']] + profile.folders.collect {|f| [ profile.identifier + '/' + f.full_name, f.id ] }))) %> |
| @@ -35,7 +35,6 @@ | @@ -35,7 +35,6 @@ | ||
| 35 | <%= submit_button :search, _('Search'), :id => 'media-search-button' %> | 35 | <%= submit_button :search, _('Search'), :id => 'media-search-button' %> |
| 36 | <% end %> | 36 | <% end %> |
| 37 | </p> | 37 | </p> |
| 38 | - </form> | ||
| 39 | <div id='media-search-results' class='media-list-results' style='display: none'> | 38 | <div id='media-search-results' class='media-list-results' style='display: none'> |
| 40 | <ul> | 39 | <ul> |
| 41 | </ul> | 40 | </ul> |
app/views/cms/_upload_file_form.rhtml
| @@ -14,9 +14,7 @@ | @@ -14,9 +14,7 @@ | ||
| 14 | 14 | ||
| 15 | <% button_bar do %> | 15 | <% button_bar do %> |
| 16 | <%= add_upload_file_field(_('More files'), {:size => size}) %> | 16 | <%= add_upload_file_field(_('More files'), {:size => size}) %> |
| 17 | - <% if @media_listing %> | ||
| 18 | - <%= submit_button :save, _('Upload') %> | ||
| 19 | - <% elsif @back_to %> | 17 | + <% if @back_to %> |
| 20 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> | 18 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> |
| 21 | <% else %> | 19 | <% else %> |
| 22 | <%= submit_button :save, _('Upload'), :cancel => {:action => (@parent ? 'view' : 'index'), :id => @parent } %> | 20 | <%= submit_button :save, _('Upload'), :cancel => {:action => (@parent ? 'view' : 'index'), :id => @parent } %> |
app/views/cms/media_listing.rhtml
| @@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
| 1 | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>"> | ||
| 2 | -<head> | ||
| 3 | - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
| 4 | - <%= stylesheet_link_tag 'application', 'media_listing', :cache => 'cache-media-listing' %> | ||
| 5 | - <%= stylesheet_import 'button', :themed_source => true %> | ||
| 6 | - <%= javascript_include_tag :defaults %> | ||
| 7 | - <%= javascript_include_tag 'lowpro' %> | ||
| 8 | - <%= stylesheet_link_tag icon_theme_stylesheet_path %> | ||
| 9 | -</head> | ||
| 10 | -<body class='noosfero'> | ||
| 11 | - <script type="text/javascript"> | ||
| 12 | - /* Adds a class to "msie" to the body element if a Microsoft browser is | ||
| 13 | - * detected. This is needed to workaround several of their limitations. | ||
| 14 | - */ | ||
| 15 | - if ( navigator.appVersion.indexOf("MSIE") > -1 ) { | ||
| 16 | - document.body.className += " msie msie" + | ||
| 17 | - navigator.appVersion.replace(/^.*MSIE\s+([0-9]+).*$/, "$1"); | ||
| 18 | - } | ||
| 19 | - function registerDocumentSize() { | ||
| 20 | - document.body.className = document.body.className.replace(/(^| )docSize.+( |$)/g, " "); | ||
| 21 | - for ( var x=100; x<=1500; x+=100 ) { | ||
| 22 | - if ( document.body.clientWidth > x ) { | ||
| 23 | - document.body.className += " docSize-GT-" + x; | ||
| 24 | - } else { | ||
| 25 | - document.body.className += " docSize-LT-" + x; | ||
| 26 | - } | ||
| 27 | - } | ||
| 28 | - } | ||
| 29 | - registerDocumentSize(); | ||
| 30 | - </script> | ||
| 31 | - <div id='media-listing-upload'> | ||
| 32 | - <p><%= _("Include files in some folder or select from the list below to add images and documents to the text editor beside (max size %s)") % UploadedFile.max_size.to_humanreadable %></p> | ||
| 33 | - | ||
| 34 | - <div id="notice" onclick="Element.hide('notice');" style="display:none"> | ||
| 35 | - <% unless flash[:notice].nil? %> | ||
| 36 | - <%= flash[:notice] %> | ||
| 37 | - <%= javascript_tag(visual_effect( :appear, 'notice')) %> | ||
| 38 | - <% end %> | ||
| 39 | - </div> | ||
| 40 | - | ||
| 41 | - <% form_for('uploaded_file', :url => {:action => 'upload_files'}, :html => {:multipart => true}) do |f| %> | ||
| 42 | - <%= hidden_field_tag('media_listing', @media_listing) %> | ||
| 43 | - <%= render :partial => 'upload_file_form', :locals => { :size => '30' } %> | ||
| 44 | - <% end %> | ||
| 45 | - </div><!-- id='media-listing-upload' --> | ||
| 46 | - <hr/> | ||
| 47 | - | ||
| 48 | - <script type='text/javascript'> | ||
| 49 | - document.observe("dom:loaded", function() { | ||
| 50 | - Event.addBehavior.reassignAfterAjax = true; | ||
| 51 | - Event.addBehavior({ | ||
| 52 | - 'div#pagination-images .pagination a' : Remote.Link, | ||
| 53 | - 'div#pagination-documents .pagination a' : Remote.Link | ||
| 54 | - }) | ||
| 55 | - }); | ||
| 56 | - </script> | ||
| 57 | - | ||
| 58 | - <div id='media-listing'> | ||
| 59 | - <h3><%= _('Folders') %></h3> | ||
| 60 | - <p><%= _('Drag images and documents to add them to the text. If needed, resize images by clicking the tree icon on editor.') %></p> | ||
| 61 | - | ||
| 62 | - <div id='media-listing-images'> | ||
| 63 | - <h4><%= _('Images') %></h4> | ||
| 64 | - <%= select_folder('', 'folder', 'image_folder_id', @image_folders, {}, :onchange => remote_function(:with => "'image_folder_id=' + value + '&ipage=1'", :url => { :action => :media_listing, :format => 'js' }) ) %> | ||
| 65 | - <%= render :partial => 'image_thumb', :locals => { :images => @images } %> | ||
| 66 | - </div><!-- id='media-listing-images' --> | ||
| 67 | - <div id='media-listing-documents'> | ||
| 68 | - <h4><%= _('Documents') %></h4> | ||
| 69 | - <%= select_folder('', 'folder', 'document_folder_id', @document_folders, {}, :onchange => remote_function(:with => "'document_folder_id=' + value + '&dpage=1'", :url => { :action => :media_listing }) ) %> | ||
| 70 | - <%= render :partial => 'document_link', :locals => { :documents => @documents } %> | ||
| 71 | - </div><!-- id='media-listing-documents' --> | ||
| 72 | - <br style="clear:both" /> | ||
| 73 | - </div><!-- id='media-listing' --> | ||
| 74 | -</body> | ||
| 75 | -</html> |
public/stylesheets/application.css
| @@ -3344,21 +3344,7 @@ table.cms-articles .icon:hover { | @@ -3344,21 +3344,7 @@ table.cms-articles .icon:hover { | ||
| 3344 | display: block; | 3344 | display: block; |
| 3345 | } | 3345 | } |
| 3346 | 3346 | ||
| 3347 | -/* Media listing */ | ||
| 3348 | - | ||
| 3349 | -.controller-cms #media-listing-iframe { | ||
| 3350 | - float: right; | ||
| 3351 | - width: 380px; | ||
| 3352 | - height: 630px; | ||
| 3353 | - border: none; | ||
| 3354 | - margin-top: 104px; | ||
| 3355 | - padding: 0px; | ||
| 3356 | - overflow: hidden; | ||
| 3357 | -} | ||
| 3358 | - | ||
| 3359 | -.controller-cms .msie #media-listing-iframe { | ||
| 3360 | - height: 610px; | ||
| 3361 | -} | 3347 | +/* Text editors sidebar */ |
| 3362 | 3348 | ||
| 3363 | .controller-cms div.with_media_panel { | 3349 | .controller-cms div.with_media_panel { |
| 3364 | float: left; | 3350 | float: left; |
| @@ -3369,8 +3355,6 @@ div.with_media_panel .formfield input { | @@ -3369,8 +3355,6 @@ div.with_media_panel .formfield input { | ||
| 3369 | width: 100%; | 3355 | width: 100%; |
| 3370 | } | 3356 | } |
| 3371 | 3357 | ||
| 3372 | -/* Textile sidebar */ | ||
| 3373 | - | ||
| 3374 | .text-editor-sidebar { | 3358 | .text-editor-sidebar { |
| 3375 | position: absolute; | 3359 | position: absolute; |
| 3376 | width: 380px; | 3360 | width: 380px; |
public/stylesheets/media_listing.css
| @@ -1,167 +0,0 @@ | @@ -1,167 +0,0 @@ | ||
| 1 | -body { | ||
| 2 | - padding: 0px; | ||
| 3 | - margin: 0px; | ||
| 4 | - font-family: Verdana, sans-serif; | ||
| 5 | - font-size: 14px; | ||
| 6 | - color: #444; | ||
| 7 | - background-color: #F0F0EE; | ||
| 8 | - overflow: hidden; | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -h3, h4, h5 { | ||
| 12 | - margin: 5px 0px; | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -h3 { | ||
| 16 | - font-size: 18px; | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -h4 { | ||
| 20 | - font-size: 16px; | ||
| 21 | -} | ||
| 22 | - | ||
| 23 | -#media-listing { | ||
| 24 | - width: 100%; | ||
| 25 | - height: 48%; | ||
| 26 | - margin: 0px; | ||
| 27 | - padding: 0px; | ||
| 28 | - padding-bottom: 5px; | ||
| 29 | -} | ||
| 30 | - | ||
| 31 | -#media-listing-upload p, | ||
| 32 | -#media-listing p { | ||
| 33 | - font-size: 13px; | ||
| 34 | - font-weight: bold; | ||
| 35 | - margin: 5px 5px; | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -#media-listing li { | ||
| 39 | - list-style: none; | ||
| 40 | - margin: 0px; | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -#media-listing li:hover { | ||
| 44 | - background-color: #CCC; | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -#media-listing a { | ||
| 48 | - text-decoration: none; | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -#media-listing select { | ||
| 52 | - width: 80%; | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -#media-listing-images { | ||
| 56 | - width: 46%; | ||
| 57 | - float: left; | ||
| 58 | - text-align: center; | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -#media-listing-images img { | ||
| 62 | - max-width: 80px; | ||
| 63 | - max-height: 60px; | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | -.msie6 #media-listing-images img, | ||
| 67 | -.msie7 #media-listing-images img { | ||
| 68 | - width: 80px; | ||
| 69 | - height: 60px; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -#media-listing-folder-images, | ||
| 73 | -#media-listing-folder-documents { | ||
| 74 | - height: 80%; | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -#media-listing ul { | ||
| 78 | - padding: 0px; | ||
| 79 | - margin: 5px; | ||
| 80 | - height: 40%; | ||
| 81 | - overflow: auto; | ||
| 82 | - width: 98%; | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -#media-listing ul { | ||
| 86 | - height: 85%; | ||
| 87 | -} | ||
| 88 | - | ||
| 89 | -#media-listing-images, | ||
| 90 | -#media-listing-documents { | ||
| 91 | - height: 55%; | ||
| 92 | -} | ||
| 93 | - | ||
| 94 | -#media-listing-documents ul { | ||
| 95 | - text-align: left; | ||
| 96 | -} | ||
| 97 | - | ||
| 98 | -#media-listing-documents { | ||
| 99 | - width: 52%; | ||
| 100 | - float: left; | ||
| 101 | - text-align: center; | ||
| 102 | -} | ||
| 103 | - | ||
| 104 | -#media-listing-documents li { | ||
| 105 | - padding-bottom: 5px; | ||
| 106 | -} | ||
| 107 | - | ||
| 108 | -#media-listing-folder-documents a.icon { | ||
| 109 | - background-repeat: no-repeat; | ||
| 110 | - padding-left: 20px; | ||
| 111 | - border: none; | ||
| 112 | -} | ||
| 113 | - | ||
| 114 | -#media-listing-folder-documents .icon:hover { | ||
| 115 | - background-color: transparent; | ||
| 116 | -} | ||
| 117 | - | ||
| 118 | -#media-listing .icon-rss-feed { | ||
| 119 | - background-image: url(../images/icons-mime/rss-feed-16.png); | ||
| 120 | -} | ||
| 121 | - | ||
| 122 | -#media-listing-upload { | ||
| 123 | - width: 98%; | ||
| 124 | - padding: 3px; | ||
| 125 | -} | ||
| 126 | - | ||
| 127 | -#media-listing-upload p { | ||
| 128 | - margin: 5px 0px; | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -#media-listing-upload select { | ||
| 132 | - width: 90%; | ||
| 133 | -} | ||
| 134 | - | ||
| 135 | -#uploaded_files { | ||
| 136 | - overflow-x: hidden; | ||
| 137 | - overflow-y: scroll; | ||
| 138 | - height: 100px; | ||
| 139 | - margin-top: 5px; | ||
| 140 | -} | ||
| 141 | - | ||
| 142 | -.msie #uploaded_files { | ||
| 143 | - height: 100px; | ||
| 144 | - padding: 0px; | ||
| 145 | -} | ||
| 146 | - | ||
| 147 | -.formlabel { | ||
| 148 | - font-size: 11px; | ||
| 149 | - display: block; | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -/* Notice */ | ||
| 153 | - | ||
| 154 | -div#notice { | ||
| 155 | - background: #fee; | ||
| 156 | - border: 1px solid #933; | ||
| 157 | - top: 150px; | ||
| 158 | - color: black; | ||
| 159 | - cursor: pointer; | ||
| 160 | - font-weight: bold; | ||
| 161 | - left: 50%; | ||
| 162 | - margin-left: -150px; | ||
| 163 | - padding: 5px; | ||
| 164 | - position: absolute; | ||
| 165 | - text-align: center; | ||
| 166 | - width: 300px; | ||
| 167 | -} |
test/functional/cms_controller_test.rb
| @@ -1064,7 +1064,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -1064,7 +1064,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 1064 | assert_tag :tag => 'input', :attributes => { :name => 'article[external_feed_builder][only_once]', :checked => 'checked', :value => 'true' } | 1064 | assert_tag :tag => 'input', :attributes => { :name => 'article[external_feed_builder][only_once]', :checked => 'checked', :value => 'true' } |
| 1065 | end | 1065 | end |
| 1066 | 1066 | ||
| 1067 | - should 'display iframe for media listing when it is TinyMceArticle and enabled on environment' do | 1067 | + should 'display media listing when it is TinyMceArticle and enabled on environment' do |
| 1068 | e = Environment.default | 1068 | e = Environment.default |
| 1069 | e.enable('media_panel') | 1069 | e.enable('media_panel') |
| 1070 | e.save! | 1070 | e.save! |
| @@ -1076,10 +1076,10 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -1076,10 +1076,10 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 1076 | file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | 1076 | file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) |
| 1077 | 1077 | ||
| 1078 | get :new, :profile => profile.identifier, :type => 'TinyMceArticle' | 1078 | get :new, :profile => profile.identifier, :type => 'TinyMceArticle' |
| 1079 | - assert_tag :tag => 'iframe', :attributes => { :src => "/myprofile/#{profile.identifier}/cms/media_listing?type=TinyMceArticle" } | 1079 | + assert_tag :div, :attributes => { :class => "text-editor-sidebar" } |
| 1080 | end | 1080 | end |
| 1081 | 1081 | ||
| 1082 | - should 'not display iframe for media listing when it is Folder' do | 1082 | + should 'not display media listing when it is Folder' do |
| 1083 | image_folder = Folder.create(:profile => profile, :name => 'Image folder') | 1083 | image_folder = Folder.create(:profile => profile, :name => 'Image folder') |
| 1084 | non_image_folder = Folder.create(:profile => profile, :name => 'Non image folder') | 1084 | non_image_folder = Folder.create(:profile => profile, :name => 'Non image folder') |
| 1085 | 1085 | ||
| @@ -1087,145 +1087,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -1087,145 +1087,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 1087 | file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | 1087 | file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) |
| 1088 | 1088 | ||
| 1089 | get :new, :profile => profile.identifier, :type => 'Folder' | 1089 | get :new, :profile => profile.identifier, :type => 'Folder' |
| 1090 | - assert_no_tag :tag => 'iframe', :attributes => { :src => "/myprofile/#{profile.identifier}/cms/media_listing" } | ||
| 1091 | - end | ||
| 1092 | - | ||
| 1093 | - should 'display list of images' do | ||
| 1094 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1095 | - process_delayed_job_queue | ||
| 1096 | - get :media_listing, :profile => profile.identifier | ||
| 1097 | - | ||
| 1098 | - assert_tag :tag => 'div', :attributes => { :id => 'media-listing-images' }, :descendant => { :tag => 'img', :attributes => {:src => /rails.png/}} | ||
| 1099 | - end | ||
| 1100 | - | ||
| 1101 | - should 'display loading image if not processed yet' do | ||
| 1102 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1103 | - get :media_listing, :profile => profile.identifier | ||
| 1104 | - | ||
| 1105 | - assert_tag :tag => 'div', :attributes => { :id => 'media-listing-images' }, :descendant => { :tag => 'img', :attributes => {:src => /image-loading-thumb.png/}} | ||
| 1106 | - end | ||
| 1107 | - | ||
| 1108 | - | ||
| 1109 | - should 'display list of documents' do | ||
| 1110 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1111 | - get :media_listing, :profile => profile.identifier | ||
| 1112 | - assert_tag :tag => 'div', :attributes => { :id => 'media-listing-documents' }, :descendant => { :tag => 'a', :attributes => {:href => /#{file.name}/}} | ||
| 1113 | - end | ||
| 1114 | - | ||
| 1115 | - should 'list image folders to select' do | ||
| 1116 | - image_folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1117 | - non_image_folder = Folder.create(:profile => profile, :name => 'Non image folder') | ||
| 1118 | - | ||
| 1119 | - image = UploadedFile.create!(:profile => profile, :parent => image_folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1120 | - file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1121 | - | ||
| 1122 | - get :media_listing, :profile => profile.identifier | ||
| 1123 | - assert_tag :tag => 'div', :attributes => { :id => 'media-listing-images' }, :descendant => { :tag => 'option', :content => /#{image_folder.name}/, :attributes => { :value => image_folder.id}} | ||
| 1124 | - assert_no_tag :tag => 'div', :attributes => { :id => 'media-listing-images' }, :descendant => { :tag => 'option', :content => /#{non_image_folder.name}/, :attributes => { :value => non_image_folder.id}} | ||
| 1125 | - end | ||
| 1126 | - | ||
| 1127 | - should 'list documents folders to select' do | ||
| 1128 | - image_folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1129 | - non_image_folder = Folder.create(:profile => profile, :name => 'Non image folder') | ||
| 1130 | - | ||
| 1131 | - image = UploadedFile.create!(:profile => profile, :parent => image_folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1132 | - file = UploadedFile.create!(:profile => profile, :parent => non_image_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1133 | - | ||
| 1134 | - get :media_listing, :profile => profile.identifier | ||
| 1135 | - assert_no_tag :tag => 'div', :attributes => { :id => 'media-listing-documents' }, :descendant => { :tag => 'option', :content => /#{image_folder.name}/, :attributes => { :value => image_folder.id}} | ||
| 1136 | - assert_tag :tag => 'div', :attributes => { :id => 'media-listing-documents' }, :descendant => { :tag => 'option', :content => /#{non_image_folder.name}/, :attributes => { :value => non_image_folder.id}} | ||
| 1137 | - end | ||
| 1138 | - | ||
| 1139 | - should 'get a list of images from a image folder' do | ||
| 1140 | - folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1141 | - other_folder = Folder.create(:profile => profile, :name => 'Non image folder') | ||
| 1142 | - image = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1143 | - file_in_folder = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1144 | - image_in_other_folder = UploadedFile.create!(:profile => profile, :parent => other_folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1145 | - | ||
| 1146 | - get :media_listing, :profile => profile.identifier, :image_folder_id => folder.id, :format => 'js' | ||
| 1147 | - | ||
| 1148 | - assert_includes assigns(:images), image | ||
| 1149 | - assert_not_includes assigns(:images), file_in_folder | ||
| 1150 | - assert_not_includes assigns(:images), image_in_other_folder | ||
| 1151 | - end | ||
| 1152 | - | ||
| 1153 | - should 'get a list of images from profile' do | ||
| 1154 | - image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1155 | - folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1156 | - image_in_folder = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1157 | - get :media_listing, :profile => profile.identifier, :image_folder_id => '', :format => 'js' | ||
| 1158 | - | ||
| 1159 | - assert_includes assigns(:images), image | ||
| 1160 | - assert_not_includes assigns(:images), image_in_folder | ||
| 1161 | - end | ||
| 1162 | - | ||
| 1163 | - should 'get a list of documents from a document folder' do | ||
| 1164 | - folder = Folder.create(:profile => profile, :name => 'Non images folder') | ||
| 1165 | - other_folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1166 | - file = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1167 | - image = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
| 1168 | - file_in_other_folder = UploadedFile.create!(:profile => profile, :parent => other_folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1169 | - | ||
| 1170 | - get :media_listing, :profile => profile.identifier, :document_folder_id => folder.id, :format => 'js' | ||
| 1171 | - | ||
| 1172 | - assert_includes assigns(:documents), file | ||
| 1173 | - assert_not_includes assigns(:documents), image | ||
| 1174 | - assert_not_includes assigns(:documents), file_in_other_folder | ||
| 1175 | - end | ||
| 1176 | - | ||
| 1177 | - should 'get a list of documents from profile' do | ||
| 1178 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1179 | - folder = Folder.create(:profile => profile, :name => 'Image folder') | ||
| 1180 | - file_in_folder = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1181 | - | ||
| 1182 | - get :media_listing, :profile => profile.identifier, :document_folder_id => '', :format => 'js' | ||
| 1183 | - | ||
| 1184 | - assert_includes assigns(:documents), file | ||
| 1185 | - assert_not_includes assigns(:documents), file_in_folder | ||
| 1186 | - end | ||
| 1187 | - | ||
| 1188 | - should 'display pagination links of images' do | ||
| 1189 | - @controller.stubs(:per_page).returns(1) | ||
| 1190 | - | ||
| 1191 | - image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) | ||
| 1192 | - image2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :created_at => 1.day.ago) | ||
| 1193 | - image2.updated_at = 1.day.ago | ||
| 1194 | - image2.send :update_without_callbacks | ||
| 1195 | - | ||
| 1196 | - get :media_listing, :profile => profile.identifier | ||
| 1197 | - | ||
| 1198 | - assert_includes assigns(:images), image | ||
| 1199 | - assert_not_includes assigns(:images), image2 | ||
| 1200 | - end | ||
| 1201 | - | ||
| 1202 | - should 'display pagination links of documents' do | ||
| 1203 | - @controller.stubs(:per_page).returns(1) | ||
| 1204 | - profile.articles.destroy_all | ||
| 1205 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/feed.xml', 'text/xml')) | ||
| 1206 | - file2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) | ||
| 1207 | - file2.created_at = 1.day.ago | ||
| 1208 | - file2.save! | ||
| 1209 | - | ||
| 1210 | - get :media_listing, :profile => profile.identifier | ||
| 1211 | - | ||
| 1212 | - assert_includes assigns(:documents), file | ||
| 1213 | - assert_not_includes assigns(:documents), file2 | ||
| 1214 | - end | ||
| 1215 | - | ||
| 1216 | - | ||
| 1217 | - should 'redirect to media listing when upload files from there' do | ||
| 1218 | - post :upload_files, :profile => profile.identifier, :media_listing => true, :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')] | ||
| 1219 | - assert_template nil | ||
| 1220 | - assert_redirected_to :action => 'media_listing' | ||
| 1221 | - end | ||
| 1222 | - | ||
| 1223 | - should 'redirect to media listing when occur errors when upload files from there' do | ||
| 1224 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png')) | ||
| 1225 | - | ||
| 1226 | - post :upload_files, :profile => profile.identifier, :media_listing => true, :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')] | ||
| 1227 | - assert_template nil | ||
| 1228 | - assert_redirected_to :action => 'media_listing' | 1090 | + assert_no_tag :div, :attributes => { :id => "text-editor-sidebar" } |
| 1229 | end | 1091 | end |
| 1230 | 1092 | ||
| 1231 | should "display 'Publish' when profile is a person" do | 1093 | should "display 'Publish' when profile is a person" do |