1 class ComicsController < ApplicationController
2 before_filter :authenticate_author!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
3 before_filter :authenticate_admin!, :only => [:list, :browse]
8 comic.author_id = current_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
101 respond_to do |format|
102 format.html # new.html.erb
103 format.json { render json: @comic }
109 @comic = Comic.find(params[:id])
115 @comic = Comic.new(params[:comic])
118 respond_to do |format|
120 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
121 format.json { render json: @comic, status: :created, location: @comic }
123 format.html { render action: "new" }
124 format.json { render json: @comic.errors, status: :unprocessable_entity }
132 @comic = Comic.find(params[:id])
133 if @comic.own? current_author
134 respond_to do |format|
135 if @comic.update_attributes(params[:comic])
136 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
137 format.json { head :ok }
139 format.html { render action: "edit" }
140 format.json { render json: @comic.errors, status: :unprocessable_entity }
144 format.html { render action: "edit" }
145 format.json { render json: @comic.errors, status: :unprocessable_entity }
150 # DELETE /comics/1.json
152 @comic = Comic.find(params[:id])
153 if @comic.own? current_author
155 respond_to do |format|
156 format.html { redirect_to comics_url }
157 format.json { head :ok }
160 format.html { render action: "edit" }
161 format.json { render json: @comic.errors, status: :unprocessable_entity }