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
8473d6dc
Commit
8473d6dc
authored
Aug 19, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified mustache template working
parent
f4c3200b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
21 deletions
+52
-21
lms/djangoapps/django_comment_client/helpers.py
+16
-15
lms/djangoapps/django_comment_client/mustache_helpers.py
+28
-0
lms/templates/discussion/_content.mustache
+8
-6
No files found.
lms/djangoapps/django_comment_client/helpers.py
View file @
8473d6dc
from
django.core.urlresolvers
import
reverse
from
mitxmako.shortcuts
import
render_to_string
from
utils
import
render_mustache
from
utils
import
*
from
mustache_helpers
import
mustache_helpers
from
functools
import
partial
import
pystache_custom
as
pystache
import
urllib
def
pluralize
(
singular_term
,
count
):
...
...
@@ -14,20 +18,17 @@ def show_if(text, condition):
else
:
return
''
def
close_thread_text
(
content
):
if
content
.
get
(
'closed'
):
return
'Re-open thread'
else
:
return
'Close thread'
def
url_for_user
(
course_id
,
user_id
):
return
reverse
(
'django_comment_client.forum.views.user_profile'
,
args
=
[
course_id
,
user_id
])
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
):
def
render_content
(
content
,
additional_context
=
{}):
content_info
=
{
'displayed_title'
:
content
.
get
(
'highlighted_title'
)
or
content
.
get
(
'title'
,
''
),
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
}
context
=
{
'content'
:
content
,
'content'
:
merge_dict
(
content
,
content_info
),
content
[
'type'
]:
True
,
}
context
=
merge_dict
(
context
,
additional_context
)
partial_mustache_helpers
=
{
k
:
partial
(
v
,
content
)
for
k
,
v
in
mustache_helpers
.
items
()}
context
=
merge_dict
(
context
,
partial_mustache_helpers
)
return
render_mustache
(
'discussion/_content.mustache'
,
context
)
lms/djangoapps/django_comment_client/mustache_helpers.py
0 → 100644
View file @
8473d6dc
from
django.core.urlresolvers
import
reverse
import
urllib
def
pluralize
(
content
,
text
):
num
,
word
=
text
.
split
(
' '
)
if
int
(
num
or
'0'
)
>=
2
:
return
num
+
' '
+
word
+
's'
else
:
return
num
+
' '
+
word
def
url_for_user
(
content
,
user_id
):
return
reverse
(
'django_comment_client.forum.views.user_profile'
,
args
=
[
content
[
'course_id'
],
user_id
])
def
url_for_tags
(
content
,
tags
):
# assume that tags is in the format u'a, b, c'
return
reverse
(
'django_comment_client.forum.views.forum_form_discussion'
,
args
=
[
content
[
'course_id'
]])
+
'?'
+
urllib
.
urlencode
({
'tags'
:
tags
})
def
close_thread_text
(
content
):
if
content
.
get
(
'closed'
):
return
'Re-open thread'
else
:
return
'Close thread'
mustache_helpers
=
{
'pluralize'
:
pluralize
,
'url_for_tags'
:
url_for_tags
,
'url_for_user'
:
url_for_user
,
'close_thread_text'
:
close_thread_text
,
}
lms/templates/discussion/_content.mustache
View file @
8473d6dc
...
...
@@ -10,7 +10,9 @@
<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>
{{#
thread
}}
<li><a
href=
"javascript:void(0)"
class=
"admin-openclose"
>
{{
close_thread_text
}}
</a></li>
{{/
thread
}}
</ul>
{{#
thread
}}
<a
class=
"thread-title"
name=
"
{{
content
.
id
}}
"
href=
"javascript:void(0)"
>
{{{
content
.
displayed_title
}}}
</a>
...
...
@@ -18,12 +20,12 @@
{{/
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>
<div
class=
"content-body
{{
content
.
type
}}
-body"
id=
"content-body-
{{
content
.
id
}}
"
>
{{{
content
.
displayed_body
}}}
</div>
<div
class=
"content-raw-body
{{
content
.
type
}}
-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>
<a
class=
"thread-tag"
href=
"
{{#
#
url_for_tags
}}{{
.
}}{{/
url_for_tags
}}
"
>
{{
.
}}
</a>
{{/
content
.
tags
}}
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
{{
content
.
raw_tags
}}
</div>
...
...
@@ -35,7 +37,7 @@
anonymous
{{/
content
.
anonymous
}}
{{^
content
.
anonymous
}}
<a
href=
"
{{#
url_for_user
}}{{
content
.
user_id
}}{{/
url_for_user
}}
"
>
{{
content
.
username
}}
</a>
<a
href=
"
{{#
#
url_for_user
}}{{
content
.
user_id
}}{{/
url_for_user
}}
"
>
{{
content
.
username
}}
</a>
{{/
content
.
anonymous
}}
</div>
<div
class=
"comment-count"
>
...
...
@@ -44,7 +46,7 @@
<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>
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show
{{#
#
pluralize
}}{{
content
.
comments_count
}}
comment
{{/
pluralize
}}
</a>
{{/
partial_comments
}}
{{/
thread
}}
</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