Commit b146a7838c978b0397fc6a41b53e9dd4572b5715

Authored by Victor Costa
1 parent bf0acf42

Remove traling spaces at display_content plugin

plugins/display_content/README
@@ -33,7 +33,7 @@ As a Noosfero administrator user, go to administrator panel: @@ -33,7 +33,7 @@ As a Noosfero administrator user, go to administrator panel:
33 DEVELOPMENT 33 DEVELOPMENT
34 =========== 34 ===========
35 35
36 -Noosfero uses jQuery 1.5.1 and the jsTree doesn't works fine with this jQuery version. 36 +Noosfero uses jQuery 1.5.1 and the jsTree doesn't works fine with this jQuery version.
37 Until Noosfero upgrade its JQuery version to a newer one is necessary to load jQuery 1.8.3 inside plugin and apply some changes in jsTree to avoid jQuery conflit. 37 Until Noosfero upgrade its JQuery version to a newer one is necessary to load jQuery 1.8.3 inside plugin and apply some changes in jsTree to avoid jQuery conflit.
38 38
39 Get the Display Content (Noosfero with Display Content Plugin) development repository: 39 Get the Display Content (Noosfero with Display Content Plugin) development repository:
plugins/display_content/controllers/display_content_plugin_admin_controller.rb
@@ -4,6 +4,6 @@ class DisplayContentPluginAdminController < AdminController @@ -4,6 +4,6 @@ class DisplayContentPluginAdminController < AdminController
4 4
5 append_view_path File.join(File.dirname(__FILE__) + '/../views') 5 append_view_path File.join(File.dirname(__FILE__) + '/../views')
6 6
7 - include DisplayContentPluginController 7 + include DisplayContentPluginController
8 8
9 end 9 end
plugins/display_content/controllers/display_content_plugin_module.rb
@@ -18,10 +18,10 @@ module DisplayContentPluginController @@ -18,10 +18,10 @@ module DisplayContentPluginController
18 node[:data] = article.title 18 node[:data] = article.title
19 node[:attr] = { 'node_id' => article.id, 'parent_id' => article.parent_id} 19 node[:attr] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
20 if block.nodes.include?(article.id) 20 if block.nodes.include?(article.id)
21 - node[:attr].merge!('class' => 'jstree-checked') 21 + node[:attr].merge!('class' => 'jstree-checked')
22 elsif block.parent_nodes.include?(article.id) 22 elsif block.parent_nodes.include?(article.id)
23 node[:children] = get_node(block, article.children) 23 node[:children] = get_node(block, article.children)
24 - node[:attr].merge!('class' => 'jstree-undetermined') 24 + node[:attr].merge!('class' => 'jstree-undetermined')
25 end 25 end
26 node[:state] = 'closed' if Article.exists?(:parent_id => article.id) 26 node[:state] = 'closed' if Article.exists?(:parent_id => article.id)
27 nodes.push(node) 27 nodes.push(node)
plugins/display_content/controllers/display_content_plugin_myprofile_controller.rb
@@ -4,6 +4,6 @@ class DisplayContentPluginMyprofileController < MyProfileController @@ -4,6 +4,6 @@ class DisplayContentPluginMyprofileController < MyProfileController
4 4
5 append_view_path File.join(File.dirname(__FILE__) + '/../views') 5 append_view_path File.join(File.dirname(__FILE__) + '/../views')
6 6
7 - include DisplayContentPluginController 7 + include DisplayContentPluginController
8 8
9 end 9 end
plugins/display_content/lib/display_content_block.rb
@@ -17,15 +17,15 @@ class DisplayContentBlock < Block @@ -17,15 +17,15 @@ class DisplayContentBlock < Block
17 17
18 settings_items :nodes, :type => Array, :default => [] 18 settings_items :nodes, :type => Array, :default => []
19 settings_items :parent_nodes, :type => Array, :default => [] 19 settings_items :parent_nodes, :type => Array, :default => []
20 - settings_items :sections,  
21 - :type => Array, 20 + settings_items :sections,
  21 + :type => Array,
