1 class ComicsController < ApplicationController
2 before_filter :authenticate_user!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
3 before_filter :authenticate_admin!, :only => [:list, :browse]
8 comic.author_id = @author.id
14 @new_comics = Comic.find(:all,
15 :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 5
17 @new_pictures = OriginalPicture.find(:all,
18 :include => [:artist, :license, :resource_picture], :order => 'updated_at', :limit => 5
21 respond_to do |format|
22 format.html # index.html.erb
29 @comics = Comic.list({}, params[:page].to_i, params[:page_size].to_i)
30 respond_to do |format|
31 format.html # index.html.erb
32 format.json { render json: @comics.to_json(Comic.json_opt) }
39 @comic = Comic.find(params[:id])
41 respond_to do |format|
42 # format.html # show.html.erb
43 format.json { render json: @comic }
48 @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
50 respond_to do |format|
51 format.html # index.html.erb
53 render :json => @comic.to_json(
54 :include => [:author, {
55 :panels => {:include => {
56 :panel_pictures => {:include => :resource_picture},
57 :balloons => {:include => :speaches}
63 render :json => "callback(" + @comic.to_json(
65 :panels => {:include => {
66 :panel_pictures => {:include => :resource_picture},
67 :balloons => {:include => :speaches}
78 respond_to do |format|
79 format.html { render layout: 'system' }# index.html.erb
80 format.json { render json: @comics }
85 @comic = Comic.find(params[:id])
87 respond_to do |format|
88 format.html { render layout: 'system' } # show.html.erb
89 format.json { render json: @comic }
94 # GET /comics/new.json
98 respond_to do |format|
99 format.html # new.html.erb
100 format.json { render json: @comic }
106 @comic = Comic.find(params[:id])
107 respond_to do |format|
108 if @comic.own? @author
110 format.json { render json: @comic }
112 format.html { render :status => :forbidden, :file => '/403.html'}
113 format.json { head :forbidden }
121 params[:comic].merge! author_id: @author.id
122 @comic = Comic.new params[:comic]
123 @comic.supply_default
125 respond_to do |format|
127 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
128 format.json { render json: @comic, status: :created, location: @comic }
130 format.html { render action: "new" }
131 format.json { render json: @comic.errors, status: :unprocessable_entity }
139 params[:comic].merge! author_id: @author.id
140 @comic = Comic.find(params[:id])
141 respond_to do |format|
142 if @comic.own? @author
143 if @comic.update_attributes(params[:comic])
144 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
145 format.json { head :ok }
147 format.html { render action: "edit" }
148 format.json { render json: @comic.errors, status: :unprocessable_entity }
151 format.html { render :status => :forbidden, :file => '/403.html'}
152 format.json { head :forbidden }
158 # DELETE /comics/1.json
160 @comic = Comic.find(params[:id])
161 if @comic.own? @author
163 respond_to do |format|
164 format.html { redirect_to comics_url }
165 format.json { head :ok }
168 format.html { render action: "edit" }
169 format.json { render json: @comic.errors, status: :unprocessable_entity }