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|
19 @paginate = Comic.list_paginate(@page, @page_size)
20 render :template => 'system/filer', :locals => {
21 :items => @comics, :model => Comic,
22 :roles => [@user, @admin], :pager => @paginate
25 format.json { render json: @comics.to_json(Comic.list_json_opt) }
32 @comic = Comic.show(params[:id], [@user, @admin])
34 respond_to do |format|
36 format.prof { render :template => 'top/prof', :layout => true }
37 format.json { render json: @comic.to_json(Comic.show_json_opt) }
44 @comic = {:count => Comic.visible_count}
45 respond_to do |format|
46 format.json { render json: @comic.to_json }
53 respond_to do |format|
54 format.html { render layout: 'system' }# index.html.erb
55 format.json { render json: @comics }
60 @comic = Comic.find(params[:id])
62 respond_to do |format|
63 format.html { render layout: 'system' } # show.html.erb
64 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 @comic = Comic.edit(params[:id], @author)
80 respond_to do |format|
89 @comic.attributes = params[:comic]
90 @comic.overwrite @author
92 respond_to do |format|
94 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
95 format.html { redirect_to @comic }
96 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
98 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
99 format.html { render action: "new" }
100 format.json { render json: @comic.errors, status: :unprocessable_entity }
106 @comic = Comic.edit(params[:id], @author)
107 @comic.attributes = params[:comic]
108 @comic.overwrite @author
109 respond_to do |format|
111 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
112 format.html { redirect_to @comic }
113 format.json { head :ok }
115 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
116 format.html { render action: "edit" }
117 format.json { render json: @comic.errors, status: :unprocessable_entity }
123 @comic = Comic.edit(params[:id], @author)
124 respond_to do |format|
125 if @comic.destroy_with_story
126 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
127 format.html { redirect_to '/home/comics' }
128 format.json { head :ok }
130 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
131 format.html { redirect_to @comic }
132 format.json { render json: @comic.errors, status: :unprocessable_entity }