OSDN Git Service

try autotest
[pettanr/pettanr.git] / app / controllers / authors_controller.rb
1 class AuthorsController < ApplicationController
2   before_filter :authenticate_user!, :only => [:index, :show]
3   before_filter :authenticate_admin!, :only => [:list, :browse]
4
5   def index
6     @page = Author.page params[:page]
7     @page_size = Author.page_size params[:page_size]
8     @authors = Author.list({}, @page, @page_size)
9
10     respond_to do |format|
11       format.html # index.html.erb
12       format.json { render :json => @authors.to_json(Author.list_json_opt) }
13     end
14   end
15
16   def show
17     @author = Author.show(params[:id])
18
19     respond_to do |format|
20       format.html
21       format.json { render :json => @author.to_json(Author.list_json_opt) }
22     end
23   end
24
25   def count
26     @author = {:count => Author.visible_count}
27     respond_to do |format|
28       format.json { render json: @author.to_json }
29     end
30   end
31   
32   def list
33     @authors = Author.all
34
35     respond_to do |format|
36       format.html { render layout: 'system' }
37     end
38   end
39
40   def browse
41     @author = Author.find(params[:id])
42
43     respond_to do |format|
44       format.html { render layout: 'system' }
45     end
46   end
47   
48 end