1 class ComicsController < ApplicationController
2 layout 'test' if Pettanr::TestLayout
4 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_user!, :only => [:top, :index, :show, :play, :new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_admin!, :only => [:list, :browse]
13 comic.author_id = @author.id
19 @new_comics = Comic.find(:all,
20 :include => :author, :conditions => ['visible > 0'], :order => 'updated_at desc', :limit => 5
22 @new_pictures = OriginalPicture.find(:all,
23 :include => [:artist, :license, :resource_picture], :order => 'updated_at', :limit => 5
26 respond_to do |format|
27 format.html # index.html.erb
34 @page = Comic.page params[:page]
35 @page_size = Comic.page_size params[:page_size]
36 @comics = Comic.list({}, @page, @page_size)
37 respond_to do |format|
38 format.html # index.html.erb
39 format.json { render json: @comics.to_json(Comic.list_json_opt) }
46 @comic = Comic.show(params[:id], @author)
48 respond_to do |format|
49 format.html # show.html.erb
50 format.json { render json: @comic.to_json(Comic.show_json_include_opt) }
55 @comic = {:count => Comic.visible_count}
56 respond_to do |format|
57 format.json { render json: @comic.to_json }
64 respond_to do |format|
65 format.html { render layout: 'system' }# index.html.erb
66 format.json { render json: @comics }
71 @comic = Comic.find(params[:id])
73 respond_to do |format|
74 format.html { render layout: 'system' } # show.html.erb
75 format.json { render json: @comic }
84 respond_to do |format|
85 format.html # new.html.erb
91 # GET /comics/1.js/edit
93 @comic = Comic.show(params[:id], @author)
95 respond_to do |format|
104 params[:comic].merge! author_id: @author.id
105 @comic = Comic.new params[:comic]
106 @comic.supply_default
108 respond_to do |format|
110 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
111 format.json { render json: Comic.show(@comic.id, @author).to_json(Comic.show_json_include_opt), status: :created, location: @comic }
113 format.html { render action: "new" }
114 format.json { render json: @comic.errors, status: :unprocessable_entity }
122 params[:comic].merge! author_id: @author.id
123 @comic = Comic.show(params[:id], @author)
124 respond_to do |format|
125 if @comic.update_attributes(params[:comic])
126 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
127 format.json { head :ok }
129 format.html { render action: "edit" }
130 format.json { render json: @comic.errors, status: :unprocessable_entity }
136 # DELETE /comics/1.json
138 @comic = Comic.find(params[:id])
139 if @comic.own? @author
141 respond_to do |format|
142 format.html { redirect_to comics_url }
143 format.json { head :ok }
146 format.html { render action: "edit" }
147 format.json { render json: @comic.errors, status: :unprocessable_entity }