Sha256: f81cd8b5d6fc7a4378bbdfe3b1a5d665ba24778077902c464dad85ac9f26ad52

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

= javascript_include_tag 'highlight.pack.js', '//code.jquery.com/jquery-1.12.4.js', '//code.jquery.com/ui/1.12.1/jquery-ui.js'
= stylesheet_link_tag 'railscasts'

= content_for :title, t('.title')

.sidebar
  .sidebar-wrapper
    ul
      - @lines.each_with_index do |item, item_index|
        li = link_to item.keys.first.split('/').last, "#anchor#{item_index}"
.right
  h4
    = t('.response_status', status: @response_status)
  - @lines.each_with_index do |item, item_index|
    .filename id="anchor#{item_index}"
      - file = item.keys.first
      .arrow-right
      .filename-title
        = file.remove(Rails.root.to_s)
      - lines = item.values.split(' ').flatten.map(&:to_i)
      - previous_row_is_empty = false
    .listing
      - file_context = File.open(Rails.root.join(file), 'r').read.split("\n")
      - html_rows = []
      - file_context.each_with_index do |row, index_row|
        - include = lines.include?(index_row + 1)
        - if include || lines.reduce(false) { |memo, line| memo || index_row.in?(line - 5..line + 4) }
          - previous_row_is_empty = false
          - html_row = "#{index_row + 1} #{'-> ' + lines.each_with_index.select { |_, index| lines[index] == index_row + 1 }.map { |_, index| index + 1 }.join(', ') if include} #{row}\n"
          - html_rows << content_tag(:code, html_row, style: "#{include ? 'background-color: #4a4a4a;' : nil}")
        - elsif !previous_row_is_empty
          - previous_row_is_empty = true
          - html_rows << "...\n"
      pre
        code
          - html_rows.each do |html_row|
            = html_row

javascript:
  $(document).ready(function(){
    hljs.initHighlighting();

    $('.filename').on('click', function(){
      $(this).find('.arrow-right').toggleClass('down')
      $(this).next().slideToggle();
    });

    $('.sidebar-wrapper > ul > li > a').on('click', function(){
      var anchor = $(this).first().attr('href').split('#').pop();
      $('.filename#'+anchor).click();
    });
  })

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lecter-0.1.6 app/views/lecter/diagnosis/show.slim