1 class SpeechBalloonTemplatesController < ApplicationController
2 before_filter :authenticate_user!, :only => [:index, :show]
3 before_filter :authenticate_admin!, :only => [:list, :browse, :import, :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_balloon_templates
34 # GET /speech_balloon_templates.json
36 @speech_balloon_templates = SpeechBalloon.all
38 respond_to do |format|
39 format.html # index.html.erb
40 format.json { render json: @speech_balloon_templates }
44 # GET /speech_balloon_templates/1
45 # GET /speech_balloon_templates/1.json
47 @speech_balloon_template = 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_template.to_json(include: {
53 :balloon_templates => {:include => :speech_templates}
57 render :json => "callback(" + @speech_balloon_template.to_json(include: {
58 :balloon_templates => {:include => :speech_templates}
65 @speech_balloon_templates = SpeechBalloon.all
67 respond_to do |format|
68 format.html { render layout: 'system' }
69 format.json { render json: @speech_balloon_templates }
74 @speech_balloon_template = SpeechBalloon.find(params[:id])
76 respond_to do |format|
77 format.html { render layout: 'system' }
78 format.json { render json: @speech_balloon_template }
82 # POST /speech_balloon_templates
83 # POST /speech_balloon_templates.json
85 @speech_balloon_template = SpeechBalloon.new(params[:speech_balloon_template])
86 if em = validate_param(params[:speech_balloon_template])
87 respond_to do |format|
88 format.json { render json: em, status: :unprocessable_entity }
91 respond_to do |format|
92 if @speech_balloon_template.save
93 format.html { redirect_to @speech_balloon_template, notice: 'Speech balloon was successfully created.' }
94 format.json { render json: @speech_balloon_template, status: :created, location: @speech_balloon_template }
96 format.html { render action: "new" }
97 format.json { render json: @speech_balloon_template.errors, status: :unprocessable_entity }
103 # DELETE /speech_balloon_templates/1
104 # DELETE /speech_balloon_templates/1.json
106 @speech_balloon_template = SpeechBalloon.find(params[:id])
107 @speech_balloon_template.destroy
109 respond_to do |format|
110 format.html { redirect_to speech_balloon_templates_url }
111 format.json { head :ok }