1 class PanelsController < ApplicationController
3 before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy]
4 before_filter :authenticate_admin!, :only => [:list, :browse]
9 panel.author_id = @author.id
17 @panels = Panel.find(:all, :include => [:comic, :author], :order => 'updated_at', :limit => 20)
19 respond_to do |format|
20 format.html # index.html.erb
21 format.json { render :json => @panels.to_json(
22 :include => [:comic, :author]
30 @panel = Panel.find(params[:id], include: [:comic, :panel_pictures => :resource_picture, :balloons => :speaches])# only: [:width, :height])
32 respond_to do |format|
33 format.html # show.html.erb
35 render :json => @panel.to_json(include: {
36 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
40 render :json => "callback(" + @panel.to_json(include: {
41 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
44 # format.json { render :json => @frame.to_json(include: {
45 # :comic => {:only => :title}, :panel_pictures => {:include => {:image => {:only => [:width]}},:only => [:width, :height, :z, :image_id]}
46 # }, only: [:border]) }
51 @panels = Panel.all :order => 'updated_at'
53 respond_to do |format|
54 format.html { render layout: 'system' }
55 format.json { render json: @panels }
60 @panel = Panel.find(params[:id])
62 respond_to do |format|
63 format.html { render layout: 'system' }
71 jsn = JSON.parse(params[:json])
73 @prm = params[:panel] || jsn
74 @panel = Panel.new(@prm)
76 @comic = Comic.find @panel.comic_id
78 respond_to do |format|
81 format.html { redirect_to @panel, notice: 'Panel was successfully created.' }
82 format.json { render json: @panel, status: :created, location: @panel }
84 format.html { render action: "new" }
85 format.json { render json: @panel.errors, status: :unprocessable_entity }
94 @panel = Panel.find(params[:id])
95 if @panel.own? @author
96 respond_to do |format|
98 if params[:panel][:t] and params[:panel][:t].to_i != @panel.t
99 @panel.move_to params[:panel][:t].to_i
101 if @panel.update_attributes(params[:panel])
102 format.html { redirect_to @panel, notice: 'Panel was successfully updated.' }
103 format.json { head :ok }
105 format.html { render action: "edit" }
106 format.json { render json: @panel.errors, status: :unprocessable_entity }
111 format.html { render action: "edit" }
112 format.json { render json: @panel.errors, status: :unprocessable_entity }
117 # DELETE /panels/1.json
119 @panel = Panel.find(params[:id])
120 if @panel.own? @author
121 respond_to do |format|
123 @panel.destroy_and_shorten
124 format.html { redirect_to panels_url }
125 format.json { head :ok }
129 format.html { render action: "edit" }
130 format.json { render json: @panel.errors, status: :unprocessable_entity }
135 @panel = Panel.find(params[:id])
136 @new_seq = params[:panel][:t].to_i
137 respond_to do |format|
139 if @panel.move_to(@new_t)
140 format.html { redirect_to @panel, notice: 'Panel was successfully moved.' }
141 format.json { head :ok }
143 format.html { render action: "show" }
144 format.json { render json: @panel.errors, status: :unprocessable_entity }