Class: TagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tags_controller.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#indexObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/tags_controller.rb', line 14

def index
  if params[:q] && params[:q].length > 1
    params[:q].gsub!("#", "")
    params[:limit] = !params[:limit].blank? ? params[:limit].to_i : 10
    @tags = ActsAsTaggableOn::Tag.autocomplete(params[:q]).limit(params[:limit] - 1)
    prep_tags_for_javascript

    respond_to do |format|
      format.json{ render(:json => @tags.to_json, :status => 200) }
    end
  else
    respond_to do |format|
      format.json{ render :nothing => true, :status => 422 }
      format.html{ redirect_to tag_path('partytimeexcellent') }
    end
  end
end

#showObject


32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/tags_controller.rb', line 32

def show
  redirect_to(:action => :show, :name => downcased_tag_name) && return if tag_has_capitals?

  if user_signed_in?
    gon.preloads[:tagFollowings] = tags
  end
  @stream = Stream::Tag.new(current_user, params[:name], :max_time => max_time, :page => params[:page])
  respond_with do |format|
    format.json { render :json => @stream.stream_posts.map { |p| LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user)) }}
  end
end