OSDN Git Service

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