1 class PanelsController < ApplicationController
2 before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy]
3 before_filter :authenticate_admin!, :only => [:list, :browse]
8 panel.author_id = @author.id
16 @panels = Panel.find(:all, :include => [:comic, :author], :order => 'updated_at', :limit => 20)
18 respond_to do |format|
19 format.html # index.html.erb
20 format.json { render :json => @panels.to_json(
21 :include => [:comic, :author]
29 @panel = Panel.find(params[:id], include: [:comic, :panel_pictures => :resource_picture, :balloons => :speaches])# only: [:width, :height])
31 respond_to do |format|
32 format.html # show.html.erb
34 render :json => @panel.to_json(include: {
35 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
39 render :json => "callback(" + @panel.to_json(include: {
40 :comic => {}, :panel_pictures => {:include => :image}, :fukidashis => {:include => :serifus}
43 # format.json { render :json => @frame.to_json(include: {
44 # :comic => {:only => :title}, :panel_pictures => {:include => {:image => {:only => [:width]}},:only => [:width, :height, :z, :image_id]}
45 # }, only: [:border]) }
50 @panels = Panel.all :order => 'updated_at'
52 respond_to do |format|
53 format.html { render layout: 'system' }
54 format.json { render json: @panels }
59 @panel = Panel.find(params[:id])
61 respond_to do |format|
62 format.html { render layout: 'system' }
69 @panel = Panel.new(params[:panel])
71 @comic = Comic.find @panel.comic_id
73 respond_to do |format|
76 format.html { redirect_to @panel, notice: 'Panel was successfully created.' }
77 format.json { render json: @panel, status: :created, location: @panel }
79 format.html { render action: "new" }
80 format.json { render json: @panel.errors, status: :unprocessable_entity }
89 @panel = Panel.find(params[:id])
90 if @panel.own? @author
91 respond_to do |format|
93 if params[:panel][:t] and params[:panel][:t].to_i != @panel.t
94 @panel.move_to params[:panel][:t].to_i
96 if @panel.update_attributes(params[:panel])
97 format.html { redirect_to @panel, notice: 'Panel was successfully updated.' }
98 format.json { head :ok }
100 format.html { render action: "edit" }
101 format.json { render json: @panel.errors, status: :unprocessable_entity }
106 format.html { render action: "edit" }
107 format.json { render json: @panel.errors, status: :unprocessable_entity }
112 # DELETE /panels/1.json
114 @panel = Panel.find(params[:id])
115 if @panel.own? @author
116 respond_to do |format|
118 @panel.destroy_and_shorten
119 format.html { redirect_to panels_url }
120 format.json { head :ok }
124 format.html { render action: "edit" }
125 format.json { render json: @panel.errors, status: :unprocessable_entity }
130 @panel = Panel.find(params[:id])
131 @new_seq = params[:panel][:t].to_i
132 respond_to do |format|
134 if @panel.move_to(@new_t)
135 format.html { redirect_to @panel, notice: 'Panel was successfully moved.' }
136 format.json { head :ok }
138 format.html { render action: "show" }
139 format.json { render json: @panel.errors, status: :unprocessable_entity }