BigW Consortium Gitlab

_snippet_blob.html.haml 1.93 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 10 11 12
    = 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)}
13
  %h4.snippet-title
Valery Sizov committed
14
  - snippet_path = reliable_snippet_path(snippet)
15 16 17
  = link_to snippet_path do
    .file-holder
      .file-title
18
        %i.fa.fa-file
Valery Sizov committed
19 20
        %strong= snippet.file_name
      - if markup?(snippet.file_name)
21
        .file-content.wiki
Valery Sizov committed
22 23 24
          - snippet_chunks.each do |chunk|
            - unless chunk[:data].empty?
              = render_markup(snippet.file_name, chunk[:data])
25 26 27 28
            - else
              .file-content.code
                .nothing-here-block Empty file
      - else
29 30
        .file-content.code.js-syntax-highlight
          .line-numbers
Valery Sizov committed
31 32
            - snippet_chunks.each do |chunk|
              - unless chunk[:data].empty?
33
                - Gitlab::Git::Util.count_lines(chunk[:data]).times do |index|
Valery Sizov committed
34
                  - offset = defined?(chunk[:start_line]) ? chunk[:start_line] : 1
35 36 37 38
                  - 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
Valery Sizov committed
39
                - unless snippet == snippet_chunks.last
40 41 42 43
                  %a.diff-line-num
                    = "."
          %pre.code
            %code
Valery Sizov committed
44 45 46 47
              - snippet_chunks.each do |chunk|
                - unless chunk[:data].empty?
                  = chunk[:data]
                  - unless chunk == snippet_chunks.last
48
                    %a
49 50 51 52
                      = "..."
                - else
                  .file-content.code
                    .nothing-here-block Empty file