Sha256: 0f04bff7cebd4b8cbdb2375cd3d19babdca849dd76d588dda8dc0075ca127d10

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 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 = "#{self.class.to_s.sub(/Controller$/, '')} for #{this_blog.blog_name}"
  end

  def show
    @grouping = Tag.find_by(name: params[:id])
    if @grouping.nil?
      @articles = []
    else
      @page_title = this_blog.tag_title_template.to_title(@grouping, this_blog, params)
      @description = @grouping.description.to_s
      @keywords = ''
      @keywords << @grouping.keywords unless @grouping.keywords.blank?
      @keywords << this_blog.meta_keywords unless this_blog.meta_keywords.blank?
      @articles = @grouping.articles.published.page(params[:page]).per(10)
    end
    respond_to do |format|
      format.html do
        if @articles.empty?
          render 'errors/404', status: 404
        else
          render template_name(params[:id])
        end
      end

      format.atom do
        @articles = @articles[0, this_blog.limit_rss_display]
        render 'articles/index_atom_feed', layout: false
      end

      format.rss do
        @articles = @articles[0, this_blog.limit_rss_display]
        render 'articles/index_rss_feed', layout: false
      end
    end
  end

  private

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
publify_core-9.0.0.pre6 app/controllers/tags_controller.rb
publify_core-9.0.0.pre5 app/controllers/tags_controller.rb
publify_core-9.0.0.pre4 app/controllers/tags_controller.rb
publify_core-9.0.0.pre3 app/controllers/tags_controller.rb