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
9b26a209
Commit
9b26a209
authored
Aug 22, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed search highlighting
parent
6c3985fa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
9 deletions
+118
-9
lms/djangoapps/django_comment_client/forum/views.py
+2
-2
lms/djangoapps/django_comment_client/helpers.py
+1
-0
lms/lib/comment_client/thread.py
+1
-0
lms/static/coffee/src/backbone_discussion/content.coffee
+8
-3
lms/static/coffee/src/backbone_discussion/discussion.coffee
+102
-1
lms/static/coffee/src/backbone_discussion/utils.coffee
+2
-1
lms/templates/discussion/mustache/_content.mustache
+2
-2
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
9b26a209
...
...
@@ -13,7 +13,7 @@ from courseware.access import has_access
from
urllib
import
urlencode
from
operator
import
methodcaller
from
django_comment_client.permissions
import
check_permissions_by_view
from
django_comment_client.utils
import
merge_dict
,
extract
,
strip_none
from
django_comment_client.utils
import
merge_dict
,
extract
,
strip_none
,
strip_blank
import
json
import
django_comment_client.utils
as
utils
...
...
@@ -81,7 +81,7 @@ def render_discussion(request, course_id, threads, *args, **kwargs):
'pages_nearby_delta'
:
PAGES_NEARBY_DELTA
,
'discussion_type'
:
discussion_type
,
'base_url'
:
base_url
,
'query_params'
:
strip_
none
(
extract
(
query_params
,
[
'page'
,
'sort_key'
,
'sort_order'
,
'tags'
,
'text'
]
)),
'query_params'
:
strip_
blank
(
strip_none
(
extract
(
query_params
,
[
'page'
,
'sort_key'
,
'sort_order'
,
'tags'
,
'text'
])
)),
'annotated_content_info'
:
json
.
dumps
(
annotated_content_info
),
'discussion_data'
:
json
.
dumps
({
discussion_id
:
threads
}),
}
...
...
lms/djangoapps/django_comment_client/helpers.py
View file @
9b26a209
...
...
@@ -41,6 +41,7 @@ def render_content(content, additional_context={}):
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
}
print
content_info
if
content
[
'type'
]
==
'thread'
:
content_info
[
'permalink'
]
=
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'id'
]])
...
...
lms/lib/comment_client/thread.py
View file @
9b26a209
...
...
@@ -11,6 +11,7 @@ class Thread(models.Model):
'commentable_id'
,
'username'
,
'user_id'
,
'created_at'
,
'updated_at'
,
'comments_count'
,
'at_position_list'
,
'children'
,
'type'
,
'highlighted_title'
,
'highlighted_body'
,
]
updatable_fields
=
[
...
...
lms/static/coffee/src/backbone_discussion/content.coffee
View file @
9b26a209
...
...
@@ -120,7 +120,7 @@ class @ContentView extends Backbone.View
else
$elem
=
$
.
merge
@
$
(
".thread-title"
),
@
$showComments
()
url
=
@
model
.
urlFor
(
'retrieve'
)
DiscussionUtil
.
get
$elem
,
url
,
(
response
,
textStatus
)
=>
DiscussionUtil
.
get
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
showed
=
true
@
updateShowComments
()
@
$showComments
().
addClass
(
"retrieved"
)
...
...
@@ -183,8 +183,8 @@ class @ContentView extends Backbone.View
@
$el
.
children
(
".comments"
).
prepend
$comment
DiscussionUtil
.
setWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"reply-body"
,
""
comment
=
@
model
.
addComment
response
.
content
comment
.
updateInfo
response
.
annotated_content_info
commentView
=
new
CommentView
el
:
$comment
[
0
],
model
:
comment
comment
.
updateInfo
response
.
annotated_content_info
@
cancelReply
()
cancelReply
:
->
...
...
@@ -320,6 +320,11 @@ class @ContentView extends Backbone.View
@
$local
=
@
$el
.
children
(
".local"
)
@
$delegateElement
=
@
$local
initTitle
:
->
$contentTitle
=
@
$
(
".thread-title"
)
if
$contentTitle
.
length
$contentTitle
.
html
DiscussionUtil
.
unescapeHighlightTag
DiscussionUtil
.
stripLatexHighlight
$contentTitle
.
html
()
initBody
:
->
$contentBody
=
@
$
(
".content-body"
)
$contentBody
.
html
DiscussionUtil
.
postMathJaxProcessor
DiscussionUtil
.
markdownWithHighlight
$contentBody
.
html
()
...
...
@@ -344,8 +349,8 @@ class @ContentView extends Backbone.View
@
initBindings
()
@
initLocal
()
@
initTimeago
()
@
initTitle
()
@
initBody
()
#@initPermalink()
@
initCommentViews
()
class
@
Thread
extends
@
Content
...
...
lms/static/coffee/src/backbone_discussion/discussion.coffee
View file @
9b26a209
...
...
@@ -9,6 +9,12 @@ class @Discussion extends Backbone.Collection
find
:
(
id
)
->
_
.
first
@
where
(
id
:
id
)
addThread
:
(
thread
,
options
)
->
options
||=
{}
model
=
new
Thread
thread
@
add
model
model
class
@
DiscussionModuleView
extends
Backbone
.
View
class
@
DiscussionView
extends
Backbone
.
View
...
...
@@ -34,7 +40,7 @@ class @DiscussionView extends Backbone.View
reload
:
(
$elem
,
url
)
->
if
not
url
then
return
DiscussionUtil
.
get
$elem
,
url
,
(
response
,
textStatus
)
=>
DiscussionUtil
.
get
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
$discussion
=
$
(
response
.
html
)
$parent
=
@
$el
.
parent
()
@
$el
.
replaceWith
(
$discussion
)
...
...
@@ -42,9 +48,104 @@ class @DiscussionView extends Backbone.View
view
=
new
DiscussionView
el
:
$discussion
[
0
],
model
:
@
model
DiscussionUtil
.
bulkUpdateContentInfo
(
window
.
$
$annotated_content_info
)
loadSimilarPost
:
(
event
)
->
console
.
log
"loading"
$title
=
@
$
(
".new-post-title"
)
$wrapper
=
@
$
(
".new-post-similar-posts-wrapper"
)
$similarPosts
=
@
$
(
".new-post-similar-posts"
)
prevText
=
$title
.
attr
(
"prev-text"
)
text
=
$title
.
val
()
if
text
==
prevText
if
@
$
(
".similar-post"
).
length
$wrapper
.
show
()
else
if
$
.
trim
(
text
).
length
$elem
=
$
(
event
.
target
)
url
=
DiscussionUtil
.
urlFor
'search_similar_threads'
,
@
model
.
id
data
=
{
text
:
@
$
(
".new-post-title"
).
val
()
}
DiscussionUtil
.
get
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
console
.
log
response
$similarPosts
.
empty
()
if
$
.
type
(
response
)
==
"array"
and
response
.
length
$wrapper
.
show
()
for
thread
in
response
$similarPost
=
$
(
"<a>"
).
addClass
(
"similar-post"
)
.
html
(
thread
[
"title"
])
.
attr
(
"href"
,
"javascript:void(0)"
)
#TODO
.
appendTo
(
$similarPosts
)
else
$wrapper
.
hide
()
else
$wrapper
.
hide
()
$title
.
attr
(
"prev-text"
,
text
)
newPost
:
->
if
not
@
$
(
".wmd-panel"
).
length
view
=
{
discussion_id
:
@
model
.
id
}
@
$el
.
children
(
".discussion-non-content"
).
append
Mustache
.
render
DiscussionUtil
.
getTemplate
(
"_new_post"
),
view
$newPostBody
=
@
$
(
".new-post-body"
)
DiscussionUtil
.
makeWmdEditor
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
$input
=
DiscussionUtil
.
getWmdInput
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
$input
.
attr
(
"placeholder"
,
"post a new topic..."
)
if
@
$el
.
hasClass
(
"inline-discussion"
)
$input
.
bind
'focus'
,
(
e
)
=>
@
$
(
".new-post-form"
).
removeClass
(
'collapsed'
)
else
if
@
$el
.
hasClass
(
"forum-discussion"
)
@
$
(
".new-post-form"
).
removeClass
(
'collapsed'
)
@
$
(
".new-post-tags"
).
tagsInput
DiscussionUtil
.
tagsInputOptions
()
@
$
(
".new-post-title"
).
blur
$
.
proxy
(
@
loadSimilarPost
,
@
)
@
$
(
".hide-similar-posts"
).
click
=>
@
$
(
".new-post-similar-posts-wrapper"
).
hide
()
@
$
(
".discussion-submit-post"
).
click
$
.
proxy
(
@
submitNewPost
,
@
)
@
$
(
".discussion-cancel-post"
).
click
$
.
proxy
(
@
cancelNewPost
,
@
)
@
$
(
".new-post-form"
).
show
()
submitNewPost
:
(
event
)
->
title
=
@
$
(
".new-post-title"
).
val
()
body
=
DiscussionUtil
.
getWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
tags
=
@
$
(
".new-post-tags"
).
val
()
url
=
DiscussionUtil
.
urlFor
(
'create_thread'
,
@
model
.
id
)
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
url
:
url
type
:
"POST"
dataType
:
'json'
data
:
title
:
title
body
:
body
tags
:
tags
error
:
DiscussionUtil
.
formErrorHandler
(
@
$
(
".new-post-form-errors"
))
success
:
(
response
,
textStatus
)
=>
DiscussionUtil
.
clearFormErrors
(
@
$
(
".new-post-form-errors"
))
$thread
=
$
(
response
.
html
)
@
$el
.
children
(
".threads"
).
prepend
(
$thread
)
@
$
(
".new-post-title"
).
val
(
""
)
DiscussionUtil
.
setWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
,
""
@
$
(
".new-post-tags"
).
val
(
""
)
@
$
(
".new-post-tags"
).
importTags
(
""
)
thread
=
@
model
.
addThread
response
.
content
threadView
=
new
ThreadView
el
:
$thread
[
0
],
model
:
thread
thread
.
updateInfo
response
.
annotated_content_info
@
cancelNewPost
()
cancelNewPost
:
(
event
)
->
if
@
$el
.
hasClass
(
"inline-discussion"
)
@
$
(
".new-post-form"
).
addClass
(
"collapsed"
)
else
if
@
$el
.
hasClass
(
"forum-discussion"
)
@
$
(
".new-post-form"
).
hide
()
search
:
(
event
)
->
event
.
preventDefault
()
$elem
=
$
(
event
.
target
)
url
=
URI
(
$elem
.
attr
(
"action"
)).
addSearch
({
text
:
@
$
(
".search-input"
).
val
()})
@
reload
(
$elem
,
url
)
...
...
lms/static/coffee/src/backbone_discussion/utils.coffee
View file @
9b26a209
...
...
@@ -70,12 +70,13 @@ class @DiscussionUtil
$
.
ajax
(
params
).
always
->
$elem
.
removeAttr
(
"disabled"
)
@
get
:
(
$elem
,
url
,
success
)
->
@
get
:
(
$elem
,
url
,
data
,
success
)
->
@
safeAjax
$elem
:
$elem
url
:
url
type
:
"GET"
dataType
:
"json"
data
:
data
success
:
success
@
post
:
(
$elem
,
url
,
data
,
success
)
->
...
...
lms/templates/discussion/mustache/_content.mustache
View file @
9b26a209
...
...
@@ -15,12 +15,12 @@
{{/
thread
}}
</ul>
{{#
thread
}}
<a
class=
"thread-title"
name=
"
{{
content
.
id
}}
"
href=
"javascript:void(0)"
>
{{
{
content
.
displayed_title
}
}}
</a>
<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
.
type
}}
-body"
id=
"content-body-
{{
content
.
id
}}
"
>
{{
{
content
.
displayed_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"
>
...
...
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