Support for a `/last` route to go to the last post in a topic.
This commit is contained in:
parent
5d865f0a1d
commit
f5019be477
|
@ -69,8 +69,12 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
urlForPostNumber: function(postNumber) {
|
||||
var url = this.get('url');
|
||||
if (postNumber && (postNumber > 1)) {
|
||||
if (postNumber >= this.get('highest_post_number')) {
|
||||
url += "/last";
|
||||
} else {
|
||||
url += "/" + postNumber;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
|||
var topicController = this.controllerFor('topic'),
|
||||
composerController = this.controllerFor('composer');
|
||||
|
||||
// I sincerely hope no topic gets this many posts
|
||||
if (params.nearPost === "last") { params.nearPost = 999999999; }
|
||||
|
||||
postStream.refresh(params).then(function () {
|
||||
// The post we requested might not exist. Let's find the closest post
|
||||
var closest = postStream.closestPostNumberFor(params.nearPost) || 1;
|
||||
|
|
|
@ -271,9 +271,11 @@ Discourse::Application.routes.draw do
|
|||
put "t/:topic_id/remove-allowed-user" => "topics#remove_allowed_user", constraints: {topic_id: /\d+/}
|
||||
put "t/:topic_id/recover" => "topics#recover", constraints: {topic_id: /\d+/}
|
||||
get "t/:topic_id/:post_number" => "topics#show", constraints: {topic_id: /\d+/, post_number: /\d+/}
|
||||
get "t/:topic_id/last" => "topics#show", post_number: 99999999, constraints: {topic_id: /\d+/}
|
||||
get "t/:slug/:topic_id.rss" => "topics#feed", format: :rss, constraints: {topic_id: /\d+/}
|
||||
get "t/:slug/:topic_id" => "topics#show", constraints: {topic_id: /\d+/}
|
||||
get "t/:slug/:topic_id/:post_number" => "topics#show", constraints: {topic_id: /\d+/, post_number: /\d+/}
|
||||
get "t/:slug/:topic_id/last" => "topics#show", post_number: 99999999, constraints: {topic_id: /\d+/}
|
||||
get "t/:topic_id/posts" => "topics#posts", constraints: {topic_id: /\d+/}
|
||||
post "t/:topic_id/timings" => "topics#timings", constraints: {topic_id: /\d+/}
|
||||
post "t/:topic_id/invite" => "topics#invite", constraints: {topic_id: /\d+/}
|
||||
|
|
Loading…
Reference in New Issue