Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
12d51334
Commit
12d51334
authored
Aug 19, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mustache template
parent
64e61605
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
70 deletions
+116
-70
lms/djangoapps/django_comment_client/helpers.py
+5
-1
lms/djangoapps/django_comment_client/utils.py
+9
-2
lms/static/coffee/src/discussion/content.coffee
+2
-2
lms/templates/discussion/_content.html
+40
-65
lms/templates/discussion/_content.mustache
+60
-0
No files found.
lms/djangoapps/django_comment_client/helpers.py
View file @
12d51334
from
django.core.urlresolvers
import
reverse
from
mitxmako.shortcuts
import
render_to_string
from
utils
import
render_mustache
import
urllib
def
pluralize
(
singular_term
,
count
):
...
...
@@ -26,4 +27,7 @@ def url_for_tags(course_id, tags):
return
reverse
(
'django_comment_client.forum.views.forum_form_discussion'
,
args
=
[
course_id
])
+
'?'
+
urllib
.
urlencode
({
'tags'
:
","
.
join
(
tags
)})
def
render_content
(
content
):
return
render_to_string
(
'discussion/_content.html'
,
{
'content'
:
content
})
context
=
{
'content'
:
content
,
}
return
render_mustache
(
'discussion/_content.mustache'
,
context
)
lms/djangoapps/django_comment_client/utils.py
View file @
12d51334
...
...
@@ -6,12 +6,15 @@ from xmodule.modulestore.django import modulestore
from
django.http
import
HttpResponse
from
django.utils
import
simplejson
from
django.db
import
connection
import
logging
from
django.conf
import
settings
from
django_comment_client.permissions
import
check_permissions_by_view
from
mitxmako
import
middleware
import
logging
import
operator
import
itertools
import
pystache
from
django_comment_client.permissions
import
check_permissions_by_view
_FULLMODULES
=
None
_DISCUSSIONINFO
=
None
...
...
@@ -175,3 +178,7 @@ def get_annotated_content_infos(course_id, thread, user):
_annotate
(
child
)
_annotate
(
thread
)
return
infos
def
render_mustache
(
template_name
,
dictionary
,
*
args
,
**
kwargs
):
template
=
middleware
.
lookup
[
'main'
]
.
get_template
(
template_name
)
.
source
return
pystache
.
render
(
template
,
dictionary
)
lms/static/coffee/src/discussion/content.coffee
View file @
12d51334
...
...
@@ -338,7 +338,7 @@ initializeFollowThread = (thread) ->
"click .admin-endorse"
:
->
handleEndorse
(
this
,
not
$content
.
hasClass
(
"endorsed"
))
"click .
discussio
n-openclose"
:
->
"click .
admi
n-openclose"
:
->
handleOpenClose
(
this
,
$
(
this
).
text
())
"click .admin-edit"
:
->
...
...
@@ -404,6 +404,6 @@ initializeFollowThread = (thread) ->
if
not
Discussion
.
getContentInfo
id
,
'can_delete'
$local
(
".admin-delete"
).
remove
()
if
not
Discussion
.
getContentInfo
id
,
'can_openclose'
$local
(
".
discussio
n-openclose"
).
remove
()
$local
(
".
admi
n-openclose"
).
remove
()
#if not Discussion.getContentInfo id, 'can_vote'
# $local(".discussion-vote").css "visibility", "hidden"
lms/templates/discussion/_content.html
View file @
12d51334
...
...
@@ -9,7 +9,11 @@
<div
class=
"discussion-content"
>
<div
class=
"discussion-content-wrapper"
>
${render_vote(content)}
<div
class=
"discussion-votes"
>
<a
class=
"discussion-vote discussion-vote-up"
href=
"javascript:void(0)"
>
▲
</a>
<div
class=
"discussion-votes-point"
>
${content['votes']['point']}
</div>
<a
class=
"discussion-vote discussion-vote-down"
href=
"javascript:void(0)"
>
▼
</a>
</div>
<div
class=
"discussion-right-wrapper"
>
<ul
class=
"admin-actions"
>
% if content['type'] == 'comment':
...
...
@@ -18,79 +22,50 @@
<li><a
href=
"javascript:void(0)"
class=
"admin-edit"
>
Edit
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-delete"
>
Delete
</a></li>
% if content['type'] == "thread":
<li><a
class=
"
discussion-openclose"
id=
"discussion-openclose-${content['id']}
"
href=
"javascript:void(0);"
>
${close_thread_text(content)}
</a></li>
<li><a
class=
"
admin-openclose
"
href=
"javascript:void(0);"
>
${close_thread_text(content)}
</a></li>
% endif
</ul>
% if content['type'] == "thread":
${render_title(content)}
<a
class=
"thread-title"
name=
"${content['id']}"
href=
"javascript:void(0)"
>
${(content.get('highlighted_title') or content['title']) | h}
</a>
<div
class=
"thread-raw-title"
style=
"display: none"
>
${content['title']}
</div>
% endif
<div
class=
"discussion-content-view"
>
<a
name=
"${content['id']}"
style=
"width: 0; height: 0; padding: 0; border: none;"
></a>
<div
class=
"content-body
${content['type']}-body"
id=
"content-body-${content['id']}
"
>
${(content.get('highlighted_body') or content['body']) | h}
</div>
<div
class=
"content-raw-body
${content['type']}-raw-body
"
style=
"display: none"
>
${content['body'] | h}
</div>
<div
class=
"content-body"
>
${(content.get('highlighted_body') or content['body']) | h}
</div>
<div
class=
"content-raw-body"
style=
"display: none"
>
${content['body'] | h}
</div>
% if content['type'] == "thread":
${render_tags(content)}
<div
class=
"thread-tags"
>
% for tag in content['tags']:
<a
class=
"thread-tag"
href=
"${url_for_tags(content['course_id'], [tag])}"
>
${tag | h}
</a>
% endfor
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
${",".join(content['tags']) | h}
</div>
% endif
${render_bottom_bar(content)}
<div
class=
"info"
>
<div
class=
"comment-time"
>
${time_ago_in_words(parse(content['updated_at']))} ago by
% if content['anonymous']:
anonymous
% else:
<a
href=
"${url_for_user(content['course_id'], content['user_id'])}"
>
${content['username']}
</a>
% endif
</div>
<div
class=
"comment-count"
>
% if content.get('comments_count', -1) >= 0:
% if discussion_type == 'user':
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments first-time"
>
Show all comments (${content['comments_count']} total)
</a>
% else:
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show ${content['comments_count']} ${pluralize('comment', content['comments_count'])}
</a>
% endif
% endif
</div>
<ul
class=
"discussion-actions"
>
<li><a
class=
"discussion-link discussion-reply discussion-reply-${content['type']}"
href=
"javascript:void(0)"
>
Reply
</a></li>
<li><div
class=
"follow-wrapper"
></div></li>
<li><a
class=
"discussion-link discussion-permanent-link"
href=
"javascript:void(0)"
>
Permanent Link
</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<
%
def
name=
"render_title(content)"
>
<a
class=
"thread-title"
name=
"${content['id']}"
href=
"javascript:void(0)"
>
${(content.get('highlighted_title') or content['title']) | h}
</a>
<div
class=
"thread-raw-title"
style=
"display: none"
>
${content['title']}
</div>
</
%
def>
<
%
def
name=
"render_tags(content)"
>
<div
class=
"thread-tags"
>
% for tag in content['tags']:
<a
class=
"thread-tag"
href=
"${url_for_tags(content['course_id'], [tag])}"
>
${tag | h}
</a>
% endfor
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
${",".join(content['tags']) | h}
</div>
</
%
def>
<
%
def
name=
"render_bottom_bar(content)"
>
<div
class=
"info"
>
${render_info(content)}
<ul
class=
"discussion-actions"
>
<li>
${render_link("discussion-link discussion-reply discussion-reply-" + content['type'], "Reply")}
</li>
<li><div
class=
"follow-wrapper"
></div></li>
<li>
${render_link("discussion-link discussion-permanent-link", "Permanent Link")}
</li>
</ul>
</div>
</
%
def>
<
%
def
name=
"render_info(content)"
>
<div
class=
"comment-time"
>
${time_ago_in_words(parse(content['updated_at']))} ago by
% if content['anonymous']:
anonymous
% else:
<a
href=
"${url_for_user(content['course_id'], content['user_id'])}"
>
${content['username']}
</a>
% endif
</div>
<div
class=
"comment-count"
>
% if content.get('comments_count', -1) >= 0:
% if discussion_type == 'user':
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments first-time"
>
Show all comments (${content['comments_count']} total)
</a>
% else:
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show ${content['comments_count']} ${pluralize('comment', content['comments_count'])}
</a>
% endif
% endif
</div>
</
%
def>
<
%
def
name=
"render_link(cls, html)"
>
<a
class=
"${cls}"
href=
"javascript:void(0)"
>
${html}
</a>
</
%
def>
<
%
def
name=
"render_vote(content)"
>
<div
class=
"discussion-votes"
>
${render_link("discussion-vote discussion-vote-up", "
▲
")}
<div
class=
"discussion-votes-point"
>
${content['votes']['point']}
</div>
${render_link("discussion-vote discussion-vote-down", "
▼
")}
</div>
</
%
def>
lms/templates/discussion/_content.mustache
0 → 100644
View file @
12d51334
<div
class=
"discussion-content"
>
<div
class=
"discussion-content-wrapper"
>
<div
class=
"discussion-votes"
>
<a
class=
"discussion-vote discussion-vote-up"
href=
"javascript:void(0)"
>
▲
</a>
<div
class=
"discussion-votes-point"
>
{{
content
.
votes
.
point
}}
</div>
<a
class=
"discussion-vote discussion-vote-down"
href=
"javascript:void(0)"
>
▼
</a>
</div>
<div
class=
"discussion-right-wrapper"
>
<ul
class=
"admin-actions"
>
<li><a
href=
"javascript:void(0)"
class=
"admin-endorse"
>
Endorse
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-edit"
>
Edit
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-delete"
>
Delete
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-openclose"
>
Close thread
</a></li>
</ul>
{{#
thread
}}
<a
class=
"thread-title"
name=
"
{{
content
.
id
}}
"
href=
"javascript:void(0)"
>
{{{
content
.
displayed_title
}}}
</a>
<div
class=
"thread-raw-title"
style=
"display: none"
>
{{{
content
.
title
}}}
</div>
{{/
thread
}}
<div
class=
"discussion-content-view"
>
<a
name=
"
{{
content
.
id
}}
"
style=
"width: 0; height: 0; padding: 0; border: none;"
></a>
<div
class=
"content-body"
>
{{{
content
.
displayed_body
}}}
</div>
<div
class=
"content-raw-body"
style=
"display: none"
>
{{{
content
.
body
}}}
</div>
{{#
thread
}}
<div
class=
"thread-tags"
>
{{#
content
.
tags
}}
<a
class=
"thread-tag"
href=
"
{{#
url_for_tags
}}{{
tag
}}{{/
url_for_tags
}}
"
>
{{
tag
}}
</a>
{{/
content
.
tags
}}
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
{{
content
.
raw_tags
}}
</div>
{{/
thread
}}
<div
class=
"info"
>
<div
class=
"comment-time"
>
<span
class=
"time-ago"
>
{{
content
.
updated_at
}}
</span>
ago by
{{#
content
.
anonymous
}}
anonymous
{{/
content
.
anonymous
}}
{{^
content
.
anonymous
}}
<a
href=
"
{{#
url_for_user
}}{{
content
.
user_id
}}{{/
url_for_user
}}
"
>
{{
content
.
username
}}
</a>
{{/
content
.
anonymous
}}
</div>
<div
class=
"comment-count"
>
{{#
thread
}}
{{#
partial_comments
}}
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments first-time"
>
Show all comments (
{{
content
.
comments_count
}}
total)
</a>
{{/
partial_comments
}}
{{^
partial_comments
}}
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show
{{#
pluralize
}}{{
content
.
comments_count
}}
comment}}
{{/
pluralize
}}
</a>
{{/
partial_comments
}}
{{/
thread
}}
</div>
<ul
class=
"discussion-actions"
>
<li><a
class=
"discussion-link discussion-reply discussion-reply-
{{
content
.
type
}}
"
href=
"javascript:void(0)"
>
Reply
</a></li>
<li><div
class=
"follow-wrapper"
></div></li>
<li><a
class=
"discussion-link discussion-permanent-link"
href=
"javascript:void(0)"
>
Permanent Link
</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment