diff --git a/common/static/common/js/spec_helpers/discussion_spec_helper.js b/common/static/common/js/spec_helpers/discussion_spec_helper.js index 77a7b8b4d7..76dd71f915 100644 --- a/common/static/common/js/spec_helpers/discussion_spec_helper.js +++ b/common/static/common/js/spec_helpers/discussion_spec_helper.js @@ -89,36 +89,8 @@ }; DiscussionSpecHelper.setUnderscoreFixtures = function() { - var templateFixture, templateName, templateNames, templateNamesNoTrailingTemplate, i, j, len; - templateNames = [ - 'thread', 'thread-show', 'thread-edit', 'thread-response', 'thread-response-show', - 'thread-response-edit', 'response-comment-show', 'response-comment-edit', 'thread-list-item', - 'search-alert', 'new-post', 'thread-type', 'new-post-menu-entry', 'new-post-alert', - 'new-post-menu-category', 'topic', 'post-user-display', 'inline-discussion', 'pagination', - 'profile-thread', 'customwmd-prompt', 'nav-loading', 'new-post-visibility' - ]; - templateNamesNoTrailingTemplate = [ - 'forum-action-endorse', 'forum-action-answer', 'forum-action-follow', 'forum-action-vote', - 'forum-action-report', 'forum-action-pin', 'forum-action-close', 'forum-action-edit', - 'forum-action-delete', 'forum-actions', 'alert-popup', 'nav-load-more-link' - ]; - for (i = 0, len = templateNames.length; i < len; i++) { - templateName = templateNames[i]; - templateFixture = readFixtures('common/templates/discussion/' + templateName + '.underscore'); - appendSetFixtures($(' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/static/common/templates/discussion/thread-edit.underscore b/common/static/common/templates/discussion/thread-edit.underscore deleted file mode 100644 index 95a825dded..0000000000 --- a/common/static/common/templates/discussion/thread-edit.underscore +++ /dev/null @@ -1,19 +0,0 @@ - class="thread-title"><%- gettext("Editing post") %>> - -
-
- -
-
-

<%- gettext('Edit your post below.') %>

-
<%- body %>
-
- - diff --git a/common/static/common/templates/discussion/thread-list-item.underscore b/common/static/common/templates/discussion/thread-list-item.underscore deleted file mode 100644 index 6aa6e4070b..0000000000 --- a/common/static/common/templates/discussion/thread-list-item.underscore +++ /dev/null @@ -1,111 +0,0 @@ -
  • - -
    - <% - var icon_class, sr_text; - if (thread_type === "discussion") { - icon_class = "fa-comments"; - // Translators: This is a label for a Discussion forum thread - sr_text = gettext("discussion"); - } else if (endorsed) { - icon_class = "fa-check-square-o"; - // Translators: This is a label for a Question forum thread with a marked answer - sr_text = gettext("answered question"); - } else { - icon_class = "fa-question"; - // Translators: This is a label for a Question forum thread without a marked answer - sr_text = gettext("unanswered question"); - } - %> - <%= sr_text %> - -
    - <%- title %> - <% if (showThreadPreview){ %> -
    <%- threadPreview %>
    - <% } %> - <% if(typeof(subscribed) === "undefined") { var subscribed = null; } %> - <% if(pinned || subscribed || staff_authored || community_ta_authored) { %> -
      - <% if (pinned) { %> - - <% } %> - <% if (subscribed) { %> - - <% } %> - <% if (staff_authored) { %> - - <% } %> - <% if (community_ta_authored) { %> - - <% } %> -
    - <% } %> -
    - <% - // Translators: 'votes_count' is a numerical placeholder for a specific discussion thread; 'span_start' and 'span_end' placeholders refer to HTML markup. Please translate the word 'votes'. - var fmt = ngettext( - "%(votes_count)s%(span_start)s vote %(span_end)s", - "%(votes_count)s%(span_start)s votes %(span_end)s", - votes['up_count'] - ); - %> - - +<%= interpolate(fmt, { - votes_count: votes['up_count'], - span_start: '', - span_end: '' - }, true) - %> - - - <% if (!hideReadState && !neverRead && unread_comments_count > 0) { %> - - <%- - StringUtils.interpolate( - gettext('{unread_comments_count} new'), - {unread_comments_count: unread_comments_count} - ) - %> - - <% } %> - - - <% - var fmt; - // Counts in data do not include the post itself, but the UI should - var data = { - 'span_sr_open': '', - 'span_close': '', - 'unread_comments_count': unread_comments_count + (read ? 0 : 1), - 'comments_count': comments_count + 1 - }; - if (unread_comments_count > 0) { - // Translators: 'comments_count' and 'unread_comments_count' are numerical placeholders for a specific discussion thread; 'span_*' placeholders refer to HTML markup. Please translate the word 'comments'. - fmt = gettext('%(comments_count)s %(span_sr_open)scomments (%(unread_comments_count)s unread comments)%(span_close)s'); - } else { - // Translators: 'comments_count' is a numerical placeholder for a specific discussion thread; 'span_*' placeholders refer to HTML markup. Please translate the word 'comments'. - fmt = gettext('%(comments_count)s %(span_sr_open)scomments %(span_close)s'); - } - print(interpolate(fmt, data, true)); - %> - -
    -
    -
  • diff --git a/common/static/common/templates/discussion/thread-response-edit.underscore b/common/static/common/templates/discussion/thread-response-edit.underscore deleted file mode 100644 index 97f7387eeb..0000000000 --- a/common/static/common/templates/discussion/thread-response-edit.underscore +++ /dev/null @@ -1,9 +0,0 @@ -
    - ><%- gettext("Editing response") %>> - -
    -
    <%- body %>
    -
    - - -
    diff --git a/common/static/common/templates/discussion/thread-response-show.underscore b/common/static/common/templates/discussion/thread-response-show.underscore deleted file mode 100644 index 29cbd233d8..0000000000 --- a/common/static/common/templates/discussion/thread-response-show.underscore +++ /dev/null @@ -1,62 +0,0 @@ -
    -
    - <%= author_display %> -

    - <%= created_at %> - <% if (obj.endorsement && obj.endorsed) { %> - - - <% - var fmt = null; - if (thread.get("thread_type") == "question") { - if (endorsement.username) { - // Translators: time_ago is a placeholder for a fuzzy, relative timestamp - // like "4 hours ago" or "about a month ago" - fmt = gettext("marked as answer %(time_ago)s by %(user)s"); - } else { - // Translators: time_ago is a placeholder for a fuzzy, relative timestamp - // like "4 hours ago" or "about a month ago" - fmt = gettext("marked as answer %(time_ago)s"); - } - } else { - if (endorsement.username) { - // Translators: time_ago is a placeholder for a fuzzy, relative timestamp - // like "4 hours ago" or "about a month ago" - fmt = gettext("endorsed %(time_ago)s by %(user)s"); - } else { - // Translators: time_ago is a placeholder for a fuzzy, relative timestamp - // like "4 hours ago" or "about a month ago" - fmt = gettext("endorsed %(time_ago)s"); - } - } - var time_ago = interpolate( - '%(time)s', - {time: endorsement.time}, - true - ); - %> - <%= interpolate(fmt, {time_ago: time_ago, user: endorser_display}, true) %> - <% } %> -

    - -
    -
    - <%= - _.template( - $('#forum-actions').html())( - { - contentId: cid, - contentType: 'response', - primaryActions: ['vote', thread.get('thread_type') == 'question' ? 'answer' : 'endorse'], - secondaryActions: ['edit', 'delete', 'report'], - readOnly: readOnly - } - ) - %> -
    -
    - -
    <%- body %>
    diff --git a/common/static/common/templates/discussion/thread-response.underscore b/common/static/common/templates/discussion/thread-response.underscore deleted file mode 100644 index a6934b35dc..0000000000 --- a/common/static/common/templates/discussion/thread-response.underscore +++ /dev/null @@ -1,23 +0,0 @@ -
    - -
      -
    1. - <% if (create_sub_comment && !readOnly) { %> -
      -
        - -
        -
        - -
        -
        - <% } %> -
      • -
      diff --git a/common/static/common/templates/discussion/thread-show.underscore b/common/static/common/templates/discussion/thread-show.underscore deleted file mode 100644 index faad477b13..0000000000 --- a/common/static/common/templates/discussion/thread-show.underscore +++ /dev/null @@ -1,86 +0,0 @@ -
      -
      - <% if (!readOnly) { %> -
      - <%= - _.template( - $('#forum-actions').html())( - { - contentId: cid, - contentType: 'post', - primaryActions: ['vote', 'follow'], - secondaryActions: ['pin', 'edit', 'delete', 'report', 'close'], - readOnly: readOnly - } - ) - %> -
      - <% } %> -
      - class="post-title"><%- title %>> -

      - <% - var timeAgoHtml = interpolate( - '%(created_at)s', - {created_at: created_at}, - true - ); - var postedTimeAgoMessage; - // Using a separate message to ensure proper translation for different languages - // thread_type describes the kind of post this is (e.g. "question" or "discussion"); - // time_ago is how much time has passed since the post was created (e.g. "4 hours ago") - if (thread_type === 'discussion') { - postedTimeAgoMessage = gettext('discussion posted %(time_ago)s by %(author)s'); - } else { - postedTimeAgoMessage = gettext('question posted %(time_ago)s by %(author)s'); - } - %> - <%= interpolate(_.escape(postedTimeAgoMessage), {time_ago: timeAgoHtml, author: author_display}, true) %> -

      - -
      -
      - -
      <%- body %>
      -
      - <% if (mode === "tab" && obj.courseware_url) { %> - <% - var courseware_title_linked = interpolate( - '%(courseware_title)s', - {courseware_url: courseware_url, courseware_title: _.escape(courseware_title)}, - true - ); - %> - <%= - interpolate( - _.escape(gettext('Related to: %(courseware_title_linked)s')), - {courseware_title_linked: courseware_title_linked}, - true - ) - %> - <% } %> -
      - <% if (obj.group_name && is_commentable_divided) { %> - <%- - interpolate( - gettext('This post is visible only to %(group_name)s.'), - {group_name: obj.group_name}, - true - ) - %> - <% } else { %> - <%- gettext('This post is visible to everyone.') %> - <% } %> -
      -
      -
      diff --git a/common/static/common/templates/discussion/thread-type.underscore b/common/static/common/templates/discussion/thread-type.underscore deleted file mode 100644 index b3c505859d..0000000000 --- a/common/static/common/templates/discussion/thread-type.underscore +++ /dev/null @@ -1,30 +0,0 @@ -
      -
      - - - <% // Translators: This is the label for a control to select a forum post type %> - <%- gettext("Post type") %> - - -
      - <%- gettext("Questions raise issues that need answers. Discussions share ideas and start conversations. (Required)") %> -
      -
      - - -
      -
      diff --git a/common/static/common/templates/discussion/thread.underscore b/common/static/common/templates/discussion/thread.underscore deleted file mode 100644 index 8205854fc8..0000000000 --- a/common/static/common/templates/discussion/thread.underscore +++ /dev/null @@ -1,38 +0,0 @@ -
      -
      -
      -
      -
      -
        -
        -
        -
        -
        - <% if (!readOnly) { %> -
        - -
        - <% } %> -
        -
        -
          -
          - - <% if (can_create_comment && !readOnly) { %> -
          - class="add-response"><%- gettext("Add a response:") %> > - -
            -
            -
            - -
            -
            - <% } %> -
            -
            -
            diff --git a/common/static/common/templates/discussion/topic.underscore b/common/static/common/templates/discussion/topic.underscore deleted file mode 100644 index 7a92973e6d..0000000000 --- a/common/static/common/templates/discussion/topic.underscore +++ /dev/null @@ -1,13 +0,0 @@ -
            - -
            - <%- gettext("Add your post to a relevant topic to help others find it. (Required)") %> -
            -
            -
            - -
            diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index d2eb94cd2b..1d43ba979b 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -10,51 +10,4 @@ window.ENABLE_DISCUSSION_HOME_PANEL = false; % endif - -<% -template_names = [ - 'thread', - 'thread-show', - 'thread-edit', - 'thread-response', - 'thread-response-show', - 'thread-response-edit', - 'response-comment-show', - 'response-comment-edit', - 'thread-list-item', - 'search-alert', - 'new-post', - 'new-post-menu-entry', - 'new-post-menu-category', - 'new-post-alert', - 'new-post-visibility', - 'topic', - 'post-user-display', - 'inline-discussion', - 'pagination', - 'profile-thread', - 'customwmd-prompt', - 'nav-loading', - 'thread-type' -] - -## same, but without trailing "-template" in script ID - these templates does not contain any free variables -template_names_no_suffix = [ - 'forum-action-endorse', 'forum-action-answer', 'forum-action-follow', 'forum-action-vote', 'forum-action-report', - 'forum-action-pin', 'forum-action-close', 'forum-action-edit', 'forum-action-delete', 'forum-actions', - 'alert-popup', 'nav-load-more-link' -] -%> - -% for template_name in template_names: - -% endfor - - -% for template_name in template_names_no_suffix: - -% endfor +<%static:include path="common/templates/discussion/templates.underscore" />