diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-11-12 14:57:38 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-11-12 14:57:38 +0000 |
commit | 6adc313a1f48809543c626aa226ad56979cdde99 (patch) | |
tree | 94f860b06b60a8a12e95bc36f292bff30b0fa912 /app | |
parent | 3bd12e992b40e1016e3431c58b8d6523219c78c3 (diff) | |
parent | 857852ce048607a0898a9b40e04fdb0658b6a83d (diff) | |
download | gitlab-ce-6adc313a1f48809543c626aa226ad56979cdde99.tar.gz |
Merge branch 'actions_in_the_inbox' into 'master'
Actions in the inbox
Related to #1607
See merge request !1247
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/emails_helper.rb | 32 | ||||
-rw-r--r-- | app/mailers/notify.rb | 1 | ||||
-rw-r--r-- | app/views/layouts/notify.html.haml | 1 |
3 files changed, 34 insertions, 0 deletions
diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb new file mode 100644 index 00000000000..24d67c21d6b --- /dev/null +++ b/app/helpers/emails_helper.rb @@ -0,0 +1,32 @@ +module EmailsHelper + + # Google Actions + # https://developers.google.com/gmail/markup/reference/go-to-action + def email_action(url) + name = action_title(url) + if name + data = { + "@context" => "http://schema.org", + "@type" => "EmailMessage", + "action" => { + "@type" => "ViewAction", + "name" => name, + "url" => url, + } + } + + content_tag :script, type: 'application/ld+json' do + data.to_json.html_safe + end + end + end + + def action_title(url) + return unless url + ["merge_requests", "issues", "commit"].each do |action| + if url.split("/").include?(action) + return "View #{action.humanize.singularize}" + end + end + end +end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index bd438bab89a..0ee19836627 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -11,6 +11,7 @@ class Notify < ActionMailer::Base add_template_helper ApplicationHelper add_template_helper GitlabMarkdownHelper add_template_helper MergeRequestsHelper + add_template_helper EmailsHelper default_url_options[:host] = Gitlab.config.gitlab.host default_url_options[:protocol] = Gitlab.config.gitlab.protocol diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index ab421d63f1a..da451961327 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -28,3 +28,4 @@ You're receiving this notification because you are a member of the #{link_to_unless @target_url, @project.name_with_namespace, project_url(@project)} project team. - if @target_url #{link_to "View it on GitLab", @target_url} + = email_action @target_url |