[#369] add missing templates; fix activity feed; add truncation to activity text

This commit is contained in:
Alexander Machehin 2014-05-06 18:58:10 +06:00
parent 32bbd69a58
commit 91dc74e73f
7 changed files with 54 additions and 8 deletions

View File

@ -19,7 +19,7 @@
.row
.container-fluid{ 'ng-repeat' => 'commit in item.last_commits' }
.col-sm-3.col-md-2
%a{ 'ng-href' => "{{commit.commit_path}}" } {{commit.hash}}
%a{ 'ng-href' => "{{commit.link}}" } {{commit.hash}}
.col-sm-8.col-md-9{ 'ng-bind-html' => "commit.message" }
.clearfix

View File

@ -11,7 +11,7 @@
.clearfix
.timeline-body
%p
{{'notification.new_comment.title' | i18n}}
{{'notification.new_commit_comment.title' | i18n}}
.row
.col-sm-3.col-md-2

View File

@ -28,6 +28,7 @@ var _locales = {
'pull_requests.filter.created': '<%= I18n.t('layout.pull_requests.created') %>',
'notification.new_comment.title': 'добавил новый комментарий к задаче ',
'notification.new_commit_comment.title': 'добавил новый комментарий к коммиту ',
'notification.push.delete_branch': 'удалил ветку ',
'notification.push.create_branch': 'создал новую ветку ',
'notification.push.update_branch': 'внес изменения в ветку ',
@ -36,6 +37,8 @@ var _locales = {
'notification.new_user.title': 'Здравствуйте, ',
'notification.new_user.content': 'Спасибо за вашу регистрацию!',
'notification.wiki.new_commit': 'обновил ',
'notification.build_list': 'сборочное задание ',
'notification.issue_assign': 'Вам назначили задачу ',
'read_more': 'Читать дальше',
@ -67,6 +70,7 @@ var _locales = {
'pull_requests.filter.created': '<%= I18n.t('layout.pull_requests.created') %>',
'notification.new_comment.title': 'added a new comment in issue ',
'notification.new_commit_comment.title': 'added a new comment in commit ',
'notification.push.delete_branch': 'deleted a branch ',
'notification.push.create_branch': 'created a new branch ',
'notification.push.update_branch': 'pushed to branch ',
@ -75,6 +79,8 @@ var _locales = {
'notification.new_user.title': 'Hello, ',
'notification.new_user.content': 'Thank you for your registration!',
'notification.wiki.new_commit': 'has been updated ',
'notification.build_list': 'build task ',
'notification.issue_assign': 'You have been assigned to issue ',
'read_more': 'Read more',

View File

@ -18,4 +18,17 @@ module ActivityFeedsHelper
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
end
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
end

View File

@ -11,6 +11,7 @@ module Feed::Comment
def new_comment_notifications
return if automatic?
if issue_comment?
commentable.subscribes.each do |subscribe|
if user_id != subscribe.user_id && can_notify_on_new_comment?(subscribe)
@ -23,7 +24,7 @@ module Feed::Comment
user_name: user.name,
user_email: user.email,
user_id: user_id,
comment_body: truncate(body, length: 100, omission: '…'),
comment_body: body.truncate(100, omission: '…'),
issue_title: commentable.title,
issue_serial_id: commentable.serial_id,
project_id: commentable.project.id,
@ -52,8 +53,8 @@ module Feed::Comment
user_name: user.name,
user_email: user.email,
user_id: user_id,
comment_body: body,
commit_message: commentable.message,
comment_body: body.truncate(100, omission: '…'),
commit_message: commentable.message.truncate(70, omission: '…'),
commit_id: commentable.id,
project_id: project.id,
comment_id: id,

View File

@ -17,11 +17,11 @@ module Feed::Git
change_type: change_type, project_owner: record.project.owner.uname}
else
if record.message # online update
last_commits, commits = [[record.newrev, truncate(record.message, length: 70, omission: '…')]], []
last_commits, commits = [[record.newrev, record.message.truncate(70, omission: '…')]], []
all_commits = last_commits
else
commits = record.project.repo.commits_between(record.oldrev, record.newrev)
all_commits = commits.collect { |commit| [commit.sha, truncate(commit.message, length: 70, omission: '…')] }
all_commits = commits.collect { |commit| [commit.sha, commit.message.truncate(70, omission: '…')] }
last_commits = all_commits.last(3).reverse
end

View File

@ -37,7 +37,7 @@ json.feed do
json.array! item.data[:last_commits] do |commit|
json.hash shortest_hash_id(commit[0])
json.message markdown(short_message(commit[1], 70))
json.commit_path commit_path(project_name_with_owner, commit[0])
json.link commit_path(project_name_with_owner, commit[0])
end
end
if item.data[:other_commits].present?
@ -62,6 +62,32 @@ json.feed do
when 'wiki_new_commit_notification'
json.wiki_link history_project_wiki_index_path(project_name_with_owner)
json.project_link project_path(project_name_with_owner)
when 'build_list_notification'
json.project_link project_path(project_name_with_owner)
json.build_list do
json.id item.data[:build_list_id]
json.link build_list_path(item.data[:build_list_id])
json.status_message get_feed_build_list_status_message(item.data[:status])
end
when 'issue_assign_notification'
json.project_link project_path(project_name_with_owner)
json.issue do
json.title item.data[:issue_title]
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
end
when 'new_comment_commit_notification'
json.project_link project_path(project_name_with_owner)
json.commit do
json.link commit_path(project_name_with_owner, item.data[:commit_id]) if item.data[:commit_id].present?
json.hash shortest_hash_id(item.data[:commit_id])
json.message markdown(short_message(item.data[:commit_message], 70))
json.read_more item.data[:comment_id]
end
json.body markdown(short_message(item.data[:comment_body], 100))
end
json.id item.id