Commit 2ca51f06 by Arjun Singh

Merge branch 'feature/tomg/new-discussions' of github.com:MITx/mitx into…

Merge branch 'feature/tomg/new-discussions' of github.com:MITx/mitx into feature/tomg/new-discussions
parents 890c5e50 b2821c53
...@@ -30,7 +30,7 @@ def _general_discussion_id(course_id): ...@@ -30,7 +30,7 @@ def _general_discussion_id(course_id):
def _should_perform_search(request): def _should_perform_search(request):
return bool(request.GET.get('text', False) or \ return bool(request.GET.get('text', False) or \
request.GET.get('tags', False)) request.GET.get('tags', False))
def render_accordion(request, course, discussion_id): def render_accordion(request, course, discussion_id):
...@@ -59,7 +59,7 @@ def render_discussion(request, course_id, threads, *args, **kwargs): ...@@ -59,7 +59,7 @@ def render_discussion(request, course_id, threads, *args, **kwargs):
}[discussion_type] }[discussion_type]
base_url = { base_url = {
'inline': (lambda: reverse('django_comment_client.forum.views.inline_discussion', args=[course_id, discussion_id])), 'inline': (lambda: reverse('django_comment_client.forum.views.inline_discussion', args=[course_id, discussion_id])),
'forum': (lambda: reverse('django_comment_client.forum.views.forum_form_discussion', args=[course_id])), 'forum': (lambda: reverse('django_comment_client.forum.views.forum_form_discussion', args=[course_id])),
'user': (lambda: reverse('django_comment_client.forum.views.user_profile', args=[course_id, user_id])), 'user': (lambda: reverse('django_comment_client.forum.views.user_profile', args=[course_id, user_id])),
}[discussion_type]() }[discussion_type]()
...@@ -123,12 +123,14 @@ def get_threads(request, course_id, discussion_id=None): ...@@ -123,12 +123,14 @@ def get_threads(request, course_id, discussion_id=None):
# discussion per page is fixed for now # discussion per page is fixed for now
def inline_discussion(request, course_id, discussion_id): def inline_discussion(request, course_id, discussion_id):
threads, query_params = get_threads(request, course_id, discussion_id) threads, query_params = get_threads(request, course_id, discussion_id)
html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \ # TODO: Remove all of this stuff or switch back to server side rendering once templates are mustache again
query_params=query_params) # html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \
# query_params=query_params)
user_info = cc.User.from_django_user(request.user).to_dict()
return utils.JsonResponse({ return utils.JsonResponse({
'html': html, # 'html': html,
'discussion_data': map(utils.safe_content, threads), 'discussion_data': map(utils.safe_content, threads),
'user_info': user_info,
}) })
def render_search_bar(request, course_id, discussion_id=None, text=''): def render_search_bar(request, course_id, discussion_id=None, text=''):
...@@ -146,7 +148,14 @@ def forum_form_discussion(request, course_id): ...@@ -146,7 +148,14 @@ def forum_form_discussion(request, course_id):
category_map = utils.get_discussion_category_map(course) category_map = utils.get_discussion_category_map(course)
threads, query_params = get_threads(request, course_id) threads, query_params = get_threads(request, course_id)
content = render_forum_discussion(request, course_id, threads, discussion_id=_general_discussion_id(course_id), query_params=query_params) content = render_forum_discussion(request, course_id, threads, discussion_id=_general_discussion_id(course_id), query_params=query_params)
user_info = cc.User.from_django_user(request.user).to_dict() user_info = cc.User.from_django_user(request.user).to_dict()
def infogetter(thread):
return utils.get_annotated_content_infos(course_id, thread, request.user, user_info)
annotated_content_info = reduce(merge_dict, map(infogetter, threads), {})
if request.is_ajax(): if request.is_ajax():
return utils.JsonResponse({ return utils.JsonResponse({
'html': content, 'html': content,
...@@ -172,6 +181,7 @@ def forum_form_discussion(request, course_id): ...@@ -172,6 +181,7 @@ def forum_form_discussion(request, course_id):
'staff_access' : has_access(request.user, course, 'staff'), 'staff_access' : has_access(request.user, course, 'staff'),
'threads': saxutils.escape(json.dumps(threads),escapedict), 'threads': saxutils.escape(json.dumps(threads),escapedict),
'user_info': saxutils.escape(json.dumps(user_info),escapedict), 'user_info': saxutils.escape(json.dumps(user_info),escapedict),
'annotated_content_info': saxutils.escape(json.dumps(annotated_content_info),escapedict),
'course_id': course.id, 'course_id': course.id,
'category_map': category_map, 'category_map': category_map,
} }
...@@ -207,6 +217,7 @@ def single_thread(request, course_id, discussion_id, thread_id): ...@@ -207,6 +217,7 @@ def single_thread(request, course_id, discussion_id, thread_id):
thread = cc.Thread.find(thread_id).retrieve(recursive=True) thread = cc.Thread.find(thread_id).retrieve(recursive=True)
annotated_content_info = utils.get_annotated_content_infos(course_id, thread, request.user, user_info=user_info) annotated_content_info = utils.get_annotated_content_infos(course_id, thread, request.user, user_info=user_info)
context = {'thread': thread.to_dict(), 'course_id': course_id} context = {'thread': thread.to_dict(), 'course_id': course_id}
# TODO: Remove completely or switch back to server side rendering
html = render_to_string('discussion/_ajax_single_thread.html', context) html = render_to_string('discussion/_ajax_single_thread.html', context)
return utils.JsonResponse({ return utils.JsonResponse({
...@@ -232,12 +243,18 @@ def single_thread(request, course_id, discussion_id, thread_id): ...@@ -232,12 +243,18 @@ def single_thread(request, course_id, discussion_id, thread_id):
user_info = cc.User.from_django_user(request.user).to_dict() user_info = cc.User.from_django_user(request.user).to_dict()
escapedict = {'"': '"'} escapedict = {'"': '"'}
def infogetter(thread):
return utils.get_annotated_content_infos(course_id, thread, request.user, user_info)
annotated_content_info = reduce(merge_dict, map(infogetter, threads), {})
context = { context = {
'discussion_id': discussion_id, 'discussion_id': discussion_id,
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'init': '', 'init': '',
'user_info': saxutils.escape(json.dumps(user_info),escapedict), 'user_info': saxutils.escape(json.dumps(user_info),escapedict),
'content': render_single_thread(request, discussion_id, course_id, thread_id), 'annotated_content_info': saxutils.escape(json.dumps(annotated_content_info), escapedict),
'course': course, 'course': course,
'recent_active_threads': recent_active_threads, 'recent_active_threads': recent_active_threads,
'trending_tags': trending_tags, 'trending_tags': trending_tags,
...@@ -273,7 +290,7 @@ def user_profile(request, course_id, user_id): ...@@ -273,7 +290,7 @@ def user_profile(request, course_id, user_id):
}) })
else: else:
context = { context = {
'course': course, 'course': course,
'user': request.user, 'user': request.user,
'django_user': User.objects.get(id=user_id), 'django_user': User.objects.get(id=user_id),
'profiled_user': profiled_user.to_dict(), 'profiled_user': profiled_user.to_dict(),
......
if Backbone? if Backbone?
class @Content extends Backbone.Model class @Content extends Backbone.Model
@contents: {}
@contentInfos: {}
template: -> DiscussionUtil.getTemplate('_content') template: -> DiscussionUtil.getTemplate('_content')
actions: actions:
...@@ -13,15 +16,18 @@ if Backbone? ...@@ -13,15 +16,18 @@ if Backbone?
urlMappers: {} urlMappers: {}
urlFor: (name) -> urlFor: (name) ->
console.log @
@urlMappers[name].apply(@) @urlMappers[name].apply(@)
can: (action) -> can: (action) ->
DiscussionUtil.getContentInfo @id, action (@get('ability') || {})[action]
updateInfo: (info) -> updateInfo: (info) ->
@set('ability', info.ability) if info
@set('voted', info.voted) console.log info.ability
@set('subscribed', info.subscribed) @set('ability', info.ability)
@set('voted', info.voted)
@set('subscribed', info.subscribed)
addComment: (comment, options) -> addComment: (comment, options) ->
options ||= {} options ||= {}
...@@ -46,10 +52,24 @@ if Backbone? ...@@ -46,10 +52,24 @@ if Backbone?
@addComment comment, { silent: true } @addComment comment, { silent: true }
initialize: -> initialize: ->
DiscussionUtil.addContent @id, @ Content.addContent @id, @
if Content.getInfo(@id)
@updateInfo(Content.getInfo(@id))
@set 'user_url', DiscussionUtil.urlFor('user_profile', @get('user_id')) @set 'user_url', DiscussionUtil.urlFor('user_profile', @get('user_id'))
@resetComments(@get('children')) @resetComments(@get('children'))
@addContent: (id, content) -> @contents[id] = content
@getContent: (id) -> @contents[id]
@getInfo: (id) ->
@contentInfos[id]
@loadContentInfos: (infos) ->
for id, info of infos
if @getContent(id)
@getContent(id).updateInfo(info)
$.extend @contentInfos, infos
class @ContentView extends Backbone.View class @ContentView extends Backbone.View
...@@ -423,9 +443,11 @@ if Backbone? ...@@ -423,9 +443,11 @@ if Backbone?
super() super()
follow: -> follow: ->
@set('subscribed', true)
@trigger "thread:follow" @trigger "thread:follow"
unfollow: -> unfollow: ->
@set('subscribed', false)
@trigger "thread:unfollow" @trigger "thread:unfollow"
display_body: -> display_body: ->
......
...@@ -23,12 +23,17 @@ if Backbone? ...@@ -23,12 +23,17 @@ if Backbone?
type: "GET" type: "GET"
dataType: 'json' dataType: 'json'
success: (response, textStatus) => success: (response, textStatus) =>
@$el.append(response.html) #@$el.append(response.html)
$discussion = @$el.find("section.discussion") window.user = new DiscussionUser(response.user_info)
$(event.target).html("Hide Discussion") $(event.target).html("Hide Discussion")
discussion = new Discussion() discussion = new Discussion()
discussion.reset(response.discussion_data, {silent: false}) discussion.reset(response.discussion_data, {silent: false})
view = new DiscussionView(el: $discussion[0], model: discussion) $discussion = $(Mustache.render $("script#_inline_discussion").html(), {'threads':response.discussion_data})
$(".discussion-module").append($discussion)
discussion.each (thread) ->
element = $("article#thread_#{thread.id}")
dtv = new DiscussionThreadView el: element, model: thread
dtv.render()
DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info) DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info)
@retrieved = true @retrieved = true
@showed = true @showed = true
...@@ -6,7 +6,9 @@ DiscussionApp = ...@@ -6,7 +6,9 @@ DiscussionApp =
window.$$course_id = element.data("course-id") window.$$course_id = element.data("course-id")
user_info = element.data("user-info") user_info = element.data("user-info")
threads = element.data("threads") threads = element.data("threads")
content_info = element.data("content-info")
window.user = new DiscussionUser(user_info) window.user = new DiscussionUser(user_info)
Content.loadContentInfos(content_info)
discussion = new Discussion(threads) discussion = new Discussion(threads)
new DiscussionRouter({discussion: discussion}) new DiscussionRouter({discussion: discussion})
Backbone.history.start({pushState: true, root: "/courses/#{$$course_id}/discussion/forum/"}) Backbone.history.start({pushState: true, root: "/courses/#{$$course_id}/discussion/forum/"})
......
$ -> $ ->
if !window.$$contents
window.$$contents = {}
$.fn.extend $.fn.extend
loading: -> loading: ->
@$_loading = $("<span class='discussion-loading'></span>") @$_loading = $("<span class='discussion-loading'></span>")
......
class @DiscussionContentView extends Backbone.View
partialRenderer:
endorsed: (endorsed) ->
closed: (closed) -> # we should just re-render the whole thread, or update according to new abilities
voted: (voted) ->
if voted
@$(".discussion-vote").addClass("is-cast")
else
@$(".discussion-vote").removeClass("is-cast")
votes_point: (votes_point) ->
@$(".discussion-vote .votes-count-number").html(votes_point)
comments_count: (comments_count) ->
subscribed: (subscribed) ->
if subscribed
@$(".dogear").addClass("is-followed")
else
@$(".dogear").removeClass("is-followed")
ability: (ability) ->
console.log "ability changed"
for action, selector of @abilityRenderer
if not ability[action]
selector.disable.apply(@)
else
selector.enable.apply(@)
abilityRenderer:
editable:
enable: -> @$(".action-edit").closest("li").show()
disable: -> @$(".action-edit").closest("li").hide()
can_delete:
enable: -> @$(".action-delete").closest("li").show()
disable: -> @$(".action-delete").closest("li").hide()
can_endorse:
enable: -> @$(".action-endorse").css("cursor", "auto")
disable: -> @$(".action-endorse").css("cursor", "default")
renderPartial: ->
console.log "changed"
for attr, value of @model.changedAttributes()
if @partialRenderer[attr]
@partialRenderer[attr].apply(@, [value])
initialize: ->
@model.bind('change', @renderPartial, @)
class @DiscussionThreadView extends Backbone.View class @DiscussionThreadView extends DiscussionContentView
abilityRenderer:
editable:
enable: -> @$(".action-edit").closest("li").show()
disable: -> @$(".action-edit").closest("li").hide()
can_delete:
enable: -> @$(".action-delete").closest("li").show()
disable: -> @$(".action-delete").closest("li").hide()
can_endorse:
enable: ->
@$(".action-endorse").css("cursor", "auto")
disable: ->
@$(".action-endorse").css("cursor", "default")
events: events:
"click .discussion-vote": "toggleVote" "click .discussion-vote": "toggleVote"
"click .dogear": "toggleFollowing" "click .action-follow": "toggleFollowing"
"click .discussion-submit-post": "submitComment" "click .discussion-submit-post": "submitComment"
"click .action-edit": "edit"
"click .action-delete": "delete"
template: _.template($("#thread-template").html()) template: _.template($("#thread-template").html())
render: -> render: ->
...@@ -29,9 +46,10 @@ class @DiscussionThreadView extends Backbone.View ...@@ -29,9 +46,10 @@ class @DiscussionThreadView extends Backbone.View
renderResponses: -> renderResponses: ->
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
url: @model.id url: "/courses/#{$$course_id}/discussion/forum/#{@model.get('commentable_id')}/threads/#{@model.id}"
success: (data, textStatus, xhr) => success: (data, textStatus, xhr) =>
@$(".loading").remove() @$(".loading").remove()
Content.loadContentInfos(data['annotated_content_info'])
comments = new Comments(data['content']['children']) comments = new Comments(data['content']['children'])
comments.each @renderResponse comments.each @renderResponse
...@@ -44,19 +62,17 @@ class @DiscussionThreadView extends Backbone.View ...@@ -44,19 +62,17 @@ class @DiscussionThreadView extends Backbone.View
addComment: => addComment: =>
@model.trigger "comment:add" @model.trigger "comment:add"
toggleVote: -> toggleVote: (event) ->
@$(".discussion-vote").toggleClass("is-cast") event.preventDefault()
if @$(".discussion-vote").hasClass("is-cast") if not @model.get('voted')#@$(".discussion-vote").hasClass("is-cast")
@vote() @vote()
else else
@unvote() @unvote()
false
toggleFollowing: (event) -> toggleFollowing: (event) ->
$elem = $(event.target) $elem = $(event.target)
@$(".dogear").toggleClass("is-followed")
url = null url = null
if @$(".dogear").hasClass("is-followed") if not @model.get('subscribed')
@model.follow() @model.follow()
url = @model.urlFor("follow") url = @model.urlFor("follow")
else else
...@@ -69,7 +85,8 @@ class @DiscussionThreadView extends Backbone.View ...@@ -69,7 +85,8 @@ class @DiscussionThreadView extends Backbone.View
vote: -> vote: ->
url = @model.urlFor("upvote") url = @model.urlFor("upvote")
@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) + 1) @model.set('votes_point', parseInt(@model.get('votes_point')) + 1)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) + 1)
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
$elem: @$(".discussion-vote") $elem: @$(".discussion-vote")
url: url url: url
...@@ -80,7 +97,8 @@ class @DiscussionThreadView extends Backbone.View ...@@ -80,7 +97,8 @@ class @DiscussionThreadView extends Backbone.View
unvote: -> unvote: ->
url = @model.urlFor("unvote") url = @model.urlFor("unvote")
@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) - 1) @model.set('votes_point', parseInt(@model.get('votes_point')) - 1)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) - 1)
DiscussionUtil.safeAjax DiscussionUtil.safeAjax
$elem: @$(".discussion-vote") $elem: @$(".discussion-vote")
url: url url: url
...@@ -89,7 +107,8 @@ class @DiscussionThreadView extends Backbone.View ...@@ -89,7 +107,8 @@ class @DiscussionThreadView extends Backbone.View
if textStatus == 'success' if textStatus == 'success'
@model.set(response) @model.set(response)
submitComment: -> submitComment: (event) ->
event.preventDefault()
url = @model.urlFor('reply') url = @model.urlFor('reply')
body = @$("#wmd-input").val() body = @$("#wmd-input").val()
response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 }) response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 })
...@@ -103,4 +122,20 @@ class @DiscussionThreadView extends Backbone.View ...@@ -103,4 +122,20 @@ class @DiscussionThreadView extends Backbone.View
dataType: 'json' dataType: 'json'
data: data:
body: body body: body
false
edit: ->
delete: ->
toggleEndorse: ->
$elem = $(event.target)
url = @model.urlFor('endorse')
endorsed = @model.get('endorsed')
data = { endorsed: not endorsed }
DiscussionUtil.safeAjax
$elem: $elem
url: url
data: data
type: "POST"
success: (response, textStatus) =>
@model.set('endorsed', not endorsed)
class @ResponseCommentView extends Backbone.View class @ResponseCommentView extends DiscussionContentView
tagName: "li" tagName: "li"
template: _.template($("#response-comment-template").html()) template: _.template($("#response-comment-template").html())
render: -> render: ->
......
...@@ -13,9 +13,9 @@ class @ThreadListItemView extends Backbone.View ...@@ -13,9 +13,9 @@ class @ThreadListItemView extends Backbone.View
if window.user.following(@model) if window.user.following(@model)
@follow() @follow()
@ @
threadSelected: -> threadSelected: (event) ->
event.preventDefault()
@trigger("thread:selected", @model.id) @trigger("thread:selected", @model.id)
false
follow: => follow: =>
@$("a").addClass("followed") @$("a").addClass("followed")
......
class @ThreadResponseView extends Backbone.View class @ThreadResponseView extends DiscussionContentView
tagName: "li" tagName: "li"
template: _.template($("#thread-response-template").html()) template: _.template($("#thread-response-template").html())
events: events:
"click .vote-btn": "toggleVote" "click .vote-btn": "toggleVote"
"submit form": "submitComment" "submit form": "submitComment"
"click .action-endorse": "toggleEndorse"
render: -> render: ->
@$el.html(@template(@model.toJSON())) @$el.html(@template(@model.toJSON()))
...@@ -27,13 +29,13 @@ class @ThreadResponseView extends Backbone.View ...@@ -27,13 +29,13 @@ class @ThreadResponseView extends Backbone.View
view.render() view.render()
@$(".comments li:last").before(view.el) @$(".comments li:last").before(view.el)
toggleVote: -> toggleVote: (event) ->
event.preventDefault()
@$(".vote-btn").toggleClass("is-cast") @$(".vote-btn").toggleClass("is-cast")
if @$(".vote-btn").hasClass("is-cast") if @$(".vote-btn").hasClass("is-cast")
@vote() @vote()
else else
@unvote() @unvote()
false
vote: -> vote: ->
url = @model.urlFor("upvote") url = @model.urlFor("upvote")
...@@ -58,10 +60,11 @@ class @ThreadResponseView extends Backbone.View ...@@ -58,10 +60,11 @@ class @ThreadResponseView extends Backbone.View
@model.set(response) @model.set(response)
submitComment: (event) -> submitComment: (event) ->
event.preventDefault()
url = @model.urlFor('reply') url = @model.urlFor('reply')
body = @$(".comment-form-input").val() body = @$(".comment-form-input").val()
if not body.trim().length if not body.trim().length
return false return
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username")) comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"))
@renderComment(comment) @renderComment(comment)
@trigger "comment:add" @trigger "comment:add"
...@@ -74,5 +77,18 @@ class @ThreadResponseView extends Backbone.View ...@@ -74,5 +77,18 @@ class @ThreadResponseView extends Backbone.View
dataType: 'json' dataType: 'json'
data: data:
body: body body: body
false toggleEndorse: (event) ->
event.preventDefault()
if not @model.can('can_endorse')
return
$elem = $(event.target)
url = @model.urlFor('endorse')
endorsed = @model.get('endorsed')
data = { endorsed: not endorsed }
@model.set('endorsed', not endorsed)
DiscussionUtil.safeAjax
$elem: $elem
url: url
data: data
type: "POST"
...@@ -1261,12 +1261,16 @@ body.discussion { ...@@ -1261,12 +1261,16 @@ body.discussion {
} }
.moderator-actions { .moderator-actions {
margin: 0;
margin-top: 20px; margin-top: 20px;
padding: 0;
@include clearfix; @include clearfix;
li { li {
float: left; float: left;
margin-right: 8px; margin-right: 8px;
list-style: none;
} }
a { a {
...@@ -1401,13 +1405,6 @@ body.discussion { ...@@ -1401,13 +1405,6 @@ body.discussion {
.global-discussion-actions { .global-discussion-actions {
height: 60px; height: 60px;
@include linear-gradient(top, #ebebeb, #d9d9d9); @include linear-gradient(top, #ebebeb, #d9d9d9);
...@@ -1415,21 +1412,13 @@ body.discussion { ...@@ -1415,21 +1412,13 @@ body.discussion {
border-bottom: 1px solid #bcbcbc; border-bottom: 1px solid #bcbcbc;
} }
.discussion-module {
@extend .discussion-body
}
/* For some reason I have to do this to get the SCSS to compile, can't stick it under the above .discussion-module */
.discussion-module {
.discussion-reply-new {
display:none
}
}
<%include file="_underscore_templates.html" />
<div class="discussion-module"> <div class="discussion-module">
<a class="discussion-show control-button" href="javascript:void(0)" discussion_id="${discussion_id | h}">Show Discussion</a> <a class="discussion-show control-button" href="javascript:void(0)" discussion_id="${discussion_id | h}">Show Discussion</a>
</div> </div>
<script type="text/template" id="thread-template"> <script type="text/template" id="thread-template">
<article class="discussion-article" data-id="${'<%- id %>'}"> <article class="discussion-article" data-id="${'<%- id %>'}">
<a href="#" class="dogear"></a> <a href="javascript:void(0)" class="dogear action-follow"></a>
<div class="discussion-post"> <div class="discussion-post">
<header> <header>
<a href="#" class="vote-btn discussion-vote discussion-vote-up"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a> <a href="#" class="vote-btn discussion-vote discussion-vote-up"><span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}</span></a>
<h1>${'<%- title %>'}</h1> <h1>${'<%- title %>'}</h1>
<p class="posted-details"> <p class="posted-details">
<span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by
<a href="${'<%- user_url %>'}">${'<%- username %>'}</a> <a href="${'<%- user_url %>'}">${'<%- username %>'}</a>
</p> </p>
</header> </header>
<div class="post-body"> <div class="post-body">
${'<%- body %>'} ${'<%- body %>'}
</div> </div>
<div class="post-status">
${'<% if (closed) { %>'}
This thread is closed.
${'<% } %>'}
</div>
<ul class="moderator-actions">
<li style="display: none"><a class="action-edit" href="javascript:void(0)"><span class="edit-icon"></span> Edit</a></li>
<li style="display: none"><a class="action-delete" href="javascript:void(0)"><span class="delete-icon"></span> Delete</a></li>
</ul>
</div> </div>
<ol class="responses"> <ol class="responses">
<li class="loading"><div class="loading-animation"></div></li> <li class="loading"><div class="loading-animation"></div></li>
</ol> </ol>
<form class="discussion-reply-new"> <form class="discussion-reply-new" data-id="${'<%- id %>'}">
<h4>Post a response:</h4> <h4>Post a response:</h4>
<ul class="discussion-errors"></ul> <ul class="discussion-errors"></ul>
<div class="reply-body"></div> <div class="reply-body"></div>
...@@ -30,7 +39,8 @@ ...@@ -30,7 +39,8 @@
<script type="text/template" id="thread-response-template"> <script type="text/template" id="thread-response-template">
<header> <header>
<a href="#" class="vote-btn" data-tooltip="vote"><span class="plus-icon"></span><span class="votes-count-number">${"<%- votes['up_count'] %>"}</span></a> <a href="javascript:void(0)" class="vote-btn" data-tooltip="vote"><span class="plus-icon"></span><span class="votes-count-number">${"<%- votes['up_count'] %>"}</span></a>
<a href="javascript:void(0)" class="endorse-btn${'<% if (endorsed) { %> is-endorsed<% } %>'} action-endorse" style="cursor: default" data-tooltip="endorse"><span class="check-icon" style="pointer-events: none; "></span></a>
<a href="${'<%- user_url %>'}" class="posted-by">${"<%- username %>"}</a> <a href="${'<%- user_url %>'}" class="posted-by">${"<%- username %>"}</a>
<p class="posted-details" title="${'<%- created_at %>'}">Sometime</p> <p class="posted-details" title="${'<%- created_at %>'}">Sometime</p>
</header> </header>
...@@ -38,14 +48,14 @@ ...@@ -38,14 +48,14 @@
<ol class="comments"> <ol class="comments">
<li> <li>
<form class="comment-form"> <form class="comment-form">
<input type="text" placeholder="Comment" class="comment-form-input"> <input type="text" placeholder="Comment..." class="comment-form-input">
</form> </form>
</li> </li>
</ol> </ol>
</script> </script>
<script type="text/template" id="response-comment-template"> <script type="text/template" id="response-comment-template">
<p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p> <p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">--posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p>
</script> </script>
<script type="text/template" id="thread-list-item-template"> <script type="text/template" id="thread-list-item-template">
......
<section class="discussion">
{{#threads}}
<article class="discussion-article" data-id="{{id}}" id="thread_{{id}}">
</article>
{{/threads}}
</section>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<%include file="_new_post.html" /> <%include file="_new_post.html" />
<section class="discussion container" id="discussion-container" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}"> <section class="discussion container" id="discussion-container" data-course-id="${course_id}" data-user-info="${user_info}" data-threads="${threads}" data-content-info="${annotated_content_info}">
<div class="discussion-body"> <div class="discussion-body">
<div class="sidebar"></div> <div class="sidebar"></div>
<div class="discussion-column"></div> <div class="discussion-column"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment