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 = SpeechBalloonTemplate.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 = SpeechBalloonTemplate.find(params[:id])
49 respond_to do |format|
50 format.html # show.html.erb
52 render :json => @speech_balloon_template.to_json()
55 render :json => "callback(" + @speech_balloon_template.to_json() + ")"
61 @speech_balloon_templates = SpeechBalloonTemplate.all
63 respond_to do |format|
64 format.html { render layout: 'system' }
65 format.json { render json: @speech_balloon_templates }
70 @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
72 respond_to do |format|
73 format.html { render layout: 'system' }
74 format.json { render json: @speech_balloon_template }
78 # POST /speech_balloon_templates
79 # POST /speech_balloon_templates.json
81 @speech_balloon_template = SpeechBalloonTemplate.new(params[:speech_balloon_template])
82 if em = validate_param(params[:speech_balloon_template])
83 respond_to do |format|
84 format.json { render json: em, status: :unprocessable_entity }
87 respond_to do |format|
88 if @speech_balloon_template.save
89 format.html { redirect_to @speech_balloon_template, notice: 'Speech balloon was successfully created.' }
90 format.json { render json: @speech_balloon_template, status: :created, location: @speech_balloon_template }
92 format.html { render action: "new" }
93 format.json { render json: @speech_balloon_template.errors, status: :unprocessable_entity }
99 # DELETE /speech_balloon_templates/1
100 # DELETE /speech_balloon_templates/1.json
102 @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
103 @speech_balloon_template.destroy
105 respond_to do |format|
106 format.html { redirect_to :action => :list }
107 format.json { head :ok }