export a json version of user page, include karma and about text

This commit is contained in:
joshua stein 2015-04-09 21:05:50 -05:00
parent 4b3a9ec2e9
commit 8f8ad57135
3 changed files with 8 additions and 1 deletions

View file

@ -2,6 +2,11 @@ class UsersController < ApplicationController
def show
@showing_user = User.where(:username => params[:username]).first!
@title = "User #{@showing_user.username}"
respond_to do |format|
format.html { render :action => "show" }
format.json { render :json => @showing_user }
end
end
def tree

View file

@ -78,6 +78,8 @@ class User < ActiveRecord::Base
:created_at,
:is_admin,
:is_moderator,
:karma,
:about,
])
h[:avatar_url] = avatar_url
h

View file

@ -87,7 +87,7 @@ Lobsters::Application.routes.draw do
get "/c/:id" => "comments#redirect_from_short_id"
get "/u" => "users#tree"
get "/u/:username" => "users#show", :as => "user"
get "/u/:username" => "users#show", :as => "user", :format => /html|json/
get "/settings" => "settings#index"
post "/settings" => "settings#update"