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.find(:all,
30 :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 20
33 respond_to do |format|
34 format.html # index.html.erb
35 format.json { render json: @comics }
42 @comic = Comic.find(params[:id])
44 respond_to do |format|
45 # format.html # show.html.erb
46 format.json { render json: @comic }
51 @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
53 respond_to do |format|
54 format.html # index.html.erb
56 render :json => @comic.to_json(
57 :include => [:author, {
58 :panels => {:include => {
59 :panel_pictures => {:include => :resource_picture},
60 :balloons => {:include => :speaches}
66 render :json => "callback(" + @comic.to_json(
68 :panels => {:include => {
69 :panel_pictures => {:include => :resource_picture},
70 :balloons => {:include => :speaches}
81 respond_to do |format|
82 format.html { render layout: 'system' }# index.html.erb
83 format.json { render json: @comics }
88 @comic = Comic.find(params[:id])
90 respond_to do |format|
91 format.html { render layout: 'system' } # show.html.erb
92 format.json { render json: @comic }
97 # GET /comics/new.json
100 @comic.supply_default
101 respond_to do |format|
102 format.html # new.html.erb
103 format.json { render json: @comic }
109 @comic = Comic.find(params[:id])
115 params[:comic].merge! author_id: @author.id
116 @comic = Comic.new params[:comic]
117 @comic.supply_default
119 respond_to do |format|
121 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
122 format.json { render json: @comic, status: :created, location: @comic }
124 format.html { render action: "new" }
125 format.json { render json: @comic.errors, status: :unprocessable_entity }
133 params[:comic].merge! author_id: @author.id
134 @comic = Comic.find(params[:id])
135 respond_to do |format|
136 if @comic.own? @author
137 if @comic.update_attributes(params[:comic])
138 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
139 format.json { head :ok }
141 format.html { render action: "edit" }
142 format.json { render json: @comic.errors, status: :unprocessable_entity }
145 format.html { render action: "edit" }
146 format.json { render json: @comic.errors, status: :unprocessable_entity }
152 # DELETE /comics/1.json
154 @comic = Comic.find(params[:id])
155 if @comic.own? @author
157 respond_to do |format|
158 format.html { redirect_to comics_url }
159 format.json { head :ok }
162 format.html { render action: "edit" }
163 format.json { render json: @comic.errors, status: :unprocessable_entity }