Commit 1ad838ac by Rocky Duan

fix random js stuff; tag fields; override mathjax config for now

parent 0790a3ad
......@@ -19,6 +19,7 @@ class DiscussionModule(XModule):
'discussion_id': self.discussion_id,
'search_bar': '',
'user_info': comment_client.get_user_info(self.user_id, raw=True),
'tags': comment_client.get_threads_tags(raw=True),
'course_id': self.course_id,
}
return self.system.render_template('discussion/inline.html', context)
......
......@@ -32,6 +32,7 @@ def render_discussion(request, course_id, threads, discussion_id=None, search_te
'discussion_id': discussion_id,
'search_bar': render_search_bar(request, course_id, discussion_id, text=search_text),
'user_info': comment_client.get_user_info(request.user.id, raw=True),
'tags': comment_client.get_threads_tags(raw=True),
'course_id': course_id,
}
return render_to_string('discussion/inline.html', context)
......@@ -78,6 +79,7 @@ def render_single_thread(request, course_id, thread_id):
context = {
'thread': comment_client.get_thread(thread_id, recursive=True),
'user_info': comment_client.get_user_info(request.user.id, raw=True),
'tags': comment_client.get_threads_tags(raw=True),
'course_id': course_id,
}
return render_to_string('discussion/single_thread.html', context)
......@@ -91,7 +93,6 @@ def single_thread(request, course_id, thread_id):
'init': '',
'content': render_single_thread(request, course_id, thread_id),
'accordion': '',
'user_info': comment_client.get_user_info(request.user.id, raw=True),
'course': course,
}
......
......@@ -11,6 +11,9 @@ def delete_threads(commentable_id, *args, **kwargs):
def get_threads(commentable_id, recursive=False, *args, **kwargs):
return _perform_request('get', _url_for_threads(commentable_id), {'recursive': recursive}, *args, **kwargs)
def get_threads_tags(*args, **kwargs):
return _perform_request('get', _url_for_threads_tags(), {}, *args, **kwargs)
def create_thread(commentable_id, attributes, *args, **kwargs):
return _perform_request('post', _url_for_threads(commentable_id), attributes, *args, **kwargs)
......@@ -126,3 +129,6 @@ def _url_for_user(user_id):
def _url_for_search():
return "{prefix}/search".format(prefix=PREFIX)
def _url_for_threads_tags():
return "{prefix}/threads/tags".format(prefix=PREFIX)
......@@ -28,7 +28,28 @@
<%static:js group='courseware'/>
<%include file="mathjax_include.html" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [
["$","$"],
],
displayMath: [
["$$","$$"],
]
}
});
</script>
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates.
It can't be run through static.url because MathJax uses crazy url introspection to do lazy loading of
MathJax extension libraries -->
<script type="text/javascript" src="/static/js/vendor/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script>
<script type="text/javascript" src="${static.url('js/vendor/split.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/jquery.ajaxfileupload.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/Markdown.Converter.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/Markdown.Sanitizer.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/Markdown.Editor.js')}"></script>
<!-- TODO: http://docs.jquery.com/Plugins/Validation -->
<script type="text/javascript">
......
......@@ -8,10 +8,9 @@
${search_bar}
<form class="new-post-form" _id="${discussion_id}">
<input type="text" class="new-post-title" placeholder="Title"/>
<div class="new-post-body">
</div>
<div class="new-post-body"></div>
<input type="text" class="new-pot-tags" placeholder="tag1, tag2"/>
<a class="discussion-new-post" href="javascript:void(0)">New Post</a>
</form>
</div>
% for thread in threads:
......@@ -19,7 +18,13 @@
% endfor
</section>
<%!
def escape_quotes(text):
return text.replace('\"', '\\\"').replace("\'", "\\\'")
%>
<script type="text/javascript">
var $$user_info = JSON.parse('${user_info}');
var $$user_info = JSON.parse('${user_info | escape_quotes}');
var $$course_id = "${course_id}";
var $$tags = JSON.parse("${tags | escape_quotes}");
</script>
......@@ -5,7 +5,13 @@
${renderer.render_thread(course_id, thread, edit_thread=True, show_comments=True)}
</section>
<%!
def escape_quotes(text):
return text.replace('\"', '\\\"').replace("\'", "\\\'")
%>
<script type="text/javascript">
var $$user_info = JSON.parse('${user_info}');
var $$user_info = JSON.parse('${user_info | escape_quotes}');
var $$course_id = "${course_id}";
var $$tags = JSON.parse("${tags | escape_quotes}");
</script>
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