Sha256: 6644c13c4d0c45993af33b20753609613d97b6b18cdcc814e6a52131b2e66d7f

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

class TagsController < ContentController
  before_action :auto_discovery_feed, only: [:show, :index]
  layout :theme_layout

  def index
    @tags = Tag.page(params[:page]).per(100)
    @page_title = controller_name.capitalize
    @keywords = ''
    @description = "Tags for #{this_blog.blog_name}"
  end

  def show
    @tag = Tag.find_by!(name: params[:id])

    @articles = @tag.
      contents.includes(:blog, :user, :tags, :resources, :text_filter).
      published.page(params[:page]).per(10)

    respond_to do |format|
      format.html do
        if @articles.empty?
          raise ActiveRecord::RecordNotFound
        else
          @page_title = this_blog.tag_title_template.to_title(@tag, this_blog, params).strip
          @description = this_blog.tag_desc_template.to_title(@tag, this_blog, params).strip
          @keywords = this_blog.meta_keywords
          render template_name(params[:id])
        end
      end

      format.atom do
        @articles = @articles[0, this_blog.limit_rss_display]
        render_cached_xml 'articles/index_atom_feed', @articles
      end

      format.rss do
        @articles = @articles[0, this_blog.limit_rss_display]
        render_cached_xml 'articles/index_rss_feed', @articles
      end
    end
  end

  private

  def template_name(value)
    template_exists?("tags/#{value}") ? value : :show
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
publify_core-9.1.0 app/controllers/tags_controller.rb
publify_core-9.0.1 app/controllers/tags_controller.rb
publify_core-9.0.0 app/controllers/tags_controller.rb