1 class StoriesController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :play, :by_comic, :by_sheet, :by_author, :count, :count_by_comic, :count_by_sheet, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
33 def show_html_format format
36 @new_sheet_items = assist_items('sheet', 'private')
37 #@new_sheet_filer = assist_filer 'sheet', @new_sheet_items
44 respond_to do |format|
45 show_html_format format
46 show_prof_format format
47 show_json_format format
52 @item = Story.show(params[:id], @operators)
53 @page = StorySheet.page params[:page]
54 @sheet = StorySheet.play_sheet(@item, @operators, @page)
55 respond_to do |format|
57 @paginate = StorySheet.play_paginate(@item, @page)
59 @new_sheet_items = assist_items('sheet', 'private_list')
60 @new_sheet_filer = assist_filer 'sheet', @new_sheet_items
65 @story_sheets = SheetPanel.play_list @sheet, @author
66 render text: SheetPanel.list_as_json_text(@story_sheets, @author)
72 render :json => "callback(" + @story_sheets.to_json_list + ");"
103 @story.supply_default
104 @story.attributes = params[:story]
106 @comic = Comic.edit(@story.comic_id, @operators) if @story.comic_id
108 respond_to do |format|
109 if @story.store @operators
110 flash[:notice] = I18n.t('flash.notice.created', :model => Story.model_name.human)
111 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
112 format.json { render json: @story.to_json(Story.show_json_opt) }
114 flash[:notice] = I18n.t('flash.notice.not_created', :model => Story.model_name.human)
115 format.html { render action: "new" }
116 format.json { render json: @story.errors, status: :unprocessable_entity }
122 @story = Story.edit(params[:id], @operators)
124 @story.attributes = params[:story]
126 respond_to do |format|
127 if @story.store @operators, ot
128 flash[:notice] = I18n.t('flash.notice.updated', :model => Story.model_name.human)
129 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
130 format.json { head :ok }
132 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Story.model_name.human)
133 format.html { render action: "edit" }
134 format.json { render json: @story.errors, status: :unprocessable_entity }
140 @story = Story.edit(params[:id], @operators)
141 respond_to do |format|
142 if @story.destroy_and_shorten
143 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
144 format.html { redirect_to comic_path(@story.comic)}
145 format.json { head :ok }
147 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
148 format.html { redirect_to story_path(@story) }
149 format.json { render json: @story.errors, status: :unprocessable_entity }