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)
21 format.json { render json: @comics.to_json(Comic.list_json_opt) }
28 @comic = Comic.show(params[:id], [@user, @admin])
30 respond_to do |format|
32 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 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
94 format.html { render action: "new" }
95 format.json { render json: @comic.errors, status: :unprocessable_entity }
101 @comic = Comic.edit(params[:id], @author)
102 @comic.attributes = params[:comic]
103 @comic.overwrite @author
104 respond_to do |format|
106 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
107 format.html { redirect_to @comic }
108 format.json { head :ok }
110 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
111 format.html { render action: "edit" }
112 format.json { render json: @comic.errors, status: :unprocessable_entity }
118 @comic = Comic.edit(params[:id], @author)
119 respond_to do |format|
120 if @comic.destroy_with_story
121 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
122 format.html { redirect_to '/home/comics' }
123 format.json { head :ok }
125 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
126 format.html { redirect_to @comic }
127 format.json { render json: @comic.errors, status: :unprocessable_entity }