diff --git a/plugins/recent_activities/lib/ext/action_tracker_model.rb b/plugins/recent_activities/lib/ext/action_tracker_model.rb new file mode 100644 index 0000000..87297ff --- /dev/null +++ b/plugins/recent_activities/lib/ext/action_tracker_model.rb @@ -0,0 +1,16 @@ +require_dependency 'action_tracker_model' + +class ActionTracker::Record + def label + case self.target.class.name + when 'Event' + 'events' + when 'Community' + 'communities' + when 'Friendship' + 'people' + else + 'posts' + end + end +end diff --git a/plugins/recent_activities/locales/en.yml b/plugins/recent_activities/locales/en.yml new file mode 100644 index 0000000..36f9430 --- /dev/null +++ b/plugins/recent_activities/locales/en.yml @@ -0,0 +1,4 @@ +"en-US": &en-US + time: + formats: + medium: "%B %d, %Y" diff --git a/plugins/recent_activities/locales/pt-BR.yml b/plugins/recent_activities/locales/pt-BR.yml new file mode 100644 index 0000000..1a8bb92 --- /dev/null +++ b/plugins/recent_activities/locales/pt-BR.yml @@ -0,0 +1,4 @@ +"pt-BR": &pt-BR + time: + formats: + medium: "%d de %B de %Y" diff --git a/plugins/recent_activities/locales/pt-PT.yml b/plugins/recent_activities/locales/pt-PT.yml new file mode 100644 index 0000000..832c7de --- /dev/null +++ b/plugins/recent_activities/locales/pt-PT.yml @@ -0,0 +1,4 @@ +"pt-PT": &pt-PT + time: + formats: + medium: "%d de %B de %Y" diff --git a/plugins/recent_activities/locales/pt.yml b/plugins/recent_activities/locales/pt.yml new file mode 100644 index 0000000..d1cdbbe --- /dev/null +++ b/plugins/recent_activities/locales/pt.yml @@ -0,0 +1,4 @@ +"pt": &pt + time: + formats: + medium: "%d de %B de %Y" diff --git a/plugins/recent_activities/public/style.css b/plugins/recent_activities/public/style.css index a14dd88..df68e75 100644 --- a/plugins/recent_activities/public/style.css +++ b/plugins/recent_activities/public/style.css @@ -35,3 +35,38 @@ display: inline-block; background-size: cover; } + +.recent-activities-block .recent-activity-date, +.recent-activities-block .recent-activity-date a, +.recent-activities-block .recent-activity-date a:visited { + color: #888a85; +} + +.recent-activities-block .recent-activity-label { + padding: 2px; + text-transform: capitalize; + background: #333; + color: #fff; + margin-left: 5px; + display: inline-block; + font-size: 11px; +} + +.recent-activities-block .recent-activity-event { + display: table-row; +} + +.recent-activities-block .recent-activity-events img { + width: 32px; + height: 32px; + float: left; +} + +.recent-activities-block .recent-activity-events .lead { + width: 148px; + margin-left: 2px; + margin-top: 2px; + float: left; + display: block; + text-align: justify; +} diff --git a/plugins/recent_activities/test/unit/recent_activities_test.rb b/plugins/recent_activities/test/unit/recent_activities_test.rb new file mode 100644 index 0000000..0d4f1fd --- /dev/null +++ b/plugins/recent_activities/test/unit/recent_activities_test.rb @@ -0,0 +1,46 @@ +require 'test_helper' + +class RecentActivitiesPluginTest < ActiveSupport::TestCase + def setup + @environment = Environment.default + @environment.enable_plugin(RecentActivitiesPlugin) + end + + should 'have label for events' do + person = fast_create(Person) + event = build(Event, { name: 'Event', start_date: DateTime.new(2020, 1, 1) }) + event.profile = person + event.save! + activity = create_activity(person, event) + assert_equal 'events', activity.label + end + + should 'have label for communities' do + person = fast_create(Person) + community = fast_create(Community) + activity = create_activity(person, community) + assert_equal 'communities', activity.label + end + + should 'have label for people' do + person = fast_create(Person) + friendship = fast_create(Friendship) + activity = create_activity(person, friendship) + assert_equal 'people', activity.label + end + + should 'have label for posts' do + person = fast_create(Person) + article = fast_create(Article) + activity = create_activity(person, article) + assert_equal 'posts', activity.label + end + + protected + + def create_activity(person, target) + activity = ActionTracker::Record.create! verb: :leave_scrap, user: person, target: target + ProfileActivity.create! profile_id: target.id, activity: activity + activity.reload + end +end diff --git a/plugins/recent_activities/views/blocks/activities.html.erb b/plugins/recent_activities/views/blocks/activities.html.erb index fca7e43..7e0ae7a 100644 --- a/plugins/recent_activities/views/blocks/activities.html.erb +++ b/plugins/recent_activities/views/blocks/activities.html.erb @@ -4,9 +4,37 @@ <% unless block.activities.size == 0 %>
<%= link_to activity.user.name, activity.user.url %> <%= describe(activity).html_safe %>
- ++ <% if activity.label === 'events' %> + <%= + _('Event on %s at %s - %s').html_safe % + [ + l(activity.target.start_date, format: :medium), + activity.target.start_date.strftime("%H:%M"), + link_to(activity.user.name, activity.user.url) + ] + %> + <% else %> + <%= + _('On %s at %s - %s').html_safe % + [ + l(activity.created_at, format: :medium), + activity.created_at.strftime("%H:%M"), + link_to(activity.user.name, activity.user.url) + ] + %> + <% end %> + <%= activity.label %> +
+ + <% if activity.label === 'events' %> + <%= image_tag(activity.params['first_image']) %> +<%= activity.params['name'] %>
<%= strip_tags(activity.params['lead']) %>
<%= describe(activity).html_safe %>
+ <% end %>