summaryrefslogtreecommitdiff
path: root/app/views/search/results/_snippet_blob.html.haml
blob: c9b7bd154afcb98bc17991fec1ab9580e57b4400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- snippet_blob = chunk_snippet(snippet_blob, @search_term)
- snippet = snippet_blob[:snippet_object]
- snippet_chunks = snippet_blob[:snippet_chunks]

.search-result-row
  %span
    = snippet.title
    by
    = link_to user_snippets_path(snippet.author) do
      = image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: ''
      = snippet.author_name
    %span.light #{time_ago_with_tooltip(snippet.created_at)}
  %h4.snippet-title
  - snippet_path = reliable_snippet_path(snippet)
  = link_to snippet_path do
    .file-holder
      .file-title
        %i.fa.fa-file
        %strong= snippet.file_name
      - if markup?(snippet.file_name)
        .file-content.wiki
          - snippet_chunks.each do |chunk|
            - unless chunk[:data].empty?
              = render_markup(snippet.file_name, chunk[:data])
            - else
              .file-content.code
                .nothing-here-block Empty file
      - else
        .file-content.code.js-syntax-highlight
          .line-numbers
            - snippet_chunks.each do |chunk|
              - unless chunk[:data].empty?
                - Gitlab::Git::Util.count_lines(chunk[:data]).times do |index|
                  - offset = defined?(chunk[:start_line]) ? chunk[:start_line] : 1
                  - i = index + offset
                  = link_to snippet_path+"#L#{i}", id: "L#{i}", rel: "#L#{i}", class: "diff-line-num" do
                    %i.fa.fa-link
                    = i
                - unless snippet == snippet_chunks.last
                  %a.diff-line-num
                    = "."
          %pre.code
            %code
              - snippet_chunks.each do |chunk|
                - unless chunk[:data].empty?
                  = chunk[:data]
                  - unless chunk == snippet_chunks.last
                    %a
                      = "..."
                - else
                  .file-content.code
                    .nothing-here-block Empty file