yegor256/0rsk

View on GitHub
views/ranked.haml

Summary

Maintainability
Test Coverage
%form{method: 'GET', action: ''}
  %input{type: 'text', name: 'q', size: 40, autocomplete: 'off', autofocus: 'true', tabindex: 1, value: query}
  %input{type: 'submit', value: 'Search', tabindex: 2}

- unless alone.empty?
  %p
    = succeed ':' do
      %strong.red ATTENTION
    There are
    %a{href: iri.cut('/ranked').add(q: '+alone')} a few risks
    without any plans!

- if triples.empty?
  %p
    %span.red Nothing
    found, sorry.
- else
  %p
    There are
    = total
    risks:
  - triples.each do |r|
    %p
      = thumb(r)
      = rank(r)
      %a{href: iri.over(q: r[:emoji])}<
        &= r[:emoji]
      = part('C', r[:cid])
      ➜
      = part('R', r[:rid])
      ➜
      = part('E', r[:eid])
      %br
      &= "#{r[:ctext]};"
      &= "#{r[:rtext]};"
      &= "#{r[:etext]}."
      %br
      %a.item.small{href: iri.cut('/triple').add(id: r[:id])} Edit
      %a.item.small{href: iri.cut('/responses').add(id: r[:id])}<
        - if r[:plans].empty?
          %span.red No plans
        - else
          = "#{r[:plans].count} plan#{r[:plans].count == 1 ? '' : 's'}"
          = '&darr;'
      %a.item.small{href: iri.cut('/ranked/delete').add(id: r[:id]), onclick: "return confirm('Are sure you want to delete tripple ##{r[:id]}');"} Delete
      - unless r[:plans].empty?
        - r[:plans].each do |p|
          %br
          %span.small{style: 'margin-left: 2em;'}
            %code.small= "P#{p[:id]}"
            &= p[:text]
  = Haml::Engine.new(File.read('views/_paging.haml')).render(self, locals.merge(count: triples.count))