Sha256: 80e84e8ede93e083a8af014872fff7744093e054869f274ee1209847832a704a

Contents?: true

Size: 1.35 KB

Versions: 11

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

11 entries across 11 versions & 1 rubygems

Version Path
publify_core-9.2.10 app/controllers/tags_controller.rb
publify_core-9.2.9 app/controllers/tags_controller.rb
publify_core-9.2.8 app/controllers/tags_controller.rb
publify_core-9.2.7 app/controllers/tags_controller.rb
publify_core-9.2.6 app/controllers/tags_controller.rb
publify_core-9.2.5 app/controllers/tags_controller.rb
publify_core-9.2.4 app/controllers/tags_controller.rb
publify_core-9.2.3 app/controllers/tags_controller.rb
publify_core-9.2.2 app/controllers/tags_controller.rb
publify_core-9.2.1 app/controllers/tags_controller.rb
publify_core-9.2.0 app/controllers/tags_controller.rb