1 class ComicsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
7 before_filter :authenticate_user!, :only => [:top, :index, :show, :new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_author, :only => [:top, :index, :show, :new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_admin!, :only => [:list, :browse]
13 respond_to do |format|
14 format.html # index.html.erb
21 @page = Comic.page params[:page]
22 @page_size = Comic.page_size params[:page_size]
23 @comics = Comic.list(@page, @page_size)
24 respond_to do |format|
25 format.html # index.html.erb
26 format.json { render json: @comics.to_json(Comic.list_json_opt) }
33 @comic = Comic.show(params[:id], @author)
35 respond_to do |format|
36 format.html # show.html.erb
37 format.json { render json: @comic.to_json(Comic.show_json_opt) }
42 @comic = {:count => Comic.visible_count}
43 respond_to do |format|
44 format.json { render json: @comic.to_json }
51 respond_to do |format|
52 format.html { render layout: 'system' }# index.html.erb
53 format.json { render json: @comics }
58 @comic = Comic.find(params[:id])
60 respond_to do |format|
61 format.html { render layout: 'system' } # show.html.erb
62 format.json { render json: @comic }
71 respond_to do |format|
72 format.html # new.html.erb
74 format.json { render json: @comic.to_json(Comic.show_json_opt) }
79 # GET /comics/1.js/edit
81 @comic = Comic.edit(params[:id], @author)
82 respond_to do |format|
93 @comic.attributes = params[:comic]
94 @comic.overwrite @author
96 respond_to do |format|
98 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
99 format.html { redirect_to @comic }
100 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
102 format.html { render action: "new" }
103 format.json { render json: @comic.errors, status: :unprocessable_entity }
111 @comic = Comic.edit(params[:id], @author)
112 @comic.attributes = params[:comic]
113 @comic.overwrite @author
114 respond_to do |format|
116 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
117 format.html { redirect_to @comic }
118 format.json { head :ok }
120 format.html { render action: "edit" }
121 format.json { render json: @comic.errors, status: :unprocessable_entity }
127 # DELETE /comics/1.json
129 @comic = Comic.edit(params[:id], @author)
131 respond_to do |format|
132 format.html { redirect_to comics_url }
133 format.json { head :ok }