Commit 272c7b8b by Rocky Duan

Merge branch 'master' into merge

parents 547114a8 2685a3b6
...@@ -122,6 +122,18 @@ def forum_form_discussion(request, course_id, discussion_id): ...@@ -122,6 +122,18 @@ def forum_form_discussion(request, course_id, discussion_id):
content = render_forum_discussion(request, course_id, threads, discussion_id=discussion_id, \ content = render_forum_discussion(request, course_id, threads, discussion_id=discussion_id, \
query_params=query_params) query_params=query_params)
recent_active_threads = comment_client.search_recent_active_threads(
course_id,
recursive=False,
query_params={'follower_id': request.user.id,
'commentable_id': discussion_id},
)
trending_tags = comment_client.search_trending_tags(
course_id,
query_params={'commentable_id': discussion_id},
)
if request.is_ajax(): if request.is_ajax():
return utils.HtmlResponse(content) return utils.HtmlResponse(content)
else: else:
...@@ -130,6 +142,8 @@ def forum_form_discussion(request, course_id, discussion_id): ...@@ -130,6 +142,8 @@ def forum_form_discussion(request, course_id, discussion_id):
'course': course, 'course': course,
'content': content, 'content': content,
'accordion': render_accordion(request, course, discussion_id), 'accordion': render_accordion(request, course, discussion_id),
'recent_active_threads': recent_active_threads,
'trending_tags': trending_tags,
} }
return render_to_response('discussion/index.html', context) return render_to_response('discussion/index.html', context)
......
...@@ -34,6 +34,16 @@ def search_similar_threads(course_id, recursive=False, query_params={}, *args, * ...@@ -34,6 +34,16 @@ def search_similar_threads(course_id, recursive=False, query_params={}, *args, *
attributes = dict(default_params.items() + query_params.items()) attributes = dict(default_params.items() + query_params.items())
return _perform_request('get', _url_for_search_similar_threads(), attributes, *args, **kwargs) return _perform_request('get', _url_for_search_similar_threads(), attributes, *args, **kwargs)
def search_recent_active_threads(course_id, recursive=False, query_params={}, *args, **kwargs):
default_params = {'course_id': course_id, 'recursive': recursive}
attributes = dict(default_params.items() + query_params.items())
return _perform_request('get', _url_for_search_recent_active_threads(), attributes, *args, **kwargs)
def search_trending_tags(course_id, query_params={}, *args, **kwargs):
default_params = {'course_id': course_id}
attributes = dict(default_params.items() + query_params.items())
return _perform_request('get', _url_for_search_trending_tags(), attributes, *args, **kwargs)
def create_user(attributes, *args, **kwargs): def create_user(attributes, *args, **kwargs):
return _perform_request('post', _url_for_users(), attributes, *args, **kwargs) return _perform_request('post', _url_for_users(), attributes, *args, **kwargs)
...@@ -167,6 +177,12 @@ def _url_for_search_threads(): ...@@ -167,6 +177,12 @@ def _url_for_search_threads():
def _url_for_search_similar_threads(): def _url_for_search_similar_threads():
return "{prefix}/search/threads/more_like_this".format(prefix=PREFIX) return "{prefix}/search/threads/more_like_this".format(prefix=PREFIX)
def _url_for_search_recent_active_threads():
return "{prefix}/search/threads/recent_active".format(prefix=PREFIX)
def _url_for_search_trending_tags():
return "{prefix}/search/tags/trending".format(prefix=PREFIX)
def _url_for_threads_tags(): def _url_for_threads_tags():
return "{prefix}/threads/tags".format(prefix=PREFIX) return "{prefix}/threads/tags".format(prefix=PREFIX)
......
...@@ -62,6 +62,15 @@ initializeFollowDiscussion = (discussion) -> ...@@ -62,6 +62,15 @@ initializeFollowDiscussion = (discussion) ->
$local(".discussion-new-post").show() $local(".discussion-new-post").show()
handleSimilarPost = (elem) -> handleSimilarPost = (elem) ->
$title = $local(".new-post-title")
$wrapper = $local(".new-post-similar-posts-wrapper")
$similarPosts = $local(".new-post-similar-posts")
prevText = $title.attr("prev-text")
text = $title.val()
if text == prevText
if $local(".similar-post").length
$wrapper.show()
else if $.trim(text).length
Discussion.safeAjax Discussion.safeAjax
$elem: $(elem) $elem: $(elem)
url: Discussion.urlFor 'search_similar_threads', id url: Discussion.urlFor 'search_similar_threads', id
...@@ -70,8 +79,7 @@ initializeFollowDiscussion = (discussion) -> ...@@ -70,8 +79,7 @@ initializeFollowDiscussion = (discussion) ->
data: data:
text: $local(".new-post-title").val() text: $local(".new-post-title").val()
success: (response, textStatus) -> success: (response, textStatus) ->
$wrapper = $local(".new-post-similar-posts-wrapper") console.log "request"
$similarPosts = $local(".new-post-similar-posts")
$similarPosts.empty() $similarPosts.empty()
if $.type(response) == "array" and response.length if $.type(response) == "array" and response.length
$wrapper.show() $wrapper.show()
...@@ -83,6 +91,9 @@ initializeFollowDiscussion = (discussion) -> ...@@ -83,6 +91,9 @@ initializeFollowDiscussion = (discussion) ->
.appendTo($similarPosts) .appendTo($similarPosts)
else else
$wrapper.hide() $wrapper.hide()
else
$wrapper.hide()
$title.attr("prev-text", text)
handleNewPost = (elem) -> handleNewPost = (elem) ->
newPostForm = $local(".new-post-form") newPostForm = $local(".new-post-form")
...@@ -102,6 +113,9 @@ initializeFollowDiscussion = (discussion) -> ...@@ -102,6 +113,9 @@ initializeFollowDiscussion = (discussion) ->
$local(".new-post-title").blur -> $local(".new-post-title").blur ->
handleSimilarPost(this) handleSimilarPost(this)
$local(".hide-similar-posts").click ->
$local(".new-post-similar-posts-wrapper").hide()
$local(".discussion-submit-post").click -> $local(".discussion-submit-post").click ->
handleSubmitNewPost(this) handleSubmitNewPost(this)
$local(".discussion-cancel-post").click -> $local(".discussion-cancel-post").click ->
......
...@@ -8,10 +8,11 @@ Discussion = @Discussion ...@@ -8,10 +8,11 @@ Discussion = @Discussion
newPostTemplate: """ newPostTemplate: """
<form class="new-post-form" _id="{{discussion_id}}"> <form class="new-post-form" _id="{{discussion_id}}">
<ul class="discussion-errors"></ul> <ul class="discussion-errors new-post-form-error"></ul>
<input type="text" class="new-post-title title-input" placeholder="Title"/> <input type="text" class="new-post-title title-input" placeholder="Title"/>
<div class="new-post-similar-posts-wrapper" style="display: none"> <div class="new-post-similar-posts-wrapper" style="display: none">
Do you mean... Similar Posts:
<a class="hide-similar-posts" href="javascript:void(0)">Hide</a>
<div class="new-post-similar-posts"></div> <div class="new-post-similar-posts"></div>
</div> </div>
<div class="new-post-body body-input"></div> <div class="new-post-body body-input"></div>
......
...@@ -24,11 +24,28 @@ form label { ...@@ -24,11 +24,28 @@ form label {
text-shadow: none; text-shadow: none;
} }
div.recent-activity {
font-size: $comment_body_size;
margin: 4%;
font-weight: bold;
a.recent-active-post {
margin-bottom: 2px;
&:hover {
color: #1C71DD;
text-decoration: none;
font-weight: normal;
}
}
}
.discussion { .discussion {
.discussion-non-content { .discussion-non-content {
margin-left: flex-gutter(); margin-left: flex-gutter();
} }
//TITLE //TITLE
.discussion-title { .discussion-title {
@include discussion-font; @include discussion-font;
@include discussion-clickable; @include discussion-clickable;
...@@ -37,6 +54,7 @@ form label { ...@@ -37,6 +54,7 @@ form label {
font-weight: bold; font-weight: bold;
margin-bottom: flex-gutter(6); margin-bottom: flex-gutter(6);
} }
.discussion-title-wrapper { .discussion-title-wrapper {
.discussion-watch-discussion, .discussion-unwatch-discussion { .discussion-watch-discussion, .discussion-unwatch-discussion {
@include discussion-font; @include discussion-font;
...@@ -45,33 +63,46 @@ form label { ...@@ -45,33 +63,46 @@ form label {
margin-left: 5px; margin-left: 5px;
} }
} }
.blank {
margin: 2%;
}
//SORTING //SORTING
.discussion-sort { .discussion-sort {
float: right; float: right;
font-size: $comment_body_size; font-size: $comment_body_size;
margin-top: -2.5%; margin-top: -2.5%;
.discussion-sort-link { .discussion-sort-link {
&:hover { &:hover {
color: #1C71DD; color: #1C71DD;
text-decoration: none; text-decoration: none;
} }
} }
.discussion-sort-link.sorted { .discussion-sort-link.sorted {
color: #1C71DD; color: #1C71DD;
font-weight: bold; font-weight: bold;
} }
} }
//SEARCH //SEARCH
.search-wrapper-inline { .search-wrapper-inline {
display: inline-block; display: inline-block;
margin-bottom: 6%; margin-bottom: 6%;
margin-top: 3%; margin-top: 3%;
width: 80%; width: 80%;
} }
.discussion-search-form { .discussion-search-form {
display: inline-block; display: inline-block;
margin-bottom: 1%; margin-bottom: 1%;
width: flex-grid(12); width: flex-grid(12);
.discussion-link { .discussion-link {
@include button; @include button;
color: white; color: white;
...@@ -82,9 +113,11 @@ form label { ...@@ -82,9 +113,11 @@ form label {
padding-top: 9px; padding-top: 9px;
text-decoration: none; text-decoration: none;
} }
.discussion-search-text { .discussion-search-text {
@include discussion-font; @include discussion-font;
} }
.search-input { .search-input {
float: left; float: left;
font: inherit; font: inherit;
...@@ -92,16 +125,20 @@ form label { ...@@ -92,16 +125,20 @@ form label {
width: 72%; width: 72%;
} }
} }
.search-within { .search-within {
display: block; display: block;
margin-bottom: 3%; margin-bottom: 3%;
} }
.discussion-search-within-board { .discussion-search-within-board {
font: inherit; font: inherit;
font-size: $comment_body_size; font-size: $comment_body_size;
font-style: normal; font-style: normal;
} }
//BASIC BUTTON STYLES //BASIC BUTTON STYLES
.control-button { .control-button {
@include button; @include button;
@include discussion-font; @include discussion-font;
...@@ -125,6 +162,7 @@ form label { ...@@ -125,6 +162,7 @@ form label {
width: inherit; width: inherit;
text-decoration: none; text-decoration: none;
text-shadow: none; text-shadow: none;
&:hover { &:hover {
background-color: #A2A2A2; background-color: #A2A2A2;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #A2A2A2),color-stop(100%, #7B7B7B)); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #A2A2A2),color-stop(100%, #7B7B7B));
...@@ -139,9 +177,12 @@ form label { ...@@ -139,9 +177,12 @@ form label {
box-shadow: inset 0 1px 0 #BBB,0 0 3px #CCC; box-shadow: inset 0 1px 0 #BBB,0 0 3px #CCC;
} }
} }
//FOLLOW BUTTON //FOLLOW BUTTON
.follow-wrapper { .follow-wrapper {
float: right; float: right;
.discussion-link { .discussion-link {
@include button; @include button;
background-color: #BEBEBE; background-color: #BEBEBE;
...@@ -155,6 +196,7 @@ form label { ...@@ -155,6 +196,7 @@ form label {
padding: 5px 8px; padding: 5px 8px;
text-decoration: none; text-decoration: none;
text-shadow: none; text-shadow: none;
&:hover { &:hover {
background-color: #AAA; background-color: #AAA;
background-image: none; background-image: none;
...@@ -165,63 +207,87 @@ form label { ...@@ -165,63 +207,87 @@ form label {
} }
} }
} }
//VOTES //VOTES
.discussion-votes { .discussion-votes {
float: left; float: left;
height: flex-grid(3); height: flex-grid(3);
margin: 1% 2%; margin: 1% 2%;
text-align: center; text-align: center;
.discussion-vote-count { .discussion-vote-count {
@include discussion-font; @include discussion-font;
font-size: $comment_body_size; font-size: $comment_body_size;
} }
a.discussion-vote { a.discussion-vote {
color: black; color: black;
display: block; display: block;
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
&:hover { &:hover {
color: #1C71DD; color: #1C71DD;
text-decoration: none; text-decoration: none;
} }
&.discussion-vote-up { &.discussion-vote-up {
margin-bottom: 3px; margin-bottom: 3px;
} }
&.discussion-vote-down { &.discussion-vote-down {
margin-top: 5px; margin-top: 5px;
} }
&.voted { &.voted {
color: #1C71DD; color: #1C71DD;
} }
} }
} }
//CREATE NEW AND EDIT POSTS //CREATE NEW AND EDIT POSTS
.discussion-right-wrapper { .discussion-right-wrapper {
float: left; float: left;
min-height: 40px; min-height: 40px;
width: 90%; width: 90%;
} }
.new-post-form, .discussion-thread-edit { .new-post-form, .discussion-thread-edit {
.title-input, .body-input { .title-input, .body-input {
display: block !important; display: block !important;
font: inherit; font: inherit;
font-style: normal; font-style: normal;
width: $discussion_input_width !important; width: $discussion_input_width !important;
} }
.discussion-errors {
color: #8F0E0E; .new-post-similar-posts-wrapper {
display: block; @include border-radius(3px);
margin-left: -5%; border: 1px solid #EEE;
font-size: $comment_body_size;
line-height: 150%;
margin-top: 1%;
padding: 1% 1.5%;
} }
.hide-similar-posts {
float: right;
}
.new-post-similar-posts { .new-post-similar-posts {
font: inherit;
.similar-post { .similar-post {
display: block; display: block;
line-height: 150%;
} }
} }
.new-post-body { .new-post-body {
margin-top: flex-gutter(); margin-top: flex-gutter();
} }
.tagsinput { .tagsinput {
background: #FAFAFA; background: #FAFAFA;
border: 1px solid #C8C8C8; border: 1px solid #C8C8C8;
...@@ -241,19 +307,39 @@ form label { ...@@ -241,19 +307,39 @@ form label {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
} }
.discussion-content-edit, .discussion-reply-new, .new-post-form { .discussion-content-edit, .discussion-reply-new, .new-post-form {
margin: 10px 0 10px 0; margin: 10px 0 10px 0;
.discussion-errors {
color: #8F0E0E;
display: block;
font: inherit;
font-size: $comment_body_size;
list-style: none;
margin-left: -3%;
padding-left: 2em;
}
a:hover {
color: #1C71DD;
text-decoration: none;
};
.new-post-control { .new-post-control {
margin-left: 80%; margin-left: 80%;
margin-top: 1%; margin-top: 1%;
} }
.reply-post-control { .reply-post-control {
margin-left: 73%; margin-left: 73%;
} }
.edit-post-control { .edit-post-control {
margin-left: 79%; margin-left: 79%;
margin-top: 1%; margin-top: 1%;
} }
.control-button { .control-button {
@include button; @include button;
@include discussion-font; @include discussion-font;
...@@ -265,24 +351,35 @@ form label { ...@@ -265,24 +351,35 @@ form label {
padding-top: 9px; padding-top: 9px;
text-decoration: none; text-decoration: none;
width: inherit; width: inherit;
&:hover {
color: white;
} }
} }
}
.new-post-form { .new-post-form {
margin: 10px 0 40px 0; margin: 10px 0 40px 0;
} }
.discussion-reply-new { .discussion-reply-new {
.discussion-auto-watch { .discussion-auto-watch {
margin-left: 2%; margin-left: 2%;
} }
} }
//THREAD STYLES //THREAD STYLES
.thread { .thread {
//display: none; //display: none;
.search-highlight { .search-highlight {
display: inline; display: inline;
font-weight: bold; font-weight: bold;
background-color: lightyellow; background-color: lightyellow;
} }
.thread-title { .thread-title {
@include discussion-font; @include discussion-font;
@include discussion-clickable; @include discussion-clickable;
...@@ -290,18 +387,23 @@ form label { ...@@ -290,18 +387,23 @@ form label {
font-size: $comment_title_size; font-size: $comment_title_size;
font-weight: bold; font-weight: bold;
} }
.thread-body, .content-body { .thread-body, .content-body {
@include discussion-font; @include discussion-font;
font-size: $comment_body_size; font-size: $comment_body_size;
margin-bottom: 4px; margin-bottom: 4px;
margin-top: 3px; margin-top: 3px;
min-height: 35px;
p { p {
@include discussion-font; @include discussion-font;
margin: 0; margin: 0;
} }
} }
.thread-tags { .thread-tags {
display: inline-block; display: inline-block;
.thread-tag { .thread-tag {
@include discussion-font; @include discussion-font;
background: #CDE69C; background: #CDE69C;
...@@ -314,43 +416,65 @@ form label { ...@@ -314,43 +416,65 @@ form label {
margin: 5px 7px 5px 0; margin: 5px 7px 5px 0;
padding: 5px 7px; padding: 5px 7px;
text-decoration: none; text-decoration: none;
&:hover { &:hover {
border-color: #1E4612; border-color: #1E4612;
color: #1E4612; color: #1E4612;
} }
} }
} }
.info { .info {
@include discussion-font; @include discussion-font;
color: gray; color: gray;
font-size: $comment_info_size; font-size: $comment_info_size;
font-style: italic; font-style: italic;
margin-top: 2%; margin-top: 2%;
a {
&:hover {
text-decoration: none;
color: #1C71DD;
}
}
.comment-time { .comment-time {
display: inline; display: inline;
float: right; float: right;
margin-right: -4%; margin-right: -4%;
} }
.comment-count { .comment-count {
display: inline; display: inline;
} }
.discussion-reply { .discussion-reply {
margin-left: 4px; margin-left: 4px;
} }
.discussion-link { .discussion-link {
@include discussion-font; @include discussion-font;
color: #1d9dd9; color: #1d9dd9;
display: inline; display: inline;
margin-left: 2px; margin-left: 2px;
&:hover {
text-decoration: none;
color: #1C71DD;
} }
} }
}
.discussion-content { .discussion-content {
border-top: lightgray 1px solid; border-top: lightgray 1px solid;
overflow: hidden; overflow: hidden;
padding: 1.5% 0; padding: 1.5% 0;
.discussion-reply-new { .discussion-reply-new {
@include discussion-font; @include discussion-font;
margin-left: 5%; margin-left: 5%;
.reply-body { .reply-body {
@include discussion-font; @include discussion-font;
display: block; display: block;
...@@ -360,12 +484,16 @@ form label { ...@@ -360,12 +484,16 @@ form label {
} }
} }
} }
//COMMENT STYLES //COMMENT STYLES
.comments { .comments {
//display: none; //display: none;
margin-left: $comment_margin_left; margin-left: $comment_margin_left;
overflow: hidden; overflow: hidden;
.comment { .comment {
.comment-body, .content-body { .comment-body, .content-body {
@include discussion-font; @include discussion-font;
color: black; color: black;
...@@ -373,7 +501,9 @@ form label { ...@@ -373,7 +501,9 @@ form label {
font-size: $comment_body_size; font-size: $comment_body_size;
margin-top: 3px; margin-top: 3px;
} }
&.endorsed { &.endorsed {
> .discussion-content { > .discussion-content {
background-color: lightyellow; background-color: lightyellow;
} }
...@@ -381,16 +511,20 @@ form label { ...@@ -381,16 +511,20 @@ form label {
} }
} }
} }
//PAGES //PAGES
.discussion-paginator { .discussion-paginator {
font-size: $comment_body_size; font-size: $comment_body_size;
margin-bottom: 10px; margin-bottom: 10px;
margin-top: 20px; margin-top: 20px;
text-align: center; text-align: center;
div { div {
display: inline-block; display: inline-block;
font-weight: bold; font-weight: bold;
margin: 0 5px; margin: 0 5px;
a { a {
background: #EEE; background: #EEE;
-webkit-border-radius: 3px; -webkit-border-radius: 3px;
...@@ -402,6 +536,7 @@ form label { ...@@ -402,6 +536,7 @@ form label {
font-weight: normal; font-weight: normal;
padding: 4px 10px; padding: 4px 10px;
text-decoration: none; text-decoration: none;
&:hover { &:hover {
background: #DDD; background: #DDD;
} }
......
...@@ -87,6 +87,11 @@ div.course-wrapper { ...@@ -87,6 +87,11 @@ div.course-wrapper {
ul { ul {
list-style: disc outside none; list-style: disc outside none;
padding-left: 1em; padding-left: 1em;
&.discussion-errors {
list-style: none;
padding-left: 2em;
}
} }
nav.sequence-bottom { nav.sequence-bottom {
......
<div class="blank-state"> <div class="blank-state">
% if performed_search: % if performed_search:
There is no result matching your search parameters. Sorry! We can't find anything matching your search. Please try another search.
% else: % else:
There is no post here yet. Be the first one to post! There are no posts here yet. Be the first one to post!
% endif % endif
</div> </div>
...@@ -14,18 +14,20 @@ ...@@ -14,18 +14,20 @@
</div> </div>
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div> <div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
</div> </div>
<%include file="_sort.html" />
% if len(threads) == 0: % if len(threads) == 0:
<div class="blank">
<%include file="_blank_slate.html" /> <%include file="_blank_slate.html" />
</div>
<div class="threads"></div> <div class="threads"></div>
% else: % else:
<%include file="_sort.html" />
<div class="threads"> <div class="threads">
% for thread in threads: % for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)} ${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor % endfor
</div> </div>
% endif
<%include file="_paginator.html" /> <%include file="_paginator.html" />
% endif
</section> </section>
<%! <%!
......
...@@ -6,19 +6,21 @@ ...@@ -6,19 +6,21 @@
<%include file="_search_bar.html" /> <%include file="_search_bar.html" />
</div> </div>
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div> <div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
<%include file="_sort.html" />
</div> </div>
% if len(threads) == 0: % if len(threads) == 0:
<div class="blank">
<%include file="_blank_slate.html" /> <%include file="_blank_slate.html" />
</div>
<div class="threads"></div> <div class="threads"></div>
% else: % else:
<%include file="_sort.html" />
<div class="threads"> <div class="threads">
% for thread in threads: % for thread in threads:
${renderer.render_thread(course_id, thread, show_comments=False)} ${renderer.render_thread(course_id, thread, show_comments=False)}
% endfor % endfor
</div> </div>
% endif
<%include file="_paginator.html" /> <%include file="_paginator.html" />
% endif
</section> </section>
<%! <%!
......
<div class="recent-activity">
Recent Activity:
<div class="recent-active-posts">
% for thread in recent_active_threads:
<a class="recent-active-post" href="javascript:void(0)">${thread['title']}</a>
% endfor
</div>
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
% if content['anonymous']: % if content['anonymous']:
anonymous anonymous
% else: % else:
user No.${content['user_id']} ${content['username']} <!---# TODO add link to user-->
% endif % endif
</div> </div>
<div class="comment-count"> <div class="comment-count">
......
Trending tags:
<div class="trending-tags">
% for tag, count in trending_tags:
<div class="trending-tag">
<a class="trending-tag-link" href="javascript:void(0)">${tag}</a>
&times;
<span class="trending-tag-count">${count}</span>
</div>
% endfor
</div>
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
${accordion} ${accordion}
</nav> </nav>
</div> </div>
<%include file="_recent_active_posts.html" />
<%include file="_trending_tags.html" />
</section> </section>
<section class="course-content"> <section class="course-content">
......
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