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_reader, :only => [:top, :index, :show]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
14 respond_to do |format|
20 @page = Comic.page params[:page]
21 @page_size = Comic.page_size params[:page_size]
22 @comics = Comic.list(@page, @page_size)
23 respond_to do |format|
24 format.html # index.html.erb
25 format.json { render json: @comics.to_json(Comic.list_json_opt) }
30 @comic = Comic.show(params[:id], [@user, @admin])
32 respond_to do |format|
33 format.html # show.html.erb
34 format.json { render json: @comic.to_json(Comic.show_json_opt) }
39 @comic = {:count => Comic.visible_count}
40 respond_to do |format|
41 format.json { render json: @comic.to_json }
48 respond_to do |format|
49 format.html { render layout: 'system' }# index.html.erb
50 format.json { render json: @comics }
55 @comic = Comic.find(params[:id])
57 respond_to do |format|
58 format.html { render layout: 'system' } # show.html.erb
59 format.json { render json: @comic }
66 respond_to do |format|
67 format.html # new.html.erb
69 format.json { render json: @comic.to_json(Comic.show_json_opt) }
74 @comic = Comic.edit(params[:id], @author)
75 respond_to do |format|
84 @comic.attributes = params[:comic]
85 @comic.overwrite @author
87 respond_to do |format|
89 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
90 format.html { redirect_to @comic }
91 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
93 format.html { render action: "new" }
94 format.json { render json: @comic.errors, status: :unprocessable_entity }
100 @comic = Comic.edit(params[:id], @author)
101 @comic.attributes = params[:comic]
102 @comic.overwrite @author
103 respond_to do |format|
105 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
106 format.html { redirect_to @comic }
107 format.json { head :ok }
109 format.html { render action: "edit" }
110 format.json { render json: @comic.errors, status: :unprocessable_entity }
116 @comic = Comic.edit(params[:id], @author)
117 respond_to do |format|
118 if @comic.destroy_with_story
119 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
120 format.html { redirect_to '/home/comic' }
121 format.json { head :ok }
123 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
124 format.html { redirect_to @comic }
125 format.json { render json: @comic.errors, status: :unprocessable_entity }