mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FEATURE: Can click to expand hidden posts to see the good stuff!
This commit is contained in:
@ -294,6 +294,10 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
expandHidden: function(post) {
|
||||||
|
post.expandHidden();
|
||||||
|
},
|
||||||
|
|
||||||
toggleVisibility: function() {
|
toggleVisibility: function() {
|
||||||
this.get('content').toggleStatus('visible');
|
this.get('content').toggleStatus('visible');
|
||||||
},
|
},
|
||||||
|
@ -396,7 +396,17 @@ Discourse.Post = Discourse.Model.extend({
|
|||||||
var topic = this.get('topic');
|
var topic = this.get('topic');
|
||||||
return !topic.isReplyDirectlyBelow(this);
|
return !topic.isReplyDirectlyBelow(this);
|
||||||
|
|
||||||
}.property('reply_count')
|
}.property('reply_count'),
|
||||||
|
|
||||||
|
expandHidden: function() {
|
||||||
|
var self = this;
|
||||||
|
return Discourse.ajax("/posts/" + this.get('id') + "/cooked.json").then(function (result) {
|
||||||
|
self.setProperties({
|
||||||
|
cooked: result.cooked,
|
||||||
|
cooked_hidden: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Post.reopenClass({
|
Discourse.Post.reopenClass({
|
||||||
|
@ -63,7 +63,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div {{bind-attr class="showUserReplyTab:avoid-tab view.repliesShown::bottom-round :contents :regular view.extraClass"}}>
|
<div {{bind-attr class="showUserReplyTab:avoid-tab view.repliesShown::bottom-round :contents :regular view.extraClass"}}>
|
||||||
<div class='cooked'>{{{cooked}}}</div>
|
<div class='cooked'>
|
||||||
|
{{{cooked}}}
|
||||||
|
</div>
|
||||||
|
{{#if cooked_hidden}}
|
||||||
|
<a href {{action expandHidden this}}>{{i18n post.show_hidden}}</a>
|
||||||
|
{{/if}}
|
||||||
{{#if view.showExpandButton}}
|
{{#if view.showExpandButton}}
|
||||||
{{#if controller.loadingExpanded}}
|
{{#if controller.loadingExpanded}}
|
||||||
<button class="btn expand-post" disabled>{{i18n loading}}</button>
|
<button class="btn expand-post" disabled>{{i18n loading}}</button>
|
||||||
|
@ -5,7 +5,7 @@ require_dependency 'distributed_memoizer'
|
|||||||
class PostsController < ApplicationController
|
class PostsController < ApplicationController
|
||||||
|
|
||||||
# Need to be logged in for all actions here
|
# Need to be logged in for all actions here
|
||||||
before_filter :ensure_logged_in, except: [:show, :replies, :by_number, :short_link, :reply_history, :revisions, :expand_embed, :markdown]
|
before_filter :ensure_logged_in, except: [:show, :replies, :by_number, :short_link, :reply_history, :revisions, :expand_embed, :markdown, :raw, :cooked]
|
||||||
|
|
||||||
skip_before_filter :store_incoming_links, only: [:short_link]
|
skip_before_filter :store_incoming_links, only: [:short_link]
|
||||||
skip_before_filter :check_xhr, only: [:markdown,:short_link]
|
skip_before_filter :check_xhr, only: [:markdown,:short_link]
|
||||||
@ -19,6 +19,11 @@ class PostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cooked
|
||||||
|
post = find_post_from_params
|
||||||
|
render json: {cooked: post.cooked}
|
||||||
|
end
|
||||||
|
|
||||||
def short_link
|
def short_link
|
||||||
post = Post.find(params[:post_id].to_i)
|
post = Post.find(params[:post_id].to_i)
|
||||||
IncomingLink.add(request,current_user)
|
IncomingLink.add(request,current_user)
|
||||||
|
@ -6,7 +6,8 @@ class BasicPostSerializer < ApplicationSerializer
|
|||||||
:avatar_template,
|
:avatar_template,
|
||||||
:uploaded_avatar_id,
|
:uploaded_avatar_id,
|
||||||
:created_at,
|
:created_at,
|
||||||
:cooked
|
:cooked,
|
||||||
|
:cooked_hidden
|
||||||
|
|
||||||
def name
|
def name
|
||||||
object.user.try(:name)
|
object.user.try(:name)
|
||||||
@ -24,8 +25,15 @@ class BasicPostSerializer < ApplicationSerializer
|
|||||||
object.user.try(:uploaded_avatar_id)
|
object.user.try(:uploaded_avatar_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cooked_hidden
|
||||||
|
object.hidden && !scope.is_staff?
|
||||||
|
end
|
||||||
|
def include_cooked_hidden?
|
||||||
|
cooked_hidden
|
||||||
|
end
|
||||||
|
|
||||||
def cooked
|
def cooked
|
||||||
if object.hidden && !scope.is_staff?
|
if cooked_hidden
|
||||||
if scope.current_user && object.user_id == scope.current_user.id
|
if scope.current_user && object.user_id == scope.current_user.id
|
||||||
I18n.t('flagging.you_must_edit')
|
I18n.t('flagging.you_must_edit')
|
||||||
else
|
else
|
||||||
|
@ -953,6 +953,7 @@ en:
|
|||||||
continue_discussion: "Continuing the discussion from {{postLink}}:"
|
continue_discussion: "Continuing the discussion from {{postLink}}:"
|
||||||
follow_quote: "go to the quoted post"
|
follow_quote: "go to the quoted post"
|
||||||
show_full: "Show Full Post"
|
show_full: "Show Full Post"
|
||||||
|
show_hidden: 'View hidden content.'
|
||||||
deleted_by_author:
|
deleted_by_author:
|
||||||
one: "(post withdrawn by author, will be automatically deleted in %{count} hour unless flagged)"
|
one: "(post withdrawn by author, will be automatically deleted in %{count} hour unless flagged)"
|
||||||
other: "(post withdrawn by author, will be automatically deleted in %{count} hours unless flagged)"
|
other: "(post withdrawn by author, will be automatically deleted in %{count} hours unless flagged)"
|
||||||
|
@ -361,6 +361,7 @@ Discourse::Application.routes.draw do
|
|||||||
|
|
||||||
post "t/:topic_id/notifications" => "topics#set_notifications" , constraints: {topic_id: /\d+/}
|
post "t/:topic_id/notifications" => "topics#set_notifications" , constraints: {topic_id: /\d+/}
|
||||||
|
|
||||||
|
get "/posts/:id/cooked" => "posts#cooked"
|
||||||
get "/posts/:id/expand-embed" => "posts#expand_embed"
|
get "/posts/:id/expand-embed" => "posts#expand_embed"
|
||||||
get "raw/:topic_id(/:post_number)" => "posts#markdown"
|
get "raw/:topic_id(/:post_number)" => "posts#markdown"
|
||||||
|
|
||||||
|
@ -57,6 +57,21 @@ describe PostsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'cooked' do
|
||||||
|
before do
|
||||||
|
post = Post.new(cooked: 'wat')
|
||||||
|
PostsController.any_instance.expects(:find_post_from_params).returns(post)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the cooked conent' do
|
||||||
|
xhr :get, :cooked, id: 1234
|
||||||
|
response.should be_success
|
||||||
|
json = ::JSON.parse(response.body)
|
||||||
|
json.should be_present
|
||||||
|
json['cooked'].should == 'wat'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'show' do
|
describe 'show' do
|
||||||
include_examples 'finding and showing post' do
|
include_examples 'finding and showing post' do
|
||||||
let(:action) { :show }
|
let(:action) { :show }
|
||||||
|
Reference in New Issue
Block a user