Class | TagsController
In: | app/controllers/tags_controller.rb
Parent: | ApplicationController

### Methods

index inicio show

### Public Instance methods

index()

[Source]

        # File app/controllers/tags_controller.rb, line 2
     2:   def index
     3:     @title_for_head = t('tags.Tags')
     4:     conditions = "draft='f' AND published_at <= '#{Time.now.strftime('%Y-%m-%d %H:%M')}' "
     5:
     6:     @ttype = params[:type]
     7:
     8:     # Deberia ser así
     9:     all_tags = Document.in_irekia.published.tag_counts(:conditions => conditions)
    10:
    11:     # all_tags = Document.tag_counts(:conditions => conditions)
    12:
    13:     @tags = all_tags.sort! {|a, b| b.count <=> a.count}[0..100].sort! {|a, b| a.sanitized_name <=> b.sanitized_name}
    14:
    15:   end

inicio()

[Source]

        # File app/controllers/tags_controller.rb, line 53
    53:   def inicio
    54:     @documents = News.in_irekia.published.translated.find(:all, :include => [:organization => :icon], :order => "featured DESC, published_at DESC", :limit => 6)
    55:
    56:     if @documents.length == 0
    57:       redirect_to documents_path and return
    58:     else
    59:       @main_document = @documents[0]
    60:     end
    61:
    62:     # @your_proposals_text = Proposal.yours_intro_page
    63:     # @your_proposals = Proposal.approved.published.from_citizens.find(:all, :order => "created_at DESC", :limit => 3)
    64:     #
    65:     # @our_proposals_text = Proposal.ours_intro_page
    66:     # @our_proposals = Proposal.approved.published.governmental.find(:all, :order => "created_at DESC", :limit => 3)
    67:
    68:     @category = Category.find_by_name_es('Inicio')
    69:
    70:     @featured_video = Video.find(:first, :conditions => ["featured=?", true])
    71:     @streaming = StreamFlow.find(:first, :conditions => {:show_in_irekia => true})
    72:
    73:     respond_to do |format|
    74:       format.html
    75:       format.iphone
    76:     end
    77:   end

show()

GET /tags/1 GET /tags/1.xml

[Source]

        # File app/controllers/tags_controller.rb, line 19
    19:   def show
    20:     if params[:id].match(/^_/)
    21:       tags = Tag.find_all_by_sanitized_name_es(params[:id])
    22:     else
    23:       tags = Tag.find_by_sql("SELECT * FROM tags WHERE (sanitized_name_es=E'#{params[:id]}' OR sanitized_name_eu=E'#{params[:id]}' OR sanitized_name_en=E'#{params[:id]}')")
    24:     end
    25:
    26:     if tags.empty?
    27:       flash[:notice] = "No hay nada con el tag #{params[:id]}"
    28:       redirect_to tags_path and return
    29:     else
    30:       @title_for_head = t("tags.Documentos_con_tag", :tag => tags.first.name)
    31:     end
    32:
    33:     tag_ids = tags.collect(&:id)
    34:
    35:     conditions = "tag_id in (#{tag_ids.join(', ')})"
    36:
    37:     @taggings = paginated_collection_of_tags_for(conditions, :page => params[:page] || 1)
    38:
    39:     respond_to do |format|
    40:       format.html do
    41:         if @taggings.length == 1
    42:           taggable = @taggings.first.taggable
    43:           if taggable.is_a?(Photo)
    44:             redirect_to album_photo_path(taggable.albums.first, taggable)
    45:           else
    46:             redirect_to taggable and return
    47:           end
    48:         end
    49:       end
    50:     end
    51:   end

[Validate]