1 class StoriesController < 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 => [:index, :show, :play]
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]
17 respond_to do |format|
19 format.json { render json: @items.to_json(@@model.list_json_opt) }
24 @item = Story.show(params[:id], @operators)
26 respond_to do |format|
30 @new_sheets = Sheet.mylist(@operators.author, 1, 5)
34 format.json { render json: @item.to_json(Story.show_json_opt) }
39 @story = Story.show(params[:id], [@user, @admin])
40 @page = StorySheet.page params[:page]
41 @sheet = StorySheet.play_sheet(@story, @author, @page)
42 respond_to do |format|
44 @paginate = StorySheet.play_paginate(@story, @page)
46 @new_sheets = Sheet.mylist(@author, 1, 5)
51 @story_sheets = SheetPanel.play_list @sheet, @author
52 render text: SheetPanel.list_as_json_text(@story_sheets, @author)
58 render :json => "callback(" + @story_sheets.to_json_list + ");"
66 respond_to do |format|
67 format.html { render layout: 'system' }# index.html.erb
68 format.json { render json: @stories }
73 @story = Story.find(params[:id])
75 respond_to do |format|
76 format.html { render layout: 'system' } # show.html.erb
77 format.json { render json: @story }
84 respond_to do |format|
85 format.html # new.html.erb
87 format.json { render json: @story.to_json(Story.show_json_opt) }
92 @story = Story.edit(params[:id], @author)
93 respond_to do |format|
101 @story.supply_default
102 @story.attributes = params[:story]
104 @comic = Comic.edit(@story.comic_id, @author) if @story.comic_id
106 respond_to do |format|
107 if @story.store @author
108 flash[:notice] = I18n.t('flash.notice.created', :model => Story.model_name.human)
109 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
110 format.json { render json: @story.to_json(Story.show_json_opt) }
112 flash[:notice] = I18n.t('flash.notice.not_created', :model => Story.model_name.human)
113 format.html { render action: "new" }
114 format.json { render json: @story.errors, status: :unprocessable_entity }
120 @story = Story.edit(params[:id], @author)
122 @story.attributes = params[:story]
124 respond_to do |format|
125 if @story.store @author, ot
126 flash[:notice] = I18n.t('flash.notice.updated', :model => Story.model_name.human)
127 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
128 format.json { head :ok }
130 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Story.model_name.human)
131 format.html { render action: "edit" }
132 format.json { render json: @story.errors, status: :unprocessable_entity }
138 @story = Story.edit(params[:id], @author)
139 respond_to do |format|
140 if @story.destroy_and_shorten
141 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
142 format.html { redirect_to comic_path(@story.comic)}
143 format.json { head :ok }
145 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
146 format.html { redirect_to story_path(@story) }
147 format.json { render json: @story.errors, status: :unprocessable_entity }