BigW Consortium Gitlab

_snippet_blob.html.haml 1.72 KB
Newer Older
Valery Sizov committed
1 2 3 4
- snippet_blob = chunk_snippet(snippet_blob, @search_term)
- snippet = snippet_blob[:snippet_object]
- snippet_chunks = snippet_blob[:snippet_chunks]

5 6
.search-result-row
  %span
Valery Sizov committed
7
    = snippet.title
8
    by
Valery Sizov committed
9
    = link_to user_snippets_path(snippet.author) do
10
      = image_tag avatar_icon(snippet.author), class: "avatar avatar-inline s16", alt: ''
Valery Sizov committed
11
      = snippet.author_name
12
    %span.light= time_ago_with_tooltip(snippet.created_at)
13
  %h4.snippet-title
Valery Sizov committed
14
  - snippet_path = reliable_snippet_path(snippet)
15 16 17
  .file-holder
    .js-file-title.file-title
      = link_to snippet_path do
18
        %i.fa.fa-file
Valery Sizov committed
19
        %strong= snippet.file_name
20 21 22 23
    - if markup?(snippet.file_name)
      .file-content.wiki
        - snippet_chunks.each do |chunk|
          - unless chunk[:data].empty?
Douwe Maan committed
24
            = markup(snippet.file_name, chunk[:data])
25 26 27 28 29 30
          - else
            .file-content.code
              .nothing-here-block Empty file
    - else
      .file-content.code.js-syntax-highlight
        .line-numbers
Valery Sizov committed
31 32
          - snippet_chunks.each do |chunk|
            - unless chunk[:data].empty?
33 34 35 36 37 38 39 40 41
              - 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
        .blob-content
          - snippet_chunks.each do |chunk|
            - unless chunk[:data].empty?
42
              = highlight(snippet.file_name, chunk[:data], repository: nil, plain: snippet.blob.no_highlighting?)
43 44 45
            - else
              .file-content.code
                .nothing-here-block Empty file