Module: Routing::SnippetsHelper

Included in:
GitlabRoutingHelper
Defined in:
app/helpers/routing/snippets_helper.rb

Instance Method Summary collapse

Instance Method Details

#gitlab_dashboard_snippets_path(snippet, *args) ⇒ Object


23
24
25
26
27
28
29
# File 'app/helpers/routing/snippets_helper.rb', line 23

def gitlab_dashboard_snippets_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippets_path(snippet.project, *args)
  else
    dashboard_snippets_path
  end
end

#gitlab_raw_snippet_blob_path(snippet, path, ref = nil, **options) ⇒ Object


63
64
65
# File 'app/helpers/routing/snippets_helper.rb', line 63

def gitlab_raw_snippet_blob_path(snippet, path, ref = nil, **options)
  gitlab_raw_snippet_blob_url(snippet, path, ref, only_path: true, **options)
end

#gitlab_raw_snippet_blob_url(snippet, path, ref = nil, **options) ⇒ Object


49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/routing/snippets_helper.rb', line 49

def gitlab_raw_snippet_blob_url(snippet, path, ref = nil, **options)
  params = {
    snippet_id: snippet,
    ref: ref || snippet.default_branch,
    path: path
  }

  if snippet.is_a?(ProjectSnippet)
    project_snippet_blob_raw_url(snippet.project, **params, **options)
  else
    snippet_blob_raw_url(**params, **options)
  end
end

#gitlab_raw_snippet_path(snippet, *args) ⇒ Object


31
32
33
34
35
36
37
38
# File 'app/helpers/routing/snippets_helper.rb', line 31

def gitlab_raw_snippet_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    raw_project_snippet_path(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    raw_snippet_path(snippet, *new_args)
  end
end

#gitlab_raw_snippet_url(snippet, *args) ⇒ Object


40
41
42
43
44
45
46
47
# File 'app/helpers/routing/snippets_helper.rb', line 40

def gitlab_raw_snippet_url(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    raw_project_snippet_url(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    raw_snippet_url(snippet, *new_args)
  end
end

#gitlab_snippet_note_path(snippet, note, *args) ⇒ Object


77
78
79
80
# File 'app/helpers/routing/snippets_helper.rb', line 77

def gitlab_snippet_note_path(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_note_path(snippet, note, *new_args)
end

#gitlab_snippet_note_url(snippet, note, *args) ⇒ Object


82
83
84
85
# File 'app/helpers/routing/snippets_helper.rb', line 82

def gitlab_snippet_note_url(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_note_url(snippet, note, *new_args)
end

#gitlab_snippet_notes_path(snippet, *args) ⇒ Object


67
68
69
70
# File 'app/helpers/routing/snippets_helper.rb', line 67

def gitlab_snippet_notes_path(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_notes_path(snippet, *new_args)
end

#gitlab_snippet_notes_url(snippet, *args) ⇒ Object


72
73
74
75
# File 'app/helpers/routing/snippets_helper.rb', line 72

def gitlab_snippet_notes_url(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_notes_url(snippet, *new_args)
end

#gitlab_snippet_path(snippet, *args) ⇒ Object


5
6
7
8
9
10
11
12
# File 'app/helpers/routing/snippets_helper.rb', line 5

def gitlab_snippet_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippet_path(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    snippet_path(snippet, *new_args)
  end
end

#gitlab_snippet_url(snippet, *args) ⇒ Object


14
15
16
17
18
19
20
21
# File 'app/helpers/routing/snippets_helper.rb', line 14

def gitlab_snippet_url(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippet_url(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    snippet_url(snippet, *new_args)
  end
end

#gitlab_toggle_award_emoji_snippet_note_path(snippet, note, *args) ⇒ Object


87
88
89
90
# File 'app/helpers/routing/snippets_helper.rb', line 87

def gitlab_toggle_award_emoji_snippet_note_path(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_note_path(snippet, note, *new_args)
end

#gitlab_toggle_award_emoji_snippet_note_url(snippet, note, *args) ⇒ Object


92
93
94
95
# File 'app/helpers/routing/snippets_helper.rb', line 92

def gitlab_toggle_award_emoji_snippet_note_url(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_note_url(snippet, note, *new_args)
end

#gitlab_toggle_award_emoji_snippet_path(snippet, *args) ⇒ Object


97
98
99
100
# File 'app/helpers/routing/snippets_helper.rb', line 97

def gitlab_toggle_award_emoji_snippet_path(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_path(snippet, *new_args)
end

#gitlab_toggle_award_emoji_snippet_url(snippet, *args) ⇒ Object


102
103
104
105
# File 'app/helpers/routing/snippets_helper.rb', line 102

def gitlab_toggle_award_emoji_snippet_url(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_url(snippet, *new_args)
end

#preview_markdown_path(parent, *args) ⇒ Object


107
108
109
110
111
112
113
114
115
# File 'app/helpers/routing/snippets_helper.rb', line 107

def preview_markdown_path(parent, *args)
  return group_preview_markdown_path(parent, *args) if parent.is_a?(Group)

  if @snippet.is_a?(PersonalSnippet)
    preview_markdown_snippets_path
  else
    preview_markdown_project_path(parent, *args)
  end
end

#toggle_award_emoji_personal_snippet_path(*args) ⇒ Object


117
118
119
# File 'app/helpers/routing/snippets_helper.rb', line 117

def toggle_award_emoji_personal_snippet_path(*args)
  toggle_award_emoji_snippet_path(*args)
end

#toggle_award_emoji_project_project_snippet_path(*args) ⇒ Object


121
122
123
# File 'app/helpers/routing/snippets_helper.rb', line 121

def toggle_award_emoji_project_project_snippet_path(*args)
  toggle_award_emoji_project_snippet_path(*args)
end

#toggle_award_emoji_project_project_snippet_url(*args) ⇒ Object


125
126
127
# File 'app/helpers/routing/snippets_helper.rb', line 125

def toggle_award_emoji_project_project_snippet_url(*args)
  toggle_award_emoji_project_snippet_url(*args)
end