Commit 3c41ae142f01a9aac524149665e223f629db14c0

Authored by Daniela Feitosa
2 parents 9db0c7d6 44d21c5e

Merge branch 'field-of-interest' into 'master'

Ticket #85: The person_tags plugin now exposes a PersonTagsBlock

The `person_tags` plugin exposes a block now, so people can show their interests in their profiles.

![tags-block](/uploads/8c8ca6d46d09a3cfb4545b9a15561b21/tags-block.png)

I also renamed `interest` to `tag` because it was in conflict with other Noosfero stuff.

See merge request !963
plugins/person_tags/features/person_tags.feature
... ... @@ -10,9 +10,9 @@ Background:
10 10 Scenario: add tags to person
11 11 Given I am on joao's control panel
12 12 And I follow "Edit Profile"
13   - When I fill in "profile_data_interest_list" with "linux,debian"
  13 + When I fill in "profile_data_tag_list" with "linux,debian"
14 14 And I press "Save"
15 15 And I go to joao's control panel
16 16 And I follow "Edit Profile"
17   - Then the "profile_data_interest_list" field should contain "linux"
18   - And the "profile_data_interest_list" field should contain "debian"
  17 + Then the "profile_data_tag_list" field should contain "linux"
  18 + And the "profile_data_tag_list" field should contain "debian"
... ...
plugins/person_tags/lib/ext/person.rb
1 1 require_dependency 'person'
2 2  
3 3 class Person
4   - attr_accessible :interest_list
  4 + attr_accessible :tag_list
5 5  
6   - acts_as_taggable_on :interests
  6 + acts_as_taggable_on :tags
7 7 N_('Fields of interest')
8 8 end
... ...
plugins/person_tags/lib/person_tags_plugin.rb
... ... @@ -19,4 +19,18 @@ class PersonTagsPlugin < Noosfero::Plugin
19 19 def self.api_mount_points
20 20 [PersonTagsPlugin::API]
21 21 end
  22 +
  23 + def self.extra_blocks
  24 + {
  25 + PersonTagsPlugin::InterestsBlock => { type: Person }
  26 + }
  27 + end
  28 +
  29 + def self.has_admin_url?
  30 + false
  31 + end
  32 +
  33 + def stylesheet?
  34 + true
  35 + end
22 36 end
... ...
plugins/person_tags/lib/person_tags_plugin/api.rb
... ... @@ -3,7 +3,7 @@ class PersonTagsPlugin::API < Grape::API
3 3 get ':id/tags' do
4 4 person = environment.people.visible.find_by(id: params[:id])
5 5 return not_found! if person.blank?
6   - present person.interest_list
  6 + present person.tag_list
7 7 end
8 8 end
9 9 end
... ...
plugins/person_tags/lib/person_tags_plugin/interests_block.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +class PersonTagsPlugin::InterestsBlock < Block
  2 + def view_title
  3 + self.default_title
  4 + end
  5 +
  6 + def tags
  7 + owner.tag_list
  8 + end
  9 +
  10 + def extra_option
  11 + {}
  12 + end
  13 +
  14 + def self.description
  15 + _('Fields of Interest')
  16 + end
  17 +
  18 + def help
  19 + _('Things that this person is interested in')
  20 + end
  21 +
  22 + def default_title
  23 + _('Fields of Interest')
  24 + end
  25 +
  26 + def self.expire_on
  27 + { profile: [:profile] }
  28 + end
  29 +end
... ...
plugins/person_tags/public/style.css 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +.person-tags-block ul {
  2 + padding: 0;
  3 + margin: 0;
  4 +}
  5 +
  6 +.person-tags-block li {
  7 + float: left;
  8 + list-style: none;
  9 + padding: 5px;
  10 + color: #fff;
  11 + background: #000;
  12 + margin: 5px;
  13 +}
... ...
plugins/person_tags/test/unit/api_test.rb
... ... @@ -10,7 +10,7 @@ class APITest &lt; ActiveSupport::TestCase
10 10  
11 11 should 'return tags for a person' do
12 12 person = create_user('person').person
13   - person.interest_list.add('linux')
  13 + person.tag_list.add('linux')
14 14 person.save!
15 15 person.reload
16 16 get "/api/v1/people/#{person.id}/tags?#{params.to_query}"
... ...
plugins/person_tags/test/unit/person_tags_test.rb
... ... @@ -7,10 +7,10 @@ class PersonTagsPluginTest &lt; ActiveSupport::TestCase
7 7 @environment.enable_plugin(PersonTagsPlugin)
8 8 end
9 9  
10   - should 'have interests' do
  10 + should 'have tags' do
11 11 person = create_user('person').person
12   - assert_equal [], person.interests
13   - person.interest_list.add('linux')
14   - assert_equal ['linux'], person.interest_list
  12 + assert_equal [], person.tags
  13 + person.tag_list.add('linux')
  14 + assert_equal ['linux'], person.tag_list
15 15 end
16 16 end
... ...
plugins/person_tags/views/blocks/interests.html.erb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<%= block_title(block.view_title, block.subtitle) %>
  2 +
  3 +<div class="person-tags-block">
  4 + <% unless block.tags.size == 0 %>
  5 + <ul>
  6 + <% block.tags.each do |tag| %>
  7 + <li><%= tag %></li>
  8 + <% end %>
  9 + </ul>
  10 + <% else %>
  11 + <div class="person-tags-block-none"><%= c_('None') %></div>
  12 + <% end %>
  13 + <br style="clear:both" />
  14 +</div>
... ...
plugins/person_tags/views/environment_design 0 → 120000
... ... @@ -0,0 +1 @@
  1 +box_organizer
0 2 \ No newline at end of file
... ...
plugins/person_tags/views/profile-editor-extras.html.erb
1 1 <h2><%= _('Select your fields of interest') %></h2>
2   -<%= text_field_tag('profile_data[interest_list]', context.profile.interest_list.join(','), size: 64) %>
  2 +<%= text_field_tag('profile_data[tag_list]', context.profile.tag_list.join(','), size: 64) %>
3 3 <br />
4 4 <%= content_tag( 'small', _('Separate tags with commas') ) %>
5 5  
6 6 <script>
7   - jQuery('#profile_data_interest_list').inputosaurus();
  7 + jQuery('#profile_data_tag_list').inputosaurus();
8 8 </script>
... ...
plugins/person_tags/views/profile_design 0 → 120000
... ... @@ -0,0 +1 @@
  1 +box_organizer
0 2 \ No newline at end of file
... ...