Sha256: 9707f7ea27f61bc2419d8682474e927f2c290514c79144ee51680fffb5890890

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

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)
      .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-10.0.2 app/controllers/tags_controller.rb
publify_core-10.0.1 app/controllers/tags_controller.rb
publify_core-10.0.0 app/controllers/tags_controller.rb