22 :default => [{:name => _('Publish date'), :checked => true}, 22 :default => [{:name => _('Publish date'), :checked => true},
23 - {:name => _('Title'), :checked => true},  
24 - {:name => _('Abstract'), :checked => true},  
25 - {:name => _('Body'), :checked => false}, 23 + {:name => _('Title'), :checked => true},
  24 + {:name => _('Abstract'), :checked => true},
  25 + {:name => _('Body'), :checked => false},
26 {:name => _('Image'), :checked => false}, 26 {:name => _('Image'), :checked => false},
27 {:name => _('Tags'), :checked => false}] 27 {:name => _('Tags'), :checked => false}]
28 - 28 +
29 def self.description 29 def self.description
30 _('Display your contents') 30 _('Display your contents')
31 end 31 end
@@ -55,7 +55,7 @@ class DisplayContentBlock < Block @@ -55,7 +55,7 @@ class DisplayContentBlock < Block
55 55
56 def articles_of_parent(parent = nil) 56 def articles_of_parent(parent = nil)
57 return [] if self.holder.nil? 57 return [] if self.holder.nil?
58 - holder.articles.find(:all, :conditions => {:type => VALID_CONTENT, :parent_id => (parent.nil? ? nil : parent)}) 58 + holder.articles.find(:all, :conditions => {:type => VALID_CONTENT, :parent_id => (parent.nil? ? nil : parent)})
59 end 59 end
60 60
61 include ActionController::UrlWriter 61 include ActionController::UrlWriter
@@ -69,16 +69,16 @@ class DisplayContentBlock < Block @@ -69,16 +69,16 @@ class DisplayContentBlock < Block
69 read_more_section = '' 69 read_more_section = ''
70 tags_section = '' 70 tags_section = ''
71 71
72 - sections.select { |section| 72 + sections.select { |section|
73 case section[:name] 73 case section[:name]
74 when 'Publish date' 74 when 'Publish date'
75 - content_sections += (display_section?(section) ? (content_tag('div', show_date(item.published_at, false), :class => 'published-at') ) : '') 75 + content_sections += (display_section?(section) ? (content_tag('div', show_date(item.published_at, false), :class => 'published-at') ) : '')
76 when 'Title' 76 when 'Title'
77 - content_sections += (display_section?(section) ? (content_tag('div', link_to(h(item.title), item.url), :class => 'title') ) : '') 77 + content_sections += (display_section?(section) ? (content_tag('div', link_to(h(item.title), item.url), :class => 'title') ) : '')
78 when 'Abstract' 78 when 'Abstract'
79 content_sections += (display_section?(section) ? (content_tag('div', item.abstract , :class => 'lead')) : '' ) 79 content_sections += (display_section?(section) ? (content_tag('div', item.abstract , :class => 'lead')) : '' )
80 if display_section?(section) 80 if display_section?(section)
81 - read_more_section = content_tag('div', link_to(_('Read more'), item.url), :class => 'read_more') 81 + read_more_section = content_tag('div', link_to(_('Read more'), item.url), :class => 'read_more')
82 end 82 end
83 when 'Body' 83 when 'Body'
84 content_sections += (display_section?(section) ? (content_tag('div', item.body ,:class => 'body')) : '' ) 84 content_sections += (display_section?(section) ? (content_tag('div', item.body ,:class => 'body')) : '' )
@@ -116,12 +116,12 @@ class DisplayContentBlock < Block @@ -116,12 +116,12 @@ class DisplayContentBlock < Block
116 def display_section?(section) 116 def display_section?(section)
117 section[:checked] 117 section[:checked]
118 end 118 end
119 - 119 +
120 protected 120 protected
121 121
122 def holder 122 def holder
123 return nil if self.box.nil? || self.box.owner.nil? 123 return nil if self.box.nil? || self.box.owner.nil?
124 - if self.box.owner.kind_of?(Environment) 124 + if self.box.owner.kind_of?(Environment)
125 return nil if self.box.owner.portal_community.nil? 125 return nil if self.box.owner.portal_community.nil?
126 self.box.owner.portal_community 126 self.box.owner.portal_community
127 else 127 else
plugins/display_content/public/style.css
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 } 16 }
17 17
18 .block.display-content-block .published-at, 18 .block.display-content-block .published-at,
19 -.block.display-content-block .title, 19 +.block.display-content-block .title,
20 .block.display-content-block .lead, 20 .block.display-content-block .lead,
21 .block.display-content-block .body, 21 .block.display-content-block .body,
22 .block.display-content-block .image, 22 .block.display-content-block .image,
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -19,7 +19,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase @@ -19,7 +19,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
19 @environment.enabled_plugins = ['DisplayContentPlugin'] 19 @environment.enabled_plugins = ['DisplayContentPlugin']
20 @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity') 20 @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity')
21 @environment.save! 21 @environment.save!
22 - 22 +
23 box = Box.new(:owner => @environment, :position => 1) 23 box = Box.new(:owner => @environment, :position => 1)
24 box.save 24 box.save
25 25
plugins/display_content/test/unit/display_content_block_test.rb
@@ -515,7 +515,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase @@ -515,7 +515,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase
515 Article.delete_all 515 Article.delete_all
516 a1 = fast_create(invalid_article, :name => 'test article 1', :profile_id => profile.id) 516 a1 = fast_create(invalid_article, :name => 'test article 1', :profile_id => profile.id)
517 a2 = fast_create(VALID_KIND_OF_ARTICLE.first, :name => 'test article 2', :profile_id => profile.id) 517 a2 = fast_create(VALID_KIND_OF_ARTICLE.first, :name => 'test article 2', :profile_id => profile.id)
518 - 518 +
519 block = DisplayContentBlock.new 519 block = DisplayContentBlock.new
520 box = mock() 520 box = mock()
521 box.stubs(:owner).returns(profile) 521 box.stubs(:owner).returns(profile)
@@ -523,7 +523,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase @@ -523,7 +523,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase
523 assert_equal [], [a2] - block.articles_of_parent 523 assert_equal [], [a2] - block.articles_of_parent
524 assert_equal [], block.articles_of_parent - [a2] 524 assert_equal [], block.articles_of_parent - [a2]
525 end 525 end
526 - 526 +
527 end 527 end
528 528
529 VALID_KIND_OF_ARTICLE.map do |valid_article| 529 VALID_KIND_OF_ARTICLE.map do |valid_article|
@@ -533,14 +533,14 @@ class DisplayContentBlockTest < ActiveSupport::TestCase @@ -533,14 +533,14 @@ class DisplayContentBlockTest < ActiveSupport::TestCase
533 Article.delete_all 533 Article.delete_all
534 a1 = fast_create(valid_article, :name => 'test article 1', :profile_id => profile.id) 534 a1 = fast_create(valid_article, :name => 'test article 1', :profile_id => profile.id)
535 a2 = fast_create(INVALID_KIND_OF_ARTICLE.first, :name => 'test article 2', :profile_id => profile.id) 535 a2 = fast_create(INVALID_KIND_OF_ARTICLE.first, :name => 'test article 2', :profile_id => profile.id)
536 - 536 +
537 block = DisplayContentBlock.new 537 block = DisplayContentBlock.new
538 box = mock() 538 box = mock()
539 box.stubs(:owner).returns(profile) 539 box.stubs(:owner).returns(profile)
540 block.stubs(:box).returns(box) 540 block.stubs(:box).returns(box)
541 assert_equal [a1], block.articles_of_parent 541 assert_equal [a1], block.articles_of_parent
542 end 542 end
543 - 543 +
544 end 544 end
545 545
546 should 'list links for all articles title defined in nodes' do 546 should 'list links for all articles title defined in nodes' do
@@ -554,7 +554,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase @@ -554,7 +554,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase
554 box = mock() 554 box = mock()
555 block.stubs(:box).returns(box) 555 block.stubs(:box).returns(box)
556 box.stubs(:owner).returns(profile) 556 box.stubs(:owner).returns(profile)
557 - 557 +
558 assert_match /.*<a.*>#{a1.title}<\/a>/, block.content 558 assert_match /.*<a.*>#{a1.title}<\/a>/, block.content
559 assert_match /.*<a.*>#{a2.title}<\/a>/, block.content 559 assert_match /.*<a.*>#{a2.title}<\/a>/, block.content
560 end 560 end
@@ -571,7 +571,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -571,7 +571,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
571 box = mock() 571 box = mock()
572 block.stubs(:box).returns(box) 572 block.stubs(:box).returns(box)
573 box.stubs(:owner).returns(profile) 573 box.stubs(:owner).returns(profile)
574 - 574 +
575 assert_match /<div class="lead">#{a1.lead}<\/div>/, block.content 575 assert_match /<div class="lead">#{a1.lead}<\/div>/, block.content
576 assert_match /<div class="lead">#{a2.lead}<\/div>/, block.content 576 assert_match /<div class="lead">#{a2.lead}<\/div>/, block.content
577 end 577 end
@@ -585,7 +585,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -585,7 +585,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
585 box = mock() 585 box = mock()
586 block.stubs(:box).returns(box) 586 block.stubs(:box).returns(box)
587 box.stubs(:owner).returns(profile) 587 box.stubs(:owner).returns(profile)
588 - 588 +
589 Article.delete_all 589 Article.delete_all
590 assert_match /<ul><\/ul>/, block.content 590 assert_match /<ul><\/ul>/, block.content
591 end 591 end
@@ -595,7 +595,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -595,7 +595,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
595 block = DisplayContentBlock.new 595 block = DisplayContentBlock.new
596 block.box = profile.boxes.first 596 block.box = profile.boxes.first
597 block.save! 597 block.save!
598 - 598 +
599 params = {:block_id => block.id} 599 params = {:block_id => block.id}
600 params[:controller] = "display_content_plugin_myprofile" 600 params[:controller] = "display_content_plugin_myprofile"
601 params[:profile] = profile.identifier 601 params[:profile] = profile.identifier
@@ -607,7 +607,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -607,7 +607,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
607 block = DisplayContentBlock.new 607 block = DisplayContentBlock.new
608 block.box = environment.boxes.first 608 block.box = environment.boxes.first
609 block.save! 609 block.save!
610 - 610 +
611 params = {:block_id => block.id} 611 params = {:block_id => block.id}
612 params[:controller] = "display_content_plugin_admin" 612 params[:controller] = "display_content_plugin_admin"
613 assert_equal params, block.url_params 613 assert_equal params, block.url_params
@@ -623,7 +623,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -623,7 +623,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
623 box = mock() 623 box = mock()
624 block.stubs(:box).returns(box) 624 block.stubs(:box).returns(box)
625 box.stubs(:owner).returns(profile) 625 box.stubs(:owner).returns(profile)
626 - 626 +
627 assert_match /.*<a.*>#{a.title}<\/a>/, block.content 627 assert_match /.*<a.*>#{a.title}<\/a>/, block.content
628 end 628 end
629 629
@@ -637,7 +637,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -637,7 +637,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
637 box = mock() 637 box = mock()
638 block.stubs(:box).returns(box) 638 block.stubs(:box).returns(box)
639 box.stubs(:owner).returns(profile) 639 box.stubs(:owner).returns(profile)
640 - 640 +
641 assert_match /#{a.abstract}/, block.content 641 assert_match /#{a.abstract}/, block.content
642 end 642 end
643 643
@@ -651,7 +651,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -651,7 +651,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
651 box = mock() 651 box = mock()
652 block.stubs(:box).returns(box) 652 block.stubs(:box).returns(box)
653 box.stubs(:owner).returns(profile) 653 box.stubs(:owner).returns(profile)
654 - 654 +
655 assert_match /#{a.body}/, block.content 655 assert_match /#{a.body}/, block.content
656 end 656 end
657 657
@@ -659,13 +659,13 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -659,13 +659,13 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
659 profile = create_user('testuser').person 659 profile = create_user('testuser').person
660 660
661 block = DisplayContentBlock.new 661 block = DisplayContentBlock.new
662 - 662 +
663 assert block.display_section?({:name => 'Title', :checked => true}) 663 assert block.display_section?({:name => 'Title', :checked => true})
664 end 664 end
665 665
666 should 'display_attribute be true if the attribute was chosen' do 666 should 'display_attribute be true if the attribute was chosen' do
667 profile = create_user('testuser').person 667 profile = create_user('testuser').person
668 - 668 +
669 block = DisplayContentBlock.new 669 block = DisplayContentBlock.new
670 670
671 block.sections = [{:name => 'Body', :checked => true}] 671 block.sections = [{:name => 'Body', :checked => true}]
@@ -678,7 +678,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -678,7 +678,7 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
678 profile = create_user('testuser').person 678 profile = create_user('testuser').person
679 679
680 block = DisplayContentBlock.new 680 block = DisplayContentBlock.new
681 - 681 +
682 assert block.display_section?({:name => 'Publish date', :checked => true}) 682 assert block.display_section?({:name => 'Publish date', :checked => true})
683 end 683 end
684 684
@@ -692,9 +692,8 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase @@ -692,9 +692,8 @@ class DisplayContentBlockTest &lt; ActiveSupport::TestCase
692 box = mock() 692 box = mock()
693 block.stubs(:box).returns(box) 693 block.stubs(:box).returns(box)
694 box.stubs(:owner).returns(profile) 694 box.stubs(:owner).returns(profile)
695 - 695 +
696 assert_match /#{a.published_at}/, block.content 696 assert_match /#{a.published_at}/, block.content
697 end 697 end
698 698
699 -  
700 end 699 end
plugins/display_content/views/box_organizer/_display_content_block.rhtml
@@ -22,15 +22,15 @@ @@ -22,15 +22,15 @@
22 jQuery_1_8_3("#display_content").jstree({ 22 jQuery_1_8_3("#display_content").jstree({
23 plugins : ["themes","json_data", "checkbox"], 23 plugins : ["themes","json_data", "checkbox"],
24 checkbox : { 24 checkbox : {
25 - real_checkboxes : true,  
26 - real_checkboxes_names : function (n) { return [("block[checked_nodes[" + n.attr('node_id') + "]]"), 1]; } 25 + real_checkboxes : true,
  26 + real_checkboxes_names : function (n) { return [("block[checked_nodes[" + n.attr('node_id') + "]]"), 1]; }
27 }, 27 },
28 themes : {"theme" : "classic", "icons" : true, "url": "/plugins/display_content/javascripts/jstree/themes/classic/style.css"}, 28 themes : {"theme" : "classic", "icons" : true, "url": "/plugins/display_content/javascripts/jstree/themes/classic/style.css"},
29 json_data : { 29 json_data : {
30 - ajax : {  
31 - url : '<%= url_for @block.url_params %>', 30 + ajax : {
  31 + url : '<%= url_for @block.url_params %>',
32 async: true, 32 async: true,
33 - data : function (m) { 33 + data : function (m) {
34 return m.attr ? {"id" : m.attr("node_id")} : {}; 34 return m.attr ? {"id" : m.attr("node_id")} : {};
35 } 35 }
36 } 36 }