get rid of nonsense 404.html
correct 404 handling for invalid pages
This commit is contained in:
@@ -65,14 +65,13 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
@latest = f.order('views desc').take(10)
|
||||
@recent = f.order('created_at desc').take(10)
|
||||
@slug = params[:slug].class == String ? params[:slug] : ''
|
||||
@slug.gsub!('-',' ')
|
||||
render status: 404, layout: 'no_js', template: '/exceptions/not_found'
|
||||
end
|
||||
|
||||
rescue_from Discourse::InvalidAccess do
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
class ExceptionsController < ApplicationController
|
||||
skip_before_filter :check_xhr
|
||||
layout 'no_js'
|
||||
|
||||
def not_found
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
|
||||
@latest = f.order('views desc').take(10)
|
||||
@recent = f.order('created_at desc').take(10)
|
||||
@slug = params[:slug].class == String ? params[:slug] : ''
|
||||
@slug.gsub!('-',' ')
|
||||
render status: 404
|
||||
# centralize all rendering of 404 into app controller
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class StaticController < ApplicationController
|
||||
return
|
||||
end
|
||||
|
||||
render file: 'public/404', layout: false, status: 404
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
||||
# This method just redirects to a given url.
|
||||
|
||||
@@ -25,7 +25,10 @@ class TopicsController < ApplicationController
|
||||
caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }
|
||||
|
||||
def show
|
||||
create_topic_view
|
||||
opts = params.slice(:username_filters, :best_of, :page, :post_number, :posts_before, :posts_after, :best)
|
||||
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
|
||||
|
||||
raise Discourse::NotFound unless @topic_view.posts.present?
|
||||
|
||||
anonymous_etag(@topic_view.topic) do
|
||||
redirect_to_correct_topic && return if slugs_do_not_match
|
||||
@@ -196,11 +199,6 @@ class TopicsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def create_topic_view
|
||||
opts = params.slice(:username_filters, :best_of, :page, :post_number, :posts_before, :posts_after, :best)
|
||||
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
|
||||
end
|
||||
|
||||
def toggle_mute(v)
|
||||
@topic = Topic.where(id: params[:topic_id].to_i).first
|
||||
guardian.ensure_can_see!(@topic)
|
||||
|
||||
Reference in New Issue
Block a user