1 class ComicsController < ApplicationController
3 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_user!, :only => [:top, :index, :show, :play, :new, :create, :edit, :update, :destroy]
7 before_filter :authenticate_admin!, :only => [:list, :browse]
12 comic.author_id = @author.id
18 @new_comics = Comic.find(:all,
19 :include => :author, :conditions => ['visible > 0'], :order => 'updated_at desc', :limit => 5
21 @new_pictures = OriginalPicture.find(:all,
22 :include => [:artist, :license, :resource_picture], :order => 'updated_at', :limit => 5
25 respond_to do |format|
26 format.html # index.html.erb
33 @page = params[:page].to_i
34 @page_size = params[:page_size].to_i
35 @comics = Comic.list({}, @page, @page_size)
36 respond_to do |format|
37 format.html # index.html.erb
38 format.json { render json: @comics.to_json(Comic.list_json_opt) }
45 @comic = Comic.show(params[:id])
47 respond_to do |format|
48 raise ActiveRecord::Forbidden unless @comic.vis(@author)
49 format.html # show.html.erb
50 format.json { render json: @comic.to_json(Comic.show_json_opt) }
55 @comic = {:count => Comic.visible_count}
56 respond_to do |format|
57 format.json { render json: @comic.to_json }
62 @comic = Comic.play(params[:id])
63 respond_to do |format|
64 format.html # index.html.erb
66 render :json => @comic.to_json_play
69 render :json => "callback(" + @comic.to_json_play + ");"
77 respond_to do |format|
78 format.html { render layout: 'system' }# index.html.erb
79 format.json { render json: @comics }
84 @comic = Comic.find(params[:id])
86 respond_to do |format|
87 format.html { render layout: 'system' } # show.html.erb
88 format.json { render json: @comic }
97 respond_to do |format|
98 format.html # new.html.erb
104 # GET /comics/1.js/edit
106 @comic = Comic.find(params[:id])
107 @comic.supply_default
108 respond_to do |format|
109 raise ActiveRecord::Forbidden unless @comic.own?(@author)
118 params[:comic].merge! author_id: @author.id
119 @comic = Comic.new params[:comic]
120 @comic.supply_default
122 respond_to do |format|
124 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
125 format.json { render json: Comic.show(@comic.id).to_json(Comic.show_json_opt), status: :created, location: @comic }
127 format.html { render action: "new" }
128 format.json { render json: @comic.errors, status: :unprocessable_entity }
136 params[:comic].merge! author_id: @author.id
137 @comic = Comic.find(params[:id])
138 respond_to do |format|
139 raise ActiveRecord::Forbidden unless @comic.own?(@author)
140 if @comic.update_attributes(params[:comic])
141 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
142 format.json { head :ok }
144 format.html { render action: "edit" }
145 format.json { render json: @comic.errors, status: :unprocessable_entity }
151 # DELETE /comics/1.json
153 @comic = Comic.find(params[:id])
154 if @comic.own? @author
156 respond_to do |format|
157 format.html { redirect_to comics_url }
158 format.json { head :ok }
161 format.html { render action: "edit" }
162 format.json { render json: @comic.errors, status: :unprocessable_entity }