OSDN Git Service

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