1 class PanelsController < ApplicationController
2 before_filter :authenticate_author!, :except => [:index, :show]
7 panel.author_id = current_author.id
15 @panels = Panel.all :order => 'updated_at'
17 respond_to do |format|
18 format.html # index.html.erb
19 format.json { render json: @panels }
26 @panel = Panel.find(params[:id], include: [:comic, :panel_pictures => :resource_picture, :balloons => :speaches])# only: [:width, :height])
28 respond_to do |format|
29 format.html # show.html.erb
31 render :json => @panel.to_json(include: {
32 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
36 render :json => "callback(" + @panel.to_json(include: {
37 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
40 # format.json { render :json => @frame.to_json(include: {
41 # :comic => {:only => :title}, :panel_pictures => {:include => {:image => {:only => [:width]}},:only => [:width, :height, :zindex, :image_id]}
42 # }, only: [:border]) }
47 # GET /panels/new.json
51 respond_to do |format|
52 format.html # new.html.erb
53 format.json { render json: @panel }
59 @panel = Panel.find(params[:id])
65 @panel = Panel.new(params[:panel])
67 @comic = Comic.find @panel.comic_id
69 respond_to do |format|
72 format.html { redirect_to @panel, notice: 'Panel was successfully created.' }
73 format.json { render json: @panel, status: :created, location: @panel }
75 format.html { render action: "new" }
76 format.json { render json: @panel.errors, status: :unprocessable_entity }
85 @panel = Panel.find(params[:id])
86 if @panel.own? current_author
87 respond_to do |format|
89 if params[:panel][:seqno] and params[:panel][:seqno].to_i != @panel.seqno
90 @panel.move_to params[:panel][:seqno].to_i
92 if @panel.update_attributes(params[:panel])
93 format.html { redirect_to @panel, notice: 'Panel was successfully updated.' }
94 format.json { head :ok }
96 format.html { render action: "edit" }
97 format.json { render json: @panel.errors, status: :unprocessable_entity }
102 format.html { render action: "edit" }
103 format.json { render json: @panel.errors, status: :unprocessable_entity }
108 # DELETE /panels/1.json
110 @panel = Panel.find(params[:id])
111 if @panel.own? current_author
112 respond_to do |format|
114 @panel.destroy_and_shorten
115 format.html { redirect_to panels_url }
116 format.json { head :ok }
120 format.html { render action: "edit" }
121 format.json { render json: @panel.errors, status: :unprocessable_entity }
126 @panel = Panel.find(params[:id])
127 @new_seq = params[:panel][:seqno].to_i
128 respond_to do |format|
130 if @panel.move_to(@new_seq)
131 format.html { redirect_to @panel, notice: 'Panel was successfully moved.' }
132 format.json { head :ok }
134 format.html { render action: "show" }
135 format.json { render json: @panel.errors, status: :unprocessable_entity }