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|
19 @page = Comic.page params[:page]
20 @page_size = Comic.page_size params[:page_size]
21 @comics = Comic.list(@page, @page_size)
22 respond_to do |format|
23 format.html # index.html.erb
24 format.json { render json: @comics.to_json(Comic.list_json_opt) }
29 @comic = Comic.show(params[:id], @author)
31 respond_to do |format|
32 format.html # show.html.erb
33 format.json { render json: @comic.to_json(Comic.show_json_opt) }
38 @comic = {:count => Comic.visible_count}
39 respond_to do |format|
40 format.json { render json: @comic.to_json }
47 respond_to do |format|
48 format.html { render layout: 'system' }# index.html.erb
49 format.json { render json: @comics }
54 @comic = Comic.find(params[:id])
56 respond_to do |format|
57 format.html { render layout: 'system' } # show.html.erb
58 format.json { render json: @comic }
65 respond_to do |format|
66 format.html # new.html.erb
68 format.json { render json: @comic.to_json(Comic.show_json_opt) }
73 @comic = Comic.edit(params[:id], @author)
74 respond_to do |format|
83 @comic.attributes = params[:comic]
84 @comic.overwrite @author
86 respond_to do |format|
88 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
89 format.html { redirect_to @comic }
90 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
92 format.html { render action: "new" }
93 format.json { render json: @comic.errors, status: :unprocessable_entity }
99 @comic = Comic.edit(params[:id], @author)
100 @comic.attributes = params[:comic]
101 @comic.overwrite @author
102 respond_to do |format|
104 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
105 format.html { redirect_to @comic }
106 format.json { head :ok }
108 format.html { render action: "edit" }
109 format.json { render json: @comic.errors, status: :unprocessable_entity }
115 @comic = Comic.edit(params[:id], @author)
116 respond_to do |format|
117 if @comic.destroy_with_story
118 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
119 format.html { redirect_to '/home/comic' }
120 format.json { head :ok }
122 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
123 format.html { redirect_to @comic }
124 format.json { render json: @comic.errors, status: :unprocessable_entity }