require_dependency 'topic_view' require_dependency 'promotion' class TopicsController < ApplicationController # Avatar is an image request, not XHR before_filter :ensure_logged_in, only: [:timings, :destroy_timings, :update, :star, :destroy, :status, :invite, :mute, :unmute, :set_notifications, :move_posts, :merge_topic, :clear_pin, :autoclose] before_filter :consider_user_for_promotion, only: :show skip_before_filter :check_xhr, only: [:avatar, :show, :feed] caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" } def show # We'd like to migrate the wordpress feed to another url. This keeps up backwards compatibility with # existing installs. return wordpress if params[:best].present? opts = params.slice(:username_filters, :filter, :page, :post_number) begin @topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts) rescue Discourse::NotFound Rails.logger.info ">>>> B" topic = Topic.where(slug: params[:id]).first if params[:id] raise Discourse::NotFound unless topic return redirect_to(topic.relative_url) end anonymous_etag(@topic_view.topic) do redirect_to_correct_topic && return if slugs_do_not_match # render workaround pseudo-static HTML page for old crawlers which ignores