Basic tag metadata returned. Now what to do about posts?...
This commit is contained in:
parent
42e061dfa0
commit
80821c9cc5
6 changed files with 40 additions and 4 deletions
|
|
@ -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
|
class Api::V0::TagsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
head :ok
|
render :json => Api::V0::Serializers::Tag.new(params[:name])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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
|
class Api::V0::UsersController < ApplicationController
|
||||||
def show
|
def show
|
||||||
if user = User.find_by_username(params[:username])
|
if user = User.find_by_username(params[:username])
|
||||||
|
|
|
||||||
19
app/models/api/v0/serializers/tag.rb
Normal file
19
app/models/api/v0/serializers/tag.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
class Api::V0::Serializers::User
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
attr_accessor :user
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
class Api::V0::Serializers::User
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
|
||||||
@person = user.person
|
@person = user.person
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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
|
class Stream::Tag < Stream::Base
|
||||||
attr_accessor :tag_name, :people_page
|
attr_accessor :tag_name, :people_page
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 'spec_helper'
|
||||||
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue