- include_stylesheet('admin/forum')
= render_region :top 

#forums_table.outset
  %table#forums.index{:cellspacing=>"0", :border=>"0", :cellpadding=>"0"}
    %thead
      %tr
        - render_region :thead do |thead|
          - thead.title_header do
            %th.forum Forum
          - thead.latest_header do
            %th.forum_latest Latest activity
          - thead.modify_header do
            %th.action Action
    %tbody
      - @forums.each do |forum|
        %tr.node.level-1
          - render_region :tbody do |tbody|

            - tbody.title_cell do
              %td.forum
                %h3
                  = link_to forum.name, edit_admin_forum_url(:id => forum)
                -if forum.for_comments
                  %p.context
                    (comments forum)
                = textilize(forum.description)
                %p
                  - if forum.respond_to?(:site)
                    = link_to "→ browse discussions", 'http://' + forum.site.base_domain + forum_path(forum)
                  - else
                    = link_to "→ browse discussions", forum_path(forum)

            - tbody.latest_cell do
              %td.forum_latest
                - if forum.posts_count > 0
                  %ul.latest
                    - forum.recent_topics.latest.each do |topic|
                      %li.topic
                        - if topic.page
                          = link_to topic.page.title, "#{topic.page.url}", {:class => 'topic'}
                        - else
                          = link_to topic.name, forum_topic_url(topic.forum, topic, :page => 'last'), {:class => 'topic'}
                        %br
                        %span.context
                          from
                          - if topic.posts.count > 1
                            = link_to topic.reader.name + '.', reader_url(topic.reader)
                            = topic.posts.count
                            = pluralize(topic.posts.count, 'comment') + ','
                            most recently from
                            = link_to topic.replied_by.name, reader_url(topic.replied_by)
                            = friendly_date(topic.replied_at)
                          - else 
                            = link_to topic.reader.name, reader_url(topic.reader)
                            = friendly_date(topic.created_at)
                -else
                  %p
                    No topics yet.
            - tbody.modify_cell do
              %td.remove
                -if forum.for_comments
                  = image('noremove', :alt => 'Remove Forum')
                -else
                  - if admin?
                    = link_to image('remove', :alt => 'Remove Forum'), remove_admin_forum_url(:id => forum) 
                  - else
                    = image('noremove', :alt => 'only admin can remove forums')

- render_region :bottom do |bottom|
  - bottom.new_button do
    - if admin?
      %p
        = link_to image('new-forum', :alt => 'New Forum'), new_admin_forum_url