route for markdown /md/topic_id/post_number
This commit is contained in:
parent
b7fc8ac33c
commit
cef9a74053
|
@ -67,6 +67,8 @@ class ApplicationController < ActionController::Base
|
|||
rescue_from Discourse::NotFound do
|
||||
if !request.format || request.format.html?
|
||||
# for now do a simple remap, we may look at cleaner ways of doing the render
|
||||
#
|
||||
# Sam: I am confused about this, we need a comment that explains why this is conditional
|
||||
raise ActiveRecord::RecordNotFound
|
||||
else
|
||||
render file: 'public/404', formats: [:html], layout: false, status: 404
|
||||
|
|
|
@ -7,7 +7,16 @@ class PostsController < ApplicationController
|
|||
before_filter :ensure_logged_in, except: [:show, :replies, :by_number, :short_link]
|
||||
|
||||
skip_before_filter :store_incoming_links, only: [:short_link]
|
||||
skip_before_filter :check_xhr, only: [:short_link]
|
||||
skip_before_filter :check_xhr, only: [:markdown,:short_link]
|
||||
|
||||
def markdown
|
||||
post = Post.where(topic_id: params[:topic_id].to_i, post_number: (params[:post_number] || 1).to_i).first
|
||||
if post && guardian.can_see?(post)
|
||||
render text: post.raw, content_type: 'text/plain'
|
||||
else
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
end
|
||||
|
||||
def short_link
|
||||
post = Post.find(params[:post_id].to_i)
|
||||
|
|
|
@ -205,6 +205,8 @@ Discourse::Application.routes.draw do
|
|||
|
||||
post 't/:topic_id/notifications' => 'topics#set_notifications' , constraints: {topic_id: /\d+/}
|
||||
|
||||
get 'md/:topic_id(/:post_number)' => 'posts#markdown'
|
||||
|
||||
|
||||
resources :invites
|
||||
delete 'invites' => 'invites#destroy'
|
||||
|
|
Loading…
Reference in New Issue