Commit 9a6825430d61f5af2c0a83998e267cf6cc38e6d8

Authored by Antonio Terceiro
2 parents bdc26ce2 6e116602

Merge remote-tracking branch 'origin/rails3'

app/helpers/application_helper.rb
@@ -671,7 +671,7 @@ module ApplicationHelper @@ -671,7 +671,7 @@ module ApplicationHelper
671 671
672 def theme_javascript_ng 672 def theme_javascript_ng
673 script = File.join(theme_path, 'theme.js') 673 script = File.join(theme_path, 'theme.js')
674 - if File.exists?(Rails.root.join('public', script)) 674 + if File.join(Rails.root, 'public', script)
675 javascript_include_tag script 675 javascript_include_tag script
676 else 676 else
677 nil 677 nil
app/views/box_organizer/_link_list_block.html.erb
@@ -10,40 +10,15 @@ @@ -10,40 +10,15 @@
10 </ul> 10 </ul>
11 <ul id="dropable-link-list"> 11 <ul id="dropable-link-list">
12 <% for link in @block.links do %> 12 <% for link in @block.links do %>
13 - <li>  
14 - <ul class="link-list-row">  
15 - <li>  
16 - <%= icon_selector(link['icon']) %>  
17 - </li>  
18 - <li>  
19 - <%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %>  
20 - </li>  
21 - <li>  
22 - <%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %>  
23 - </li>  
24 - <li>  
25 - <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>  
26 - </li>  
27 - <li>  
28 - <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>  
29 - </li>  
30 - </ul>  
31 - </li> 13 + <%= render :partial => 'link_list_item', :locals => {:link => link} %>
32 <% end %> 14 <% end %>
33 </ul> 15 </ul>
34 <input type="hidden" id="page_url" value="<%=url_for(:action=>'search_autocomplete')%>" /> 16 <input type="hidden" id="page_url" value="<%=url_for(:action=>'search_autocomplete')%>" />
  17 +
  18 + <div id="new-template">
  19 + <% template_link = {'icon' => 'ok'} %>
  20 + <%= render :partial => 'link_list_item', :locals => {:link => template_link} %>
  21 + </div>
35 </div> 22 </div>
36 23
37 -<%= link_to_function(_('New link'), nil, :class => 'button icon-add with-text') do |page|  
38 - page.insert_html :bottom, 'dropable-link-list', content_tag('li',  
39 - content_tag('ul',  
40 - content_tag('li', icon_selector('ok')) +  
41 - content_tag('li', text_field_tag('block[links][][name]', '', :maxlength => 20)) +  
42 - content_tag('li', text_field_tag('block[links][][address]', nil, :class => 'link-address')) +  
43 - content_tag('li', select_tag('block[links][][target]',  
44 - options_for_select(LinkListBlock::TARGET_OPTIONS, '_self'))) +  
45 - content_tag('li', button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row")),  
46 - :class=>"link-list-row new_link_row")  
47 - ) +  
48 - javascript_tag("new_link_action()")  
49 -end %> 24 +<%= link_to_function(_('New link'), 'add_new_link();', :class => 'button icon-add with-text') %>
app/views/box_organizer/_link_list_item.html.erb 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +<li>
  2 + <ul class="link-list-row">
  3 + <li>
  4 + <%= icon_selector(link['icon']) %>
  5 + </li>
  6 + <li>
  7 + <%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %>
  8 + </li>
  9 + <li>
  10 + <%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %>
  11 + </li>
  12 + <li>
  13 + <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>
  14 + </li>
  15 + <li>
  16 + <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>
  17 + </li>
  18 + </ul>
  19 +</li>
app/views/comment/_comment_form.html.erb
@@ -81,7 +81,7 @@ function check_captcha(button, confirm_action) { @@ -81,7 +81,7 @@ function check_captcha(button, confirm_action) {
81 <%= hidden_field_tag(:view, params[:view])%> 81 <%= hidden_field_tag(:view, params[:view])%>
82 <%= f.hidden_field(:reply_of_id) %> 82 <%= f.hidden_field(:reply_of_id) %>
83 83
84 - <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns).collect { |content| instance_exec(&content) }.join("") %> 84 + <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }.join("") %>
85 85
86 <% button_bar do %> 86 <% button_bar do %>
87 <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %> 87 <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %>
plugins/display_content/lib/display_content_block.rb
@@ -26,7 +26,7 @@ class DisplayContentBlock &lt; Block @@ -26,7 +26,7 @@ class DisplayContentBlock &lt; Block
26 settings_items :display_folder_children, :type => :boolean, :default => true 26 settings_items :display_folder_children, :type => :boolean, :default => true
27 settings_items :types, :type => Array, :default => ['TextileArticle', 'TinyMceArticle', 'RawHTMLArticle'] 27 settings_items :types, :type => Array, :default => ['TextileArticle', 'TinyMceArticle', 'RawHTMLArticle']
28 28
29 - attr_accessible :sections, :checked_nodes, :display_folder_children 29 + attr_accessible :sections, :checked_nodes, :display_folder_children, :types
30 30
31 def self.description 31 def self.description
32 _('Display your contents') 32 _('Display your contents')
plugins/display_content/test/unit/display_content_block_test.rb
@@ -350,10 +350,11 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -350,10 +350,11 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
350 should 'list links for all articles title defined in nodes' do 350 should 'list links for all articles title defined in nodes' do
351 profile = create_user('testuser').person 351 profile = create_user('testuser').person
352 Article.delete_all 352 Article.delete_all
353 - a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id)  
354 - a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id) 353 + a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id)
  354 + a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id)
