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


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

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 { head :unprocessable_entity }
      format.html { redirect_to tag_path("partytimeexcellent") }
    end
  end
end

#showObject


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/tags_controller.rb', line 35

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])
  @stream = TagStreamPresenter.new(stream)
  respond_with do |format|
    format.json do
      posts = stream.stream_posts.map do |p|
        LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user))
      end
      render json: posts
    end
  end
end