Commit cf5d3bb0add2344ea6fd31520535fd2f382ff637
1 parent
887c0c67
Exists in
master
and in
4 other branches
Improve help page for Project web hooks
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
68 additions
and
53 deletions
Show diff stats
app/helpers/application_helper.rb
| @@ -207,4 +207,12 @@ module ApplicationHelper | @@ -207,4 +207,12 @@ module ApplicationHelper | ||
| 207 | def broadcast_message | 207 | def broadcast_message |
| 208 | BroadcastMessage.current | 208 | BroadcastMessage.current |
| 209 | end | 209 | end |
| 210 | + | ||
| 211 | + def highlight_js(&block) | ||
| 212 | + string = capture(&block) | ||
| 213 | + | ||
| 214 | + content_tag :div, class: user_color_scheme_class do | ||
| 215 | + Pygments::Lexer[:js].highlight(string).html_safe | ||
| 216 | + end | ||
| 217 | + end | ||
| 210 | end | 218 | end |
app/views/help/web_hooks.html.haml
| @@ -4,21 +4,68 @@ | @@ -4,21 +4,68 @@ | ||
| 4 | Project web hooks allow you to trigger url if new code is pushed or new issue is created | 4 | Project web hooks allow you to trigger url if new code is pushed or new issue is created |
| 5 | %hr | 5 | %hr |
| 6 | 6 | ||
| 7 | - %p | 7 | + %p.slead |
| 8 | You can configure web hook to listen for specific events like pushes, issues, merge requests. | 8 | You can configure web hook to listen for specific events like pushes, issues, merge requests. |
| 9 | %br | 9 | %br |
| 10 | GitLab will send POST request with data to web hook url. | 10 | GitLab will send POST request with data to web hook url. |
| 11 | %br | 11 | %br |
| 12 | Web Hooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. | 12 | Web Hooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. |
| 13 | - | 13 | + %hr |
| 14 | 14 | ||
| 15 | %h4 Push events | 15 | %h4 Push events |
| 16 | - = render "projects/hooks/data_ex" | 16 | + %p.light |
| 17 | + Triggered when you push to the repository except pushing tags. | ||
| 18 | + %br | ||
| 19 | + Request body: | ||
| 20 | + = highlight_js do | ||
| 21 | + :erb | ||
| 22 | + { | ||
| 23 | + "before": "95790bf891e76fee5e1747ab589903a6a1f80f22", | ||
| 24 | + "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 25 | + "ref": "refs/heads/master", | ||
| 26 | + "user_id": 4, | ||
| 27 | + "user_name": "John Smith", | ||
| 28 | + "project_id": 15, | ||
| 29 | + "repository": { | ||
| 30 | + "name": "Diaspora", | ||
| 31 | + "url": "git@localhost:diaspora.git", | ||
| 32 | + "description": "", | ||
| 33 | + "homepage": "http://localhost/diaspora", | ||
| 34 | + }, | ||
| 35 | + "commits": [ | ||
| 36 | + { | ||
| 37 | + "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", | ||
| 38 | + "message": "Update Catalan translation to e38cb41.", | ||
| 39 | + "timestamp": "2011-12-12T14:27:31+02:00", | ||
| 40 | + "url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", | ||
| 41 | + "author": { | ||
| 42 | + "name": "Jordi Mallach", | ||
| 43 | + "email": "jordi@softcatala.org", | ||
| 44 | + } | ||
| 45 | + }, | ||
| 46 | + // ... | ||
| 47 | + { | ||
| 48 | + "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 49 | + "message": "fixed readme", | ||
| 50 | + "timestamp": "2012-01-03T23:36:29+02:00", | ||
| 51 | + "url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 52 | + "author": { | ||
| 53 | + "name": "GitLab dev user", | ||
| 54 | + "email": "gitlabdev@dv6700.(none)", | ||
| 55 | + }, | ||
| 56 | + }, | ||
| 57 | + ], | ||
| 58 | + "total_commits_count": 4, | ||
| 59 | + }; | ||
| 17 | 60 | ||
| 18 | 61 | ||
| 19 | - %h4 Issues events | ||
| 20 | - %pre | ||
| 21 | - :preserve | 62 | + %h4.prepend-top-20 Issues events |
| 63 | + %p.light | ||
| 64 | + Triggered when new issue created or existing issue was closed. | ||
| 65 | + %br | ||
| 66 | + Request body: | ||
| 67 | + = highlight_js do | ||
| 68 | + :erb | ||
| 22 | { | 69 | { |
| 23 | "object_kind":"issue", | 70 | "object_kind":"issue", |
| 24 | "object_attributes":{ | 71 | "object_attributes":{ |
| @@ -37,9 +84,13 @@ | @@ -37,9 +84,13 @@ | ||
| 37 | "iid":23 | 84 | "iid":23 |
| 38 | } | 85 | } |
| 39 | } | 86 | } |
| 40 | - %h4 Merge request events | ||
| 41 | - %pre | ||
| 42 | - :preserve | 87 | + %h4.prepend-top-20 Merge request events |
| 88 | + %p.light | ||
| 89 | + Triggered when new merge request created or existing merge request was merged/closed. | ||
| 90 | + %br | ||
| 91 | + Request body: | ||
| 92 | + = highlight_js do | ||
| 93 | + :erb | ||
| 43 | { | 94 | { |
| 44 | "object_kind":"merge_request", | 95 | "object_kind":"merge_request", |
| 45 | "object_attributes":{ | 96 | "object_attributes":{ |
app/views/projects/hooks/_data_ex.html.erb
| @@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
| 1 | -<% data_ex_str = <<eos | ||
| 2 | -{ | ||
| 3 | - "before": "95790bf891e76fee5e1747ab589903a6a1f80f22", | ||
| 4 | - "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 5 | - "ref": "refs/heads/master", | ||
| 6 | - "user_id": 4, | ||
| 7 | - "user_name": "John Smith", | ||
| 8 | - "project_id": 15, | ||
| 9 | - "repository": { | ||
| 10 | - "name": "Diaspora", | ||
| 11 | - "url": "git@localhost:diaspora.git", | ||
| 12 | - "description": "", | ||
| 13 | - "homepage": "http://localhost/diaspora", | ||
| 14 | - }, | ||
| 15 | - "commits": [ | ||
| 16 | - { | ||
| 17 | - "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", | ||
| 18 | - "message": "Update Catalan translation to e38cb41.", | ||
| 19 | - "timestamp": "2011-12-12T14:27:31+02:00", | ||
| 20 | - "url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", | ||
| 21 | - "author": { | ||
| 22 | - "name": "Jordi Mallach", | ||
| 23 | - "email": "jordi@softcatala.org", | ||
| 24 | - } | ||
| 25 | - }, | ||
| 26 | - // ... | ||
| 27 | - { | ||
| 28 | - "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 29 | - "message": "fixed readme", | ||
| 30 | - "timestamp": "2012-01-03T23:36:29+02:00", | ||
| 31 | - "url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", | ||
| 32 | - "author": { | ||
| 33 | - "name": "GitLab dev user", | ||
| 34 | - "email": "gitlabdev@dv6700.(none)", | ||
| 35 | - }, | ||
| 36 | - }, | ||
| 37 | - ], | ||
| 38 | - "total_commits_count": 4, | ||
| 39 | -}; | ||
| 40 | -eos | ||
| 41 | -%> | ||
| 42 | -<div class="<%= user_color_scheme_class%>"> | ||
| 43 | - <%= raw Pygments::Lexer[:js].highlight(data_ex_str) %> | ||
| 44 | -</div> |