OSDN Git Service

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