## mako

<%! main_css = "style-discussion-main" %>

<%page expression_filter="h"/>
<%inherit file="../main.html" />
<%namespace name='static' file='../static_content.html'/>
<%def name="online_help_token()"><% return "discussions" %></%def>
<%!
import json
from django.utils.translation import ugettext as _
from django.template.defaultfilters import escapejs
from django.core.urlresolvers import reverse

from django_comment_client.permissions import has_permission
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
%>

<%block name="bodyclass">discussion</%block>
<%block name="pagetitle">${_("Discussion - {course_number}").format(course_number=course.display_number_with_default)}</%block>

<%block name="headextra">
<%include file="../discussion/_js_head_dependencies.html" />
</%block>

<%block name="base_js_dependencies">
    ## Enable fast preview to fix discussion MathJax rendering bug when page first loads.
    <%include file="/discussion/_js_body_dependencies.html" args="disable_fast_preview=False"/>
</%block>

<%block name="js_extra">
<%static:require_module module_name="discussion/js/discussion_board_factory" class_name="DiscussionBoardFactory">
DiscussionBoardFactory({
    courseId: '${unicode(course.id) | n, js_escaped_string}',
    $el: $(".discussion-board"),
    user_info: ${user_info | n, dump_js_escaped_json},
    roles: ${roles | n, dump_js_escaped_json},
    sort_preference: '${sort_preference | n, js_escaped_string}',
    threads: ${threads | n, dump_js_escaped_json},
    thread_pages: '${thread_pages | n, js_escaped_string}',
    content_info: ${annotated_content_info | n, dump_js_escaped_json},
    course_name: '${course.display_name_with_default | n, js_escaped_string}',
    course_settings: ${course_settings | n, dump_js_escaped_json}
});
</%static:require_module>
</%block>

<%include file="../courseware/course_navigation.html" args="active_page='discussion'" />

<%block name="content">
<section class="discussion discussion-board container" id="discussion-container"
         data-course-id="${course_id}"
         data-user-create-comment="${json.dumps(can_create_comment)}"
         data-user-create-subcomment="${json.dumps(can_create_subcomment)}"
         data-read-only="false"
         data-sort-preference="${sort_preference}"
         data-flag-moderator="${json.dumps(flag_moderator)}"
         data-user-cohort-id="${user_cohort}">
    <header class="page-header has-secondary">
        ## Breadcrumb navigation
        <div class="page-header-main">
            <nav aria-label="${_('Discussions')}" class="sr-is-focusable" tabindex="-1">
                <div class="has-breadcrumbs"></div>
            </nav>
        </div>
        <div class="page-header-secondary">
            ## Add Post button
            % if has_permission(user, 'create_thread', course.id):
            <div class="form-actions">
                <button class="btn-brand btn-small new-post-btn">${_("Add a Post")}</button>
            </div>
            % endif
            ## Search box
            <div class="forum-search"></div>
        </div>
    </header>
    <div class="page-content">
        <div class="discussion-body layout layout-1t2t">
            <aside class="forum-nav layout-col layout-col-a" role="complementary" aria-label="${_("Discussion thread list")}">
            </aside>

            <main id="main" aria-label="Content" tabindex="-1" class="discussion-column layout-col layout-col-b">
                <article class="new-post-article" style="display: none" tabindex="-1" aria-label="${_("New topic form")}"></article>
                <div class="forum-content"></div>
            </main>
        </div>
    </div>
</section>
</%block>

<%include file="_underscore_templates.html" />
<%include file="_thread_list_template.html" />
