diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js
index 9912dfd0f97..8c12943ee6e 100644
--- a/app/assets/javascripts/discourse/controllers/topic_controller.js
+++ b/app/assets/javascripts/discourse/controllers/topic_controller.js
@@ -216,10 +216,24 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
}) + "\n\n" + q);
});
});
- }
+ },
+ expandFirstPost: function(post) {
+ var self = this;
+ this.set('loadingExpanded', true);
+ post.expand().then(function() {
+ self.set('firstPostExpanded', true);
+ }).finally(function() {
+ self.set('loadingExpanded', false);
+ });
+ }
},
+ showExpandButton: function() {
+ var post = this.get('post');
+ return post.get('post_number') === 1 && post.get('topic.expandable_first_post');
+ }.property(),
+
slackRatio: function() {
return Discourse.Capabilities.currentProp('slackRatio');
}.property(),
diff --git a/app/assets/javascripts/discourse/models/post.js b/app/assets/javascripts/discourse/models/post.js
index a41377b15ca..08c626a67af 100644
--- a/app/assets/javascripts/discourse/models/post.js
+++ b/app/assets/javascripts/discourse/models/post.js
@@ -176,6 +176,17 @@ Discourse.Post = Discourse.Model.extend({
}
},
+ /**
+ Expands the first post's content, if embedded and shortened.
+
+ @method expandFirstPost
+ **/
+ expand: function() {
+ var self = this;
+ return Discourse.ajax("/posts/" + this.get('id') + "/expand-embed").then(function(result) {
+ self.set('cooked', result.cooked);
+ });
+ },
/**
Recover a deleted post
diff --git a/app/assets/javascripts/discourse/templates/post.js.handlebars b/app/assets/javascripts/discourse/templates/post.js.handlebars
index fca80bd430d..861e0184162 100644
--- a/app/assets/javascripts/discourse/templates/post.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/post.js.handlebars
@@ -74,6 +74,13 @@
{{/unless}}
{{{cooked}}}
+ {{#if view.showExpandButton}}
+ {{#if controller.loadingExpanded}}
+
+ {{else}}
+
+ {{/if}}
+ {{/if}}
{{view Discourse.PostMenuView postBinding="this" postViewBinding="view"}}
{{view Discourse.RepliesView content=replies postView=view}}
diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js
index b248619b87c..1cc74946f72 100644
--- a/app/assets/javascripts/discourse/views/post_view.js
+++ b/app/assets/javascripts/discourse/views/post_view.js
@@ -27,6 +27,13 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
}
}.property('post.primary_group_name'),
+ showExpandButton: function() {
+ if (this.get('controller.firstPostExpanded')) { return false; }
+
+ var post = this.get('post');
+ return post.get('post_number') === 1 && post.get('topic.expandable_first_post');
+ }.property('post.post_number', 'controller.firstPostExpanded'),
+
// If the cooked content changed, add the quote controls
cookedChanged: function() {
var self = this;
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 4cd3efea88d..1ed8b47041e 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -143,6 +143,10 @@ class PostsController < ApplicationController
render nothing: true
end
+ def expand_embed
+ render json: {cooked: "NEW COOKED CONTENT"}
+ end
+
def recover
post = find_post_from_params
guardian.ensure_can_recover_post!(post)
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 2f3731d00ce..2c779db59c7 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -891,6 +891,7 @@ en:
reply_as_new_topic: "Reply as new Topic"
continue_discussion: "Continuing the discussion from {{postLink}}:"
follow_quote: "go to the quoted post"
+ show_full: "Show Full Post"
deleted_by_author:
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)"
diff --git a/config/routes.rb b/config/routes.rb
index 6e28b6b5cf8..684080876ee 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -335,6 +335,7 @@ Discourse::Application.routes.draw do
post "t/:topic_id/notifications" => "topics#set_notifications" , constraints: {topic_id: /\d+/}
+ get "/posts/:id/expand-embed" => "posts#expand_embed"
get "raw/:topic_id(/:post_number)" => "posts#markdown"
resources :invites