Sha256: 16d72cd2f9204daea38dab6c07f413088812a6e5e8207c7c054e66a987b97fd9

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

description 'Subpages aspect'

Aspect.create(:subpages, priority: 2, layout: true, cacheable: true) do
  def accepts?(page); !page.children.empty?; end
  def call(context, page)
    @page_nr = [context.params[:page].to_i, 1].max
    per_page = 20
    @page = page
    @page_count = @page.children.size / per_page + 1
    @children = @page.children[((@page_nr - 1) * per_page) ... (@page_nr * per_page)].to_a
    render :subpages
  end
end

__END__
@@ subpages.slim
= pagination(@page, @page_count, @page_nr, aspect: 'subpages')
table#subpages-table
  thead
    tr
      th= :name.t
      th= :description.t
      th= :last_modified.t
      th= :author.t
      th= :comment.t
      th= :actions.t
  tbody
    - @children.each do |child|
      - classes = child.children.empty? ? 'page' : 'folder'
      - if !child.extension.empty?
        - classes << " file-type-#{child.extension}"
      tr
        td.link
          a href=build_path(child) class=classes = child.name
        td= truncate(child.attributes['description'], 30)
        td= date(child.version.date)
        td= truncate(child.version.author.name, 30)
        td= truncate(child.version.comment, 30)
        td.actions
          a.action-edit href=build_path(child, action: :edit) title=:edit.t = :edit.t
          a.action-history href=build_path(child, action: :history) title=:history.t = :history.t
          a.action-move href=build_path(child, action: :move) title=:move.t = :move.t
          a.action-delete href=build_path(child, action: :delete) title=:delete.t = :delete.t
= pagination(@page, @page_count, @page_nr, aspect: 'subpages')

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
olelo-0.9.8 plugins/aspects/subpages.rb
olelo-0.9.7 plugins/aspects/subpages.rb
olelo-0.9.6 plugins/aspects/subpages.rb
olelo-0.9.5 plugins/aspects/subpages.rb
olelo-0.9.4 plugins/aspects/subpages.rb