OSDN Git Service

t#29400
[pettanr/pettanr.git] / app / controllers / speech_balloon_templates_controller.rb
1 class SpeechBalloonTemplatesController < ApplicationController
2   layout 'test' if Pettanr::TestLayout
3   before_filter :authenticate_user!, :only => [:index, :show]
4   before_filter :authenticate_admin!, :only => [:list, :browse, :destroy]
5
6   # GET /speech_balloon_templates
7   # GET /speech_balloon_templates.json
8   def index
9     @speech_balloon_templates = SpeechBalloonTemplate.list
10
11     respond_to do |format|
12       format.html # index.html.erb
13       format.json { render json: @speech_balloon_templates.to_json(SpeechBalloonTemplate.list_json_opt) }
14     end
15   end
16
17   # GET /speech_balloon_templates/1
18   # GET /speech_balloon_templates/1.json
19   def show
20     @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], @author)
21
22     respond_to do |format|
23       format.html # show.html.erb
24       format.json {
25         render :json => @speech_balloon_template.to_json(SpeechBalloonTemplate.show_json_opt)
26       }
27       format.jsonp {
28         render :json => "callback(" + @speech_balloon_template.to_json() + ")"
29       }
30     end
31   end
32
33   def list
34     @speech_balloon_templates = SpeechBalloonTemplate.all
35
36     respond_to do |format|
37       format.html { render layout: 'system' }
38       format.json { render json: @speech_balloon_templates }
39     end
40   end
41
42   def browse
43     @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
44
45     respond_to do |format|
46       format.html { render layout: 'system' }
47       format.json { render json: @speech_balloon_template }
48     end
49   end
50
51   # DELETE /speech_balloon_templates/1
52   # DELETE /speech_balloon_templates/1.json
53   def destroy
54     @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
55     @speech_balloon_template.destroy
56
57     respond_to do |format|
58       format.html { redirect_to :action => :list }
59       format.json { head :ok }
60     end
61   end
62 end