require_dependency 'topic_view' require_dependency 'promotion' require_dependency 'url_helper' require_dependency 'topics_bulk_action' class TopicsController < ApplicationController include UrlHelper before_filter :ensure_logged_in, only: [:timings, :destroy_timings, :update, :star, :destroy, :recover, :status, :invite, :mute, :unmute, :set_notifications, :move_posts, :merge_topic, :clear_pin, :autoclose, :bulk] before_filter :consider_user_for_promotion, only: :show skip_before_filter :check_xhr, only: [:show, :feed] 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) username_filters = opts[:username_filters] opts[:username_filters] = [username_filters] if username_filters.is_a?(String) begin @topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts) rescue Discourse::NotFound topic = Topic.where(slug: params[:id]).first if params[:id] raise Discourse::NotFound unless topic return redirect_to(topic.relative_url) end discourse_expires_in 1.minute redirect_to_correct_topic && return if slugs_do_not_match # render workaround pseudo-static HTML page for old crawlers which ignores