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 = Comic.page params[:page]
34 @page_size = Comic.page_size params[:page_size]
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], @author)
47 respond_to do |format|
48 format.html # show.html.erb
49 format.json { render json: @comic.to_json(Comic.show_json_include_opt) }
54 @comic = {:count => Comic.visible_count}
55 respond_to do |format|
56 format.json { render json: @comic.to_json }
61 @comic = Comic.play(params[:id])
62 respond_to do |format|
63 format.html # index.html.erb
65 render :json => @comic.to_json_play
68 render :json => "callback(" + @comic.to_json_play + ");"
76 respond_to do |format|
77 format.html { render layout: 'system' }# index.html.erb
78 format.json { render json: @comics }
83 @comic = Comic.find(params[:id])
85 respond_to do |format|
86 format.html { render layout: 'system' } # show.html.erb
87 format.json { render json: @comic }
96 respond_to do |format|
97 format.html # new.html.erb
103 # GET /comics/1.js/edit
105 @comic = Comic.show(params[:id], @author)
106 @comic.supply_default
107 respond_to do |format|
116 params[:comic].merge! author_id: @author.id
117 @comic = Comic.new params[:comic]
118 @comic.supply_default
120 respond_to do |format|
122 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
123 format.json { render json: Comic.show(@comic.id, @author).to_json(Comic.show_json_include_opt), status: :created, location: @comic }
125 format.html { render action: "new" }
126 format.json { render json: @comic.errors, status: :unprocessable_entity }
134 params[:comic].merge! author_id: @author.id
135 @comic = Comic.show(params[:id], @author)
136 respond_to do |format|
137 raise ActiveRecord::Forbidden unless @comic.own?(@author)
138 if @comic.update_attributes(params[:comic])
139 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
140 format.json { head :ok }
142 format.html { render action: "edit" }
143 format.json { render json: @comic.errors, status: :unprocessable_entity }
149 # DELETE /comics/1.json
151 @comic = Comic.find(params[:id])
152 if @comic.own? @author
154 respond_to do |format|
155 format.html { redirect_to comics_url }
156 format.json { head :ok }
159 format.html { render action: "edit" }
160 format.json { render json: @comic.errors, status: :unprocessable_entity }