diff --git a/plugins/person_tags/features/person_tags.feature b/plugins/person_tags/features/person_tags.feature index 9f7a76a..17fa901 100644 --- a/plugins/person_tags/features/person_tags.feature +++ b/plugins/person_tags/features/person_tags.feature @@ -10,9 +10,9 @@ Background: Scenario: add tags to person Given I am on joao's control panel And I follow "Edit Profile" - When I fill in "profile_data_interest_list" with "linux,debian" + When I fill in "profile_data_tag_list" with "linux,debian" And I press "Save" And I go to joao's control panel And I follow "Edit Profile" - Then the "profile_data_interest_list" field should contain "linux" - And the "profile_data_interest_list" field should contain "debian" + Then the "profile_data_tag_list" field should contain "linux" + And the "profile_data_tag_list" field should contain "debian" diff --git a/plugins/person_tags/lib/ext/person.rb b/plugins/person_tags/lib/ext/person.rb index 0ed8eae..42eda36 100644 --- a/plugins/person_tags/lib/ext/person.rb +++ b/plugins/person_tags/lib/ext/person.rb @@ -1,8 +1,8 @@ require_dependency 'person' class Person - attr_accessible :interest_list + attr_accessible :tag_list - acts_as_taggable_on :interests + acts_as_taggable_on :tags N_('Fields of interest') end diff --git a/plugins/person_tags/lib/person_tags_block.rb b/plugins/person_tags/lib/person_tags_block.rb new file mode 100644 index 0000000..57ba39e --- /dev/null +++ b/plugins/person_tags/lib/person_tags_block.rb @@ -0,0 +1,29 @@ +class PersonTagsBlock < Block + def view_title + self.default_title + end + + def tags + owner.tag_list + end + + def extra_option + {} + end + + def self.description + _('Fields of Interest') + end + + def help + _('Things that this person is interested in') + end + + def default_title + _('Fields of Interest') + end + + def self.expire_on + { profile: [:profile] } + end +end diff --git a/plugins/person_tags/lib/person_tags_plugin.rb b/plugins/person_tags/lib/person_tags_plugin.rb index 4ee0858..9512080 100644 --- a/plugins/person_tags/lib/person_tags_plugin.rb +++ b/plugins/person_tags/lib/person_tags_plugin.rb @@ -19,4 +19,18 @@ class PersonTagsPlugin < Noosfero::Plugin def self.api_mount_points [PersonTagsPlugin::API] end + + def self.extra_blocks + { + PersonTagsBlock => { type: Person } + } + end + + def self.has_admin_url? + false + end + + def stylesheet? + true + end end diff --git a/plugins/person_tags/lib/person_tags_plugin/api.rb b/plugins/person_tags/lib/person_tags_plugin/api.rb index 0fb53cf..ae0f233 100644 --- a/plugins/person_tags/lib/person_tags_plugin/api.rb +++ b/plugins/person_tags/lib/person_tags_plugin/api.rb @@ -3,7 +3,7 @@ class PersonTagsPlugin::API < Grape::API get ':id/tags' do person = environment.people.visible.find_by(id: params[:id]) return not_found! if person.blank? - present person.interest_list + present person.tag_list end end end diff --git a/plugins/person_tags/public/style.css b/plugins/person_tags/public/style.css new file mode 100644 index 0000000..1e6dd2f --- /dev/null +++ b/plugins/person_tags/public/style.css @@ -0,0 +1,13 @@ +.person-tags-block ul { + padding: 0; + margin: 0; +} + +.person-tags-block li { + float: left; + list-style: none; + padding: 5px; + color: #fff; + background: #000; + margin: 5px; +} diff --git a/plugins/person_tags/test/unit/api_test.rb b/plugins/person_tags/test/unit/api_test.rb index 90400cf..e37fc8f 100644 --- a/plugins/person_tags/test/unit/api_test.rb +++ b/plugins/person_tags/test/unit/api_test.rb @@ -10,7 +10,7 @@ class APITest < ActiveSupport::TestCase should 'return tags for a person' do person = create_user('person').person - person.interest_list.add('linux') + person.tag_list.add('linux') person.save! person.reload get "/api/v1/people/#{person.id}/tags?#{params.to_query}" diff --git a/plugins/person_tags/test/unit/person_tags_test.rb b/plugins/person_tags/test/unit/person_tags_test.rb index ccc9914..78c1f17 100644 --- a/plugins/person_tags/test/unit/person_tags_test.rb +++ b/plugins/person_tags/test/unit/person_tags_test.rb @@ -7,10 +7,10 @@ class PersonTagsPluginTest < ActiveSupport::TestCase @environment.enable_plugin(PersonTagsPlugin) end - should 'have interests' do + should 'have tags' do person = create_user('person').person - assert_equal [], person.interests - person.interest_list.add('linux') - assert_equal ['linux'], person.interest_list + assert_equal [], person.tags + person.tag_list.add('linux') + assert_equal ['linux'], person.tag_list end end diff --git a/plugins/person_tags/views/blocks/person_tags.html.erb b/plugins/person_tags/views/blocks/person_tags.html.erb new file mode 100644 index 0000000..64956bb --- /dev/null +++ b/plugins/person_tags/views/blocks/person_tags.html.erb @@ -0,0 +1,14 @@ +<%= block_title(block.view_title, block.subtitle) %> + +
+ <% unless block.tags.size == 0 %> + + <% else %> +
<%= c_('None') %>
+ <% end %> +
+
diff --git a/plugins/person_tags/views/environment_design b/plugins/person_tags/views/environment_design new file mode 120000 index 0000000..a75d184 --- /dev/null +++ b/plugins/person_tags/views/environment_design @@ -0,0 +1 @@ +box_organizer \ No newline at end of file diff --git a/plugins/person_tags/views/profile-editor-extras.html.erb b/plugins/person_tags/views/profile-editor-extras.html.erb index 12eccdd..dceface 100644 --- a/plugins/person_tags/views/profile-editor-extras.html.erb +++ b/plugins/person_tags/views/profile-editor-extras.html.erb @@ -1,8 +1,8 @@

<%= _('Select your fields of interest') %>

-<%= text_field_tag('profile_data[interest_list]', context.profile.interest_list.join(','), size: 64) %> +<%= text_field_tag('profile_data[tag_list]', context.profile.tag_list.join(','), size: 64) %>
<%= content_tag( 'small', _('Separate tags with commas') ) %> diff --git a/plugins/person_tags/views/profile_design b/plugins/person_tags/views/profile_design new file mode 120000 index 0000000..a75d184 --- /dev/null +++ b/plugins/person_tags/views/profile_design @@ -0,0 +1 @@ +box_organizer \ No newline at end of file diff --git a/public/plugins/person_tags b/public/plugins/person_tags new file mode 120000 index 0000000..98572ee --- /dev/null +++ b/public/plugins/person_tags @@ -0,0 +1 @@ +/home/caiosba/IBICT/noosfero/config/plugins/person_tags/public \ No newline at end of file -- libgit2 0.21.2