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]
21 @item = Story.show(params[:id], @operators)
23 respond_to do |format|
27 @new_sheets = Sheet.mylist(@operators.author, 1, 5)
31 format.json { render json: @item.to_json(Story.show_json_opt) }
36 @story = Story.show(params[:id], [@user, @admin])
37 @page = StorySheet.page params[:page]
38 @sheet = StorySheet.play_sheet(@story, @author, @page)
39 respond_to do |format|
41 @paginate = StorySheet.play_paginate(@story, @page)
43 @new_sheets = Sheet.mylist(@author, 1, 5)
48 @story_sheets = SheetPanel.play_list @sheet, @author
49 render text: SheetPanel.list_as_json_text(@story_sheets, @author)
55 render :json => "callback(" + @story_sheets.to_json_list + ");"
63 respond_to do |format|
66 format.json { render json: @story.to_json(Story.show_json_opt) }
71 @story = Story.edit(params[:id], @operators)
72 respond_to do |format|
81 @story.attributes = params[:story]
83 @comic = Comic.edit(@story.comic_id, @operators) if @story.comic_id
85 respond_to do |format|
86 if @story.store @operators
87 flash[:notice] = I18n.t('flash.notice.created', :model => Story.model_name.human)
88 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
89 format.json { render json: @story.to_json(Story.show_json_opt) }
91 flash[:notice] = I18n.t('flash.notice.not_created', :model => Story.model_name.human)
92 format.html { render action: "new" }
93 format.json { render json: @story.errors, status: :unprocessable_entity }
99 @story = Story.edit(params[:id], @operators)
101 @story.attributes = params[:story]
103 respond_to do |format|
104 if @story.store @operators, ot
105 flash[:notice] = I18n.t('flash.notice.updated', :model => Story.model_name.human)
106 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
107 format.json { head :ok }
109 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Story.model_name.human)
110 format.html { render action: "edit" }
111 format.json { render json: @story.errors, status: :unprocessable_entity }
117 @story = Story.edit(params[:id], @operators)
118 respond_to do |format|
119 if @story.destroy_and_shorten
120 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
121 format.html { redirect_to comic_path(@story.comic)}
122 format.json { head :ok }
124 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
125 format.html { redirect_to story_path(@story) }
126 format.json { render json: @story.errors, status: :unprocessable_entity }