2012-01-25 08:31:49 +00:00
|
|
|
module ActivityFeedsHelper
|
2012-04-17 16:38:02 +01:00
|
|
|
def get_feed_title_from_content(content)
|
|
|
|
# removes html tags and haml generator indentation whitespaces and new line chars:
|
|
|
|
feed_title = strip_tags(content).gsub(/(^\s+|\n| )/, ' ')
|
|
|
|
# removes multiple whitespaces in a row and strip it:
|
|
|
|
feed_title = feed_title.gsub(/\s{2,}/, ' ').strip
|
|
|
|
end
|
2013-02-25 07:50:53 +00:00
|
|
|
|
2014-04-08 14:11:34 +01:00
|
|
|
def get_user_from_activity_item(item)
|
2015-05-05 13:25:29 +01:00
|
|
|
email = item.data[:creator_email]
|
2014-04-08 14:11:34 +01:00
|
|
|
User.where(email: email).first || User.new(email: email) if email.present?
|
|
|
|
end
|
|
|
|
|
2013-11-26 18:39:30 +00:00
|
|
|
def user_link(user, user_name, full_url = false)
|
|
|
|
user.persisted? ? link_to(user_name, full_url ? user_url(user) : user_path(user)) : user_name
|
2013-02-25 07:50:53 +00:00
|
|
|
end
|
2014-05-06 13:58:10 +01:00
|
|
|
|
|
|
|
def get_feed_build_list_status_message(status)
|
|
|
|
message, error = case status
|
|
|
|
when BuildList::BUILD_PENDING
|
|
|
|
['pending', nil]
|
|
|
|
when BuildList::BUILD_PUBLISHED
|
|
|
|
['published', nil]
|
|
|
|
when BuildList::SUCCESS
|
|
|
|
['success', nil]
|
|
|
|
else ['failed', t("layout.build_lists.statuses.#{BuildList::HUMAN_STATUSES[status]}")]
|
|
|
|
end
|
|
|
|
" #{t("notifications.bodies.build_status.#{message}", error: error)}"
|
|
|
|
end
|
2012-01-25 08:31:49 +00:00
|
|
|
end
|