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 c = Comic.show(params[:id], @author)
62 cnt = Panel.count(:conditions => ['comic_id = ?', c.id]).to_i
63 @offset = Comic.offset cnt, params[:offset]
64 @panel_count = Comic.panel_count cnt, params[:count]
65 @comic = Comic.play(params[:id])
66 respond_to do |format|
67 format.html # index.html.erb
69 render :json => @comic.to_json_play
72 render :json => "callback(" + @comic.to_json_play + ");"
80 respond_to do |format|
81 format.html { render layout: 'system' }# index.html.erb
82 format.json { render json: @comics }
87 @comic = Comic.find(params[:id])
89 respond_to do |format|
90 format.html { render layout: 'system' } # show.html.erb
91 format.json { render json: @comic }
100 respond_to do |format|
101 format.html # new.html.erb
107 # GET /comics/1.js/edit
109 @comic = Comic.show(params[:id], @author)
110 @comic.supply_default
111 respond_to do |format|
120 params[:comic].merge! author_id: @author.id
121 @comic = Comic.new params[:comic]
122 @comic.supply_default
124 respond_to do |format|
126 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
127 format.json { render json: Comic.show(@comic.id, @author).to_json(Comic.show_json_include_opt), status: :created, location: @comic }
129 format.html { render action: "new" }
130 format.json { render json: @comic.errors, status: :unprocessable_entity }
138 params[:comic].merge! author_id: @author.id
139 @comic = Comic.show(params[:id], @author)
140 respond_to do |format|
141 raise ActiveRecord::Forbidden unless @comic.own?(@author)
142 if @comic.update_attributes(params[:comic])
143 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
144 format.json { head :ok }
146 format.html { render action: "edit" }
147 format.json { render json: @comic.errors, status: :unprocessable_entity }
153 # DELETE /comics/1.json
155 @comic = Comic.find(params[:id])
156 if @comic.own? @author
158 respond_to do |format|
159 format.html { redirect_to comics_url }
160 format.json { head :ok }
163 format.html { render action: "edit" }
164 format.json { render json: @comic.errors, status: :unprocessable_entity }