Sha256: 013bc79add2e465a0f9fd505a4f8d6244e1ba3e75969d8a8fe9e032bda4f3b77

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 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 "articles/index"
        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

10 entries across 10 versions & 1 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.4.0 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.3.0 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.2.0 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.1.1 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.1.0 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.0.3 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.0.2 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.0.1 app/controllers/tags_controller.rb
HornsAndHooves-publify_core-10.0.0 app/controllers/tags_controller.rb