summaryrefslogtreecommitdiff
path: root/app/views/forums/show.html.erb
blob: b232292df85c6bc4f5b798980e5f85152c047b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= @forum %>

<h1>
  <%= title @forum %>
  <%= link_to "Search Threads", forumthreads_path(forum: @forum.id), class: "btn blue right" %>
</h1>
<% if @forum.can_write?(current_user) %>
  <p>
    <%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %>
  </p>
<% end %>

<% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %>
  <div class="lockednote">
    <% if @forum.role_read > current_user.role %>
      This forum is write-only. You can only see your own posts.
    <% else %>
      This forum is write-only for users ranked under <%= @forum.role_read %>. They can only see their own posts.
    <% end %>
  </div>
<% end %>

<div id="forum_groups">
  <% @threads.each do |thread| %>
    <div class="item-group with-avatar" id="thread-<%= thread.id %>">
      <div class="header">
        <%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %>
        <%= render partial: "users/username", locals: { user: thread.author } %>
        <%= link_to thread do %>
          <%= ago thread.created_at %>
        <% end %>
        <span class="comment-counter">
          <%= link_to pluralize(thread.replies.count, "Reply"), thread %>
        </span>
        <div class="clear-right"></div>
      </div>
      <div class="items bold">
        <div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
          <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
          <div class="item-info">
            <% if rpl = thread.replies.last %>
              <%= rpl.author.name %>
              <%
                position = thread.replies.count - 1
                page     = position / Kaminari.config.default_per_page + 1
              %>
              <%= link_to "replied", forumthread_path(thread, page: page) + "#reply-#{rpl.id}" %>
              <%= ago rpl.created_at %>.
            <% else %>
              No replies yet.
            <% end %>
          </div>
          <div class="clear"></div>
        </div>
      </div>
    </div>
  <% end %>
  <%= paginate @threads %>
</div>