diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-18 19:16:32 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-18 19:16:32 +0000 |
commit | ab651ef45ced72dadb32ce7bdbd0f040fc2652fc (patch) | |
tree | 4d6e9abc025a97fa525832dd42fcc1fc44fee1be | |
parent | e540498f2b028414ba6093823512e3ac457a0b3b (diff) | |
parent | e460e04e16abe5409b2e4918016a29b0415790ca (diff) | |
download | gitlab-ce-ab651ef45ced72dadb32ce7bdbd0f040fc2652fc.tar.gz |
Merge branch 'syntax_highlight_diff_email' into 'master'
Add syntax colors to diffs in email-on-push notifications
## What does this MR do?
This MR adds syntaxhighlighting to the email-on-push notifications.
## Are there points in the code the reviewer needs to double check?
No
## Why was this MR needed?
Currently the diff in email-on-push notifications is just a monochrome diff that's hard to read.
This MR adds colored syntaxhighlighting to the mails.
## What are the relevant issue numbers / Feature requests?
* It closes https://github.com/gitlabhq/gitlabhq/issues/6994
* There is a Discussion in the Feedback Forum: http://feedback.gitlab.com/forums/176466-general/suggestions/5802256-add-color-to-diffs-in-email-on-push-service-to-htm
* A pull request for this already existed, but was closed. https://github.com/gitlabhq/gitlabhq/pull/7739
## Screenshots
see prior Pull Request for a screenshot
See merge request !295
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | app/helpers/emails_helper.rb | 10 | ||||
-rw-r--r-- | app/views/layouts/notify.html.haml | 2 | ||||
-rw-r--r-- | app/views/notify/repository_push_email.html.haml | 2 |
4 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index 240173b3b31..6784c1f258f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ v 7.8.0 - Expose description in groups API - - - - + - Add diff syntax highlighting in email-on-push service notifications (Hannes Rosenögger) - - - diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index 24d67c21d6b..b336263049c 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -29,4 +29,14 @@ module EmailsHelper end end end + + def add_email_highlight_css + Rugments::Themes::Github.render(:scope => '.highlight') + end + + def color_email_diff(diffcontent) + formatter = Rugments::Formatters::HTML.new(cssclass: 'highlight') + lexer = Rugments::Lexers::Diff.new + raw formatter.format(lexer.lex(diffcontent)) + end end diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index e81cf9e5bf6..a722db2f32c 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -16,7 +16,7 @@ font-size:small; color:#777 } - + #{add_email_highlight_css} %body %div.content = yield diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml index d678147ec5d..b6fe445867c 100644 --- a/app/views/notify/repository_push_email.html.haml +++ b/app/views/notify/repository_push_email.html.haml @@ -23,7 +23,7 @@ = diff.new_path || diff.old_path %hr %pre - = diff.diff + = color_email_diff(diff.diff) %br - if @compare.timeout |