{{ template "base.html" . }}

{{ define "content" }}
<div class="content-block">
    {{ range .Subforums }}
        <div class="mv3">
            <h2 class="ma0 ph3 pb2">
                <a href="{{ .Url }}">
                    {{ .Name }} &raquo;<br/>
                </a>
            </h2>
            {{ range .Threads }}
                {{ template "thread_list_item.html" . }}
            {{ end }}
            {{ $more := sub .TotalThreads 3 }}
            {{ if gt $more 0 }}
                <div class="ph3 pv1">
                    <a class="title" href="{{ .Url }}">{{ $more }} more &raquo;</a>
                </div>
            {{ end }}
        </div>
    {{ end }}
    <div class="optionbar">
        {{ template "subforum_options" . }}
    </div>
    {{ range .Threads }}
        {{ template "thread_list_item.html" . }}
    {{ end }}
    <div class="optionbar bottom">
        {{ template "subforum_options" . }}
    </div>
</div>
{{ end }}

{{ define "subforum_options" }}
<div class="options">
    {{ if .Project.HasForum }}
        {{ if .User }}
            <a class="button new-thread" href="{{ .NewThreadUrl }}"><span class="big pr1">+</span> New Thread</a>
        {{ else }}
            <a class="button" href="{{ .LoginPageUrl }}">Log in to post a new thread</a>
        {{ end }}
    {{ end }}
    {{ if .User }}
        <form method="POST" action="{{ .MarkReadUrl }}">
            {{ csrftoken .Session }}
            <button type="submit"><span class="big pr1">&#x2713;</span> Mark threads here as read</button>
        </form>
    {{ end }}
</div>
<div class="options">
    {{ template "pagination.html" .Pagination }}
</div>
{{ end }}
