diff --git a/app/controllers/api/v0/tags_controller.rb b/app/controllers/api/v0/tags_controller.rb index 4bb08428642d42236dcd42e28c505c1ad73712c1..1ce401b1c22f5343ddf1a838366314f4e6dbeb4b 100644 --- a/app/controllers/api/v0/tags_controller.rb +++ b/app/controllers/api/v0/tags_controller.rb @@ -1,5 +1,9 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + class Api::V0::TagsController < ApplicationController def show - head :ok + render :json => Api::V0::Serializers::Tag.new(params[:name]) end end diff --git a/app/controllers/api/v0/users_controller.rb b/app/controllers/api/v0/users_controller.rb index 882a46162021306ace2417e298723132d36ee2e8..5328a63c3f2b5230f78e0e771c9c3c032b44e81e 100644 --- a/app/controllers/api/v0/users_controller.rb +++ b/app/controllers/api/v0/users_controller.rb @@ -1,3 +1,7 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + class Api::V0::UsersController < ApplicationController def show if user = User.find_by_username(params[:username]) diff --git a/app/models/api/v0/serializers/tag.rb b/app/models/api/v0/serializers/tag.rb new file mode 100644 index 0000000000000000000000000000000000000000..73ef055d8b0018c53e513c63b65df839bb5105de --- /dev/null +++ b/app/models/api/v0/serializers/tag.rb @@ -0,0 +1,19 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +class Api::V0::Serializers::Tag + + def initialize(tag) + @stream = Stream::Tag.new(nil, tag) + end + + def as_json(opts={}) + { + "name" => @stream.tag_name, + "person_count" => @stream.people_count, + "followed_count" => @stream.tag_follow_count, + "posts" => [] + } + end +end diff --git a/app/models/api/v0/serializers/user.rb b/app/models/api/v0/serializers/user.rb index 7bbaa259d127f42f0c51b1fd8c4171f30143c1b0..2dc94fc0724ea4265426bb5e3b3bff864359db24 100644 --- a/app/models/api/v0/serializers/user.rb +++ b/app/models/api/v0/serializers/user.rb @@ -1,8 +1,9 @@ -class Api::V0::Serializers::User - attr_accessor :user +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. +class Api::V0::Serializers::User def initialize(user) - @user = user @person = user.person @profile = @person.profile end diff --git a/lib/stream/tag.rb b/lib/stream/tag.rb index 312a3b58f9186a1818bb861b93ef6ab497b7faa3..97d7a7936e654e6b696e57957c12cdfa69fa1b67 100644 --- a/lib/stream/tag.rb +++ b/lib/stream/tag.rb @@ -1,3 +1,7 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + class Stream::Tag < Stream::Base attr_accessor :tag_name, :people_page diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb index edc9d4e7e63a1f7341839a05afaf7c26b211a8ce..3c12d55f0d026e94c0a98d3b038f3d537859be61 100644 --- a/spec/lib/stream/tag_spec.rb +++ b/spec/lib/stream/tag_spec.rb @@ -1,3 +1,7 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + require 'spec_helper' require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')