1 class SpeechBalloonsController < ApplicationController
2 before_filter :authenticate_user!, :only => [:index, :show]
3 before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
9 bl = ft[:size_count].to_i
10 tl = ft[:tail_count].to_i
11 if bl * tl == ft[:balloon_templates_attributes].size
19 ft[:balloon_templates_attributes].each do |k, t|
20 flag[t[:size].to_i - 1][t[:tail].to_i - 1] = nil
22 if flag.flatten.compact.size == 0
24 res = "invalid variation"
27 res = "invalid template size"
33 # GET /speech_balloons
34 # GET /speech_balloons.json
36 @speech_balloons = SpeechBalloon.all
38 respond_to do |format|
39 format.html # index.html.erb
40 format.json { render json: @speech_balloons }
44 # GET /speech_balloons/1
45 # GET /speech_balloons/1.json
47 @speech_balloon = SpeechBalloon.find(params[:id], include: {:balloon_templates => :speech_templates})
49 respond_to do |format|
50 format.html # show.html.erb
52 render :json => @speech_balloon.to_json(include: {
53 :balloon_templates => {:include => :speech_templates}
57 render :json => "callback(" + @speech_balloon.to_json(include: {
58 :balloon_templates => {:include => :speech_templates}
65 @speech_balloons = SpeechBalloon.all
67 respond_to do |format|
68 format.html { render layout: 'system' }
69 format.json { render json: @speech_balloons }
74 @speech_balloon = SpeechBalloon.find(params[:id])
76 respond_to do |format|
77 format.html { render layout: 'system' }
78 format.json { render json: @speech_balloon }
82 # POST /speech_balloons
83 # POST /speech_balloons.json
85 @speech_balloon = SpeechBalloon.new(params[:speech_balloon])
86 if em = validate_param(params[:speech_balloon])
87 respond_to do |format|
88 format.json { render json: em, status: :unprocessable_entity }
91 respond_to do |format|
92 if @speech_balloon.save
93 format.html { redirect_to @speech_balloon, notice: 'Speech balloon was successfully created.' }
94 format.json { render json: @speech_balloon, status: :created, location: @speech_balloon }
96 format.html { render action: "new" }
97 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
103 # PUT /speech_balloons/1
104 # PUT /speech_balloons/1.json
106 @speech_balloon = SpeechBalloon.find(params[:id])
108 respond_to do |format|
109 if @speech_balloon.update_attributes(params[:speech_balloon])
110 format.html { redirect_to @speech_balloon, notice: 'Speech balloon was successfully updated.' }
111 format.json { head :ok }
113 format.html { render action: "edit" }
114 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
119 # DELETE /speech_balloons/1
120 # DELETE /speech_balloons/1.json
122 @speech_balloon = SpeechBalloon.find(params[:id])
123 @speech_balloon.destroy
125 respond_to do |format|
126 format.html { redirect_to speech_balloons_url }
127 format.json { head :ok }