-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from it3s/activity-stream
Activity stream
- Loading branch information
Showing
41 changed files
with
562 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.activities-list { | ||
.list-item { | ||
|
||
&.small .item { width: 562px; } | ||
|
||
.trackable { font-weight: bold; } | ||
|
||
&.user { | ||
.item-avatar { background-color: $meppit-dark-green; } | ||
.trackable { color: $meppit-dark-green; } | ||
} | ||
|
||
&.geo_data { | ||
.trackable { color: $meppit-data-color; } | ||
} | ||
|
||
&.map { | ||
.trackable { color: $meppit-maps-color; } | ||
} | ||
} | ||
|
||
.event-type { | ||
font-weight: bold; | ||
} | ||
|
||
.activity-event { | ||
display: inline-block; | ||
} | ||
|
||
.activity-time { | ||
display: inline-block; | ||
font-size: 0.8em; | ||
color: $grey; | ||
margin-left: 10px; | ||
} | ||
|
||
.activity-changes { | ||
margin-top: 5px; | ||
font-size: 0.9em; | ||
color: $grey; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,4 @@ | |
@import "maps"; | ||
@import "versions"; | ||
@import "relations"; | ||
@import "activities"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class ActivitiesController < ApplicationController | ||
before_action :find_user, only: [:user_activity] | ||
|
||
def user_activity | ||
@activities = paginate @user.activities_performed | ||
render layout: nil if request.xhr? | ||
end | ||
|
||
private | ||
|
||
def find_user | ||
@user ||= User.find(id: params[:user_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class ActivityListener | ||
|
||
IGNORE_KEYS = ["updated_at", "created_at", "administrator_id"] | ||
REMOVE_VALS = ["avatar"] | ||
|
||
def geo_data_created(payload) | ||
save_activity payload, :geo_data, :create | ||
end | ||
|
||
def geo_data_updated(payload) | ||
save_activity payload, :geo_data, :update | ||
end | ||
|
||
def map_created(payload) | ||
save_activity payload, :map, :create | ||
end | ||
|
||
def map_updated(payload) | ||
save_activity payload, :map, :update | ||
end | ||
|
||
def user_updated(payload) | ||
save_activity payload, :user, :update | ||
end | ||
|
||
def followed(payload) | ||
save_activity payload, :object, :follow | ||
end | ||
|
||
private | ||
|
||
def save_activity(params, key, action) | ||
trackable = params[key] | ||
changes = cleaned_changes(params) | ||
|
||
trackable.create_activity action, owner: params[:current_user], parameters: {changes: changes} | ||
end | ||
|
||
def cleaned_changes(params) | ||
return {} unless params[:changes] | ||
changes = params[:changes].except(*IGNORE_KEYS) | ||
REMOVE_VALS.each { |key| changes[key] = ["", ""] if changes[key] } | ||
changes | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
class RelationshipsListener | ||
|
||
def geo_data_updated(payload) | ||
geo_data = payload[:geo_data] | ||
geo_data.save_relations_from_attributes if geo_data.relations_attributes | ||
save_relation payload[:geo_data] | ||
end | ||
|
||
def geo_data_created(payload) | ||
save_relation payload[:geo_data] | ||
end | ||
|
||
private | ||
|
||
def save_relation(geo_data) | ||
geo_data.save_relations_from_attributes if geo_data.relations_attributes | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.