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
fe45ae0c
Commit
fe45ae0c
authored
Aug 19, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
major refactor of templates
parent
df58ca2c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
109 additions
and
114 deletions
+109
-114
lms/djangoapps/django_comment_client/helpers.py
+29
-0
lms/djangoapps/django_comment_client/utils.py
+0
-6
lms/templates/discussion/_content.html
+48
-96
lms/templates/discussion/_content_renderer.html
+20
-0
lms/templates/discussion/_forum.html
+2
-2
lms/templates/discussion/_inline.html
+2
-2
lms/templates/discussion/ajax_create_comment.html
+2
-2
lms/templates/discussion/ajax_create_thread.html
+2
-2
lms/templates/discussion/ajax_update_comment.html
+2
-2
lms/templates/discussion/ajax_update_thread.html
+2
-2
No files found.
lms/djangoapps/django_comment_client/helpers.py
0 → 100644
View file @
fe45ae0c
from
django.core.urlresolvers
import
reverse
from
mitxmako.shortcuts
import
render_to_string
import
urllib
def
pluralize
(
singular_term
,
count
):
if
int
(
count
)
>=
2
:
return
singular_term
+
's'
return
singular_term
def
show_if
(
text
,
condition
):
if
condition
:
return
text
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
):
return
render_to_string
(
'discussion/_content.html'
,
{
'content'
:
content
})
lms/djangoapps/django_comment_client/utils.py
View file @
fe45ae0c
...
...
@@ -175,9 +175,3 @@ def get_annotated_content_infos(course_id, thread, user):
_annotate
(
child
)
_annotate
(
thread
)
return
infos
def
pluralize
(
singular_term
,
count
):
if
int
(
count
)
>=
2
:
return
singular_term
+
's'
return
singular_term
lms/templates/discussion/_
thread
.html
→
lms/templates/discussion/_
content
.html
View file @
fe45ae0c
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%!
from
django
_comment_client
.
helpers
import
url_for_tags
,
url_for_user
%
>
<
%!
from
datehelper
import
time_ago_in_words
%
>
<
%!
from
dateutil
.
parser
import
parse
%
>
<
%!
from
django_comment_client
.
utils
import
pluralize
%
>
<
%!
import
urllib
%
>
<
%!
def
show_if
(
text
,
condition
)
:
if
condition:
return
text
else:
return
''
%
>
<
%!
def
close_thread_text
(
content
)
:
if
content
.
get
('
closed
')
:
return
'
Re-open
thread
'
else:
return
'
Close
thread
'
<
%!
from
django_comment_client
.
helpers
import
close_thread_text
,
\
url_for_tags
,
\
url_for_user
,
\
pluralize
%
>
<
%
def
name=
"render_thread(course_id, thread, show_comments=False)"
>
<div
class=
"thread"
_id=
"${thread['id']}"
_discussion_id=
"${thread['commentable_id']}"
_author_id=
"${show_if(thread['user_id'], thread.get('anonymous'))}"
>
${render_content(thread, "thread", show_comments=show_comments)}
% if show_comments:
${render_comments(thread.get('children', []))}
% endif
</div>
</
%
def>
<
%
def
name=
"render_comment(comment)"
>
<div
class=
"comment ${show_if('endorsed', comment.get('endorsed'))}"
_id=
"${comment['id']}"
_author_id=
"${show_if(comment['user_id'], comment.get('anonymous'))}"
>
${render_content(comment, "comment")}
<div
class=
"comments"
>
${render_comments(comment.get('children', []))}
</div>
</div>
</
%
def>
<
%
def
name=
"render_comments(comments)"
>
<div
class=
"comments"
>
% for comment in comments:
${render_comment(comment)}
% endfor
</div>
</
%
def>
<
%
def
name=
"render_content(content, type, **kwargs)"
>
<div
class=
"discussion-content"
>
<div
class=
"discussion-content-wrapper"
>
${render_vote(content)}
<div
class=
"discussion-right-wrapper"
>
<ul
class=
"admin-actions"
>
% if type == 'comment':
<li><a
href=
"javascript:void(0)"
class=
"admin-endorse"
>
Endorse
</a></li>
% endif
<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 type == "thread":
<li><a
class=
"discussion-openclose"
id=
"discussion-openclose-${content['id']}"
href=
"javascript:void(0);"
>
${close_thread_text(content)}
</a></li>
% endif
</ul>
${render_title(content, type, **kwargs)}
<div
class=
"discussion-content-view"
>
<a
name=
"${content['id']}"
style=
"width: 0; height: 0; padding: 0; border: none;"
></a>
<div
class=
"content-body ${type}-body"
id=
"content-body-${content['id']}"
>
${(content.get('highlighted_body') or content['body']) | h}
</div>
<div
class=
"content-raw-body ${type}-raw-body"
style=
"display: none"
>
${content['body'] | h}
</div>
${render_tags(content, type, **kwargs)}
${render_bottom_bar(content, type, **kwargs)}
</div>
<div
class=
"discussion-content"
>
<div
class=
"discussion-content-wrapper"
>
${render_vote(content)}
<div
class=
"discussion-right-wrapper"
>
<ul
class=
"admin-actions"
>
% if content['type'] == 'comment':
<li><a
href=
"javascript:void(0)"
class=
"admin-endorse"
>
Endorse
</a></li>
% endif
<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>
% endif
</ul>
% if content['type'] == "thread":
${render_title(content)}
% 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>
% if content['type'] == "thread":
${render_tags(content)}
% endif
${render_bottom_bar(content)}
</div>
</div>
</div>
</
%
def
>
</
div
>
<
%
def
name=
"render_title(content, type, **kwargs)"
>
% if type == "thread":
<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
<
%
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, type, **kwargs)"
>
<
%
def
url_for_tags
(
tags
)
:
return
reverse
('
django_comment_client
.
forum
.
views
.
forum_form_discussion
',
args=
[course_id])
+
'?'
+
urllib
.
urlencode
({'
tags
'
:
",".
join
(
tags
)})
%
>
% if type == "thread":
<div
class=
"thread-tags"
>
% for tag in content['tags']:
<a
class=
"thread-tag"
href=
"${url_for_tags([tag])}"
>
${tag | h}
</a>
% endfor
</div>
<div
class=
"thread-raw-tags"
style=
"display: none"
>
${",".join(content['tags']) | h}
</div>
% endif
<
%
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
, type, **kwargs
)"
>
<div
class=
"info"
>
${render_info(content
, type, **kwargs
)}
<
%
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-" +
type
, "Reply")}
</li>
<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, type, **kwargs)"
>
<
%
def
url_for_user
(
user_id
)
:
return
reverse
('
django_comment_client
.
forum
.
views
.
user_profile
',
args=
[course_id,
user_id
])
%
>
<
%
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['user_id'])}"
>
${content['username']}
</a>
<a
href=
"${url_for_user(content['
course_id'], content['
user_id'])}"
>
${content['username']}
</a>
% endif
</div>
<div
class=
"comment-count"
>
...
...
lms/templates/discussion/_content_renderer.html
0 → 100644
View file @
fe45ae0c
<
%!
import
django_comment_client
.
helpers
as
helpers
%
>
<
%
def
name=
"render_content(content)"
>
${helpers.render_content(content)}
</
%
def>
<
%
def
name=
"render_content_with_comments(content)"
>
<div
class=
"${content['type']}"
_id=
"${content['id']}"
_discussion_id=
"${content.get('commentable_id')}"
_author_id=
"${helpers.show_if(content['user_id'], content.get('anonymous'))}"
>
${render_content(content)}
${render_comments(content.get('children', []))}
</div>
</
%
def>
<
%
def
name=
"render_comments(comments)"
>
<div
class=
"comments"
>
% for comment in comments:
${render_content_with_comments(comment)}
% endfor
</div>
</
%
def>
lms/templates/discussion/_forum.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
<section
class=
"discussion forum-discussion"
_id=
"${discussion_id}"
>
...
...
@@ -16,7 +16,7 @@
<
%
include
file=
"_sort.html"
/>
<div
class=
"threads"
>
% for thread in threads:
${renderer.render_
thread(course_id, thread, show_comments=False
)}
${renderer.render_
content_with_comments(thread
)}
% endfor
</div>
<
%
include
file=
"_paginator.html"
/>
...
...
lms/templates/discussion/_inline.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
<section
class=
"discussion inline-discussion"
_id=
"${discussion_id}"
>
...
...
@@ -6,7 +6,7 @@
<div
class=
"threads"
>
% for thread in threads:
${renderer.render_
thread(course_id, thread, show_comments=False
)}
${renderer.render_
content_with_comments(thread
)}
% endfor
</div>
...
...
lms/templates/discussion/ajax_create_comment.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
${renderer.render_co
mment
(content)}
${renderer.render_co
ntent_with_comments
(content)}
lms/templates/discussion/ajax_create_thread.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
${renderer.render_
thread(course_id,
content)}
${renderer.render_
content_with_comments(
content)}
lms/templates/discussion/ajax_update_comment.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
${renderer.render_content(content
, "comment"
)}
${renderer.render_content(content)}
lms/templates/discussion/ajax_update_thread.html
View file @
fe45ae0c
<
%
namespace
name=
"renderer"
file=
"_
thread
.html"
/>
<
%
namespace
name=
"renderer"
file=
"_
content_renderer
.html"
/>
${renderer.render_content(content
, "thread"
)}
${renderer.render_content(content)}
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