355 355
356 block = DisplayContentBlock.new 356 block = DisplayContentBlock.new
  357 + block.sections = [{:value => 'title', :checked => true}]
357 block.nodes = [a1.id, a2.id] 358 block.nodes = [a1.id, a2.id]
358 box = mock() 359 box = mock()
359 block.stubs(:box).returns(box) 360 block.stubs(:box).returns(box)
@@ -366,8 +367,8 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -366,8 +367,8 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
366 should 'list content for all articles lead defined in nodes' do 367 should 'list content for all articles lead defined in nodes' do
367 profile = create_user('testuser').person 368 profile = create_user('testuser').person
368 Article.delete_all 369 Article.delete_all
369 - a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1')  
370 - a2 = fast_create(TextArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') 370 + a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1')
  371 + a2 = fast_create(TinyMceArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2')
371 372
372 block = DisplayContentBlock.new 373 block = DisplayContentBlock.new
373 block.sections = [{:value => 'abstract', :checked => true}] 374 block.sections = [{:value => 'abstract', :checked => true}]
@@ -421,7 +422,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -421,7 +422,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
421 422
422 should 'show title if defined by user' do 423 should 'show title if defined by user' do
423 profile = create_user('testuser').person 424 profile = create_user('testuser').person
424 - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) 425 + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id)
425 426
426 block = DisplayContentBlock.new 427 block = DisplayContentBlock.new
427 block.nodes = [a.id] 428 block.nodes = [a.id]
@@ -435,7 +436,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -435,7 +436,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
435 436
436 should 'show abstract if defined by user' do 437 should 'show abstract if defined by user' do
437 profile = create_user('testuser').person 438 profile = create_user('testuser').person
438 - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') 439 + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract')
439 440
440 block = DisplayContentBlock.new 441 block = DisplayContentBlock.new
441 block.nodes = [a.id] 442 block.nodes = [a.id]
@@ -449,7 +450,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -449,7 +450,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
449 450
450 should 'show body if defined by user' do 451 should 'show body if defined by user' do
451 profile = create_user('testuser').person 452 profile = create_user('testuser').person
452 - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') 453 + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body')
453 454
454 block = DisplayContentBlock.new 455 block = DisplayContentBlock.new
455 block.nodes = [a.id] 456 block.nodes = [a.id]
@@ -577,7 +578,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -577,7 +578,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
577 block.types = ['TinyMceArticle'] 578 block.types = ['TinyMceArticle']
578 579
579 block.types = ['TinyMceArticle', 'Folder'] 580 block.types = ['TinyMceArticle', 'Folder']
580 - assert_equal [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], block.available_content_types 581 + assert_equivalent [TinyMceArticle, Folder, UploadedFile, Event, TextileArticle, RawHTMLArticle, Blog, Forum, Gallery, RssFeed], block.available_content_types
581 end 582 end
582 583
583 should 'return available content types' do 584 should 'return available content types' do
@@ -585,7 +586,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -585,7 +586,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
585 block = DisplayContentBlock.create! 586 block = DisplayContentBlock.create!
586 block.types = ['TinyMceArticle'] 587 block.types = ['TinyMceArticle']
587 block.types = [] 588 block.types = []
588 - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types 589 + assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed], block.available_content_types
589 end 590 end
590 591
591 should 'return first 2 content types' do 592 should 'return first 2 content types' do
@@ -629,7 +630,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -629,7 +630,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
629 Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) 630 Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new])
630 631
631 block.types = [] 632 block.types = []
632 - assert_equal [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types 633 + assert_equivalent [UploadedFile, Event, TinyMceArticle, TextileArticle, RawHTMLArticle, Folder, Blog, Forum, Gallery, RssFeed, SomePluginContent], block.available_content_types
633 end 634 end
634 635
635 should 'do not fail if a selected article was removed' do 636 should 'do not fail if a selected article was removed' do
public/javascripts/edit-link-list.js
@@ -29,6 +29,13 @@ function new_link_action(){ @@ -29,6 +29,13 @@ function new_link_action(){
29 jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); 29 jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop());
30 } 30 }
31 31
  32 +function add_new_link() {
  33 + var new_link = jQuery('#edit-link-list-block #new-template>li').clone();
  34 + new_link.show();
  35 + jQuery('#dropable-link-list').append(new_link);
  36 + new_link_action();
  37 +}
  38 +
32 jQuery(document).ready(function(){ 39 jQuery(document).ready(function(){
33 new_link_action(); 40 new_link_action();
34 41
@@ -36,4 +43,4 @@ jQuery(document).ready(function(){ @@ -36,4 +43,4 @@ jQuery(document).ready(function(){
36 revert: true, 43 revert: true,
37 axis: "y" 44 axis: "y"
38 }); 45 });
39 -});  
40 \ No newline at end of file 46 \ No newline at end of file
  47 +});
public/stylesheets/application.css
@@ -1864,6 +1864,9 @@ a.button.disabled, input.disabled { @@ -1864,6 +1864,9 @@ a.button.disabled, input.disabled {
1864 position: relative; 1864 position: relative;
1865 left: -24px; 1865 left: -24px;
1866 } 1866 }
  1867 +#edit-link-list-block #new-template {
  1868 + display: none;
  1869 +}
1867 .link-list-header { 1870 .link-list-header {
1868 width: 98%; 1871 width: 98%;
1869 height: 25px; 1872 height: 25px;