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 @page = Comic.page params[:page]
15 @page_size = Comic.page_size params[:page_size]
16 @comics = Comic.list(@page, @page_size)
17 respond_to do |format|
18 format.html # index.html.erb
19 format.json { render json: @comics.to_json(Comic.list_json_opt) }
26 @comic = Comic.show(params[:id], [@user, @admin])
28 respond_to do |format|
29 format.html # show.html.erb
30 format.json { render json: @comic.to_json(Comic.show_json_opt) }
37 @comic = {:count => Comic.visible_count}
38 respond_to do |format|
39 format.json { render json: @comic.to_json }
46 respond_to do |format|
47 format.html { render layout: 'system' }# index.html.erb
48 format.json { render json: @comics }
53 @comic = Comic.find(params[:id])
55 respond_to do |format|
56 format.html { render layout: 'system' } # show.html.erb
57 format.json { render json: @comic }
64 respond_to do |format|
65 format.html # new.html.erb
67 format.json { render json: @comic.to_json(Comic.show_json_opt) }
72 @comic = Comic.edit(params[:id], @author)
73 respond_to do |format|
82 @comic.attributes = params[:comic]
83 @comic.overwrite @author
85 respond_to do |format|
87 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
88 format.html { redirect_to @comic }
89 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
91 format.html { render action: "new" }
92 format.json { render json: @comic.errors, status: :unprocessable_entity }
98 @comic = Comic.edit(params[:id], @author)
99 @comic.attributes = params[:comic]
100 @comic.overwrite @author
101 respond_to do |format|
103 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
104 format.html { redirect_to @comic }
105 format.json { head :ok }
107 format.html { render action: "edit" }
108 format.json { render json: @comic.errors, status: :unprocessable_entity }
114 @comic = Comic.edit(params[:id], @author)
115 respond_to do |format|
116 if @comic.destroy_with_story
117 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
118 format.html { redirect_to '/home/comic' }
119 format.json { head :ok }
121 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
122 format.html { redirect_to @comic }
123 format.json { render json: @comic.errors, status: :unprocessable_entity }