tnantoka/wizu

View on GitHub
app/views/pages/_page.html.slim

Summary

Maintainability
Test Coverage
= render 'pages/breadcrumb', page: page
.card
  .card-header
    .btn-group.btn-group-sm.pull-right
      - if can?(:manage, page)
        = link_to t('global.edit'), (page.wiki? ? edit_wiki_path(page) : edit_page_path(page)),
          class: 'btn btn-secondary js-edit-page', title: 'e'
      .btn-group.btn-group-sm
        button type="button" class="btn btn-secondary" data-toggle="dropdown"
          = icon('caret-down')
        .dropdown-menu.dropdown-menu-right
          = link_to t('global.histories'), histories_page_path(page), class: 'dropdown-item'
          - unless page.wiki?
            = link_to t('.markdown'), page_path(page, format: :md), class: 'dropdown-item'
            = link_to t('.html'), page_path(page, format: :html), class: 'dropdown-item'
          - if can?(:manage, page)
            .dropdown-divider
            = link_to t('global.delete'), page, method: :delete, class: 'dropdown-item text-danger',
              data: { confirm: t('global.are_you_sure') }
    - if page.wiki?
      => t('activerecord.attributes.wiki.content') if page.content.present?
    - else
      => page.title
    small.text-muted= time_ago(page.updated_at)
  - if !page.wiki? || page.content.present?
    .card-block
      - if page.headers > 1
        .card.markdown-body
          .card-block.p-y-0
            h4.card-title
              a href="#toc" data-toggle="collapse"= t('.toc')
            #toc.collapse.in= page.toc
      .markdown-body.text-break= page.render
  - if page.children.exists?
    .list-group.list-group-flush
      - page.children.each do |p|
        = link_to p, class: 'list-group-item' do
          => p.title
          small.text-muted= time_ago(p.updated_at)
  - if page.wiki? && can?(:manage, page)
    .card-block
      = render 'wikis/links', page: page