1 class StoriesController < ApplicationController
2 layout 'test' if Pettanr::TestLayout
4 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_user!, :only => [:index, :show, :comic, :new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_admin!, :only => [:list, :browse]
11 @story = Story.show(params[:id], @author)
13 respond_to do |format|
14 format.html # show.html.erb
15 format.json { render json: @story.story_as_json(@author) }
20 @comic = Comic.show(params[:id], @author)
21 cnt = Story.count(:conditions => ['comic_id = ?', @comic.id]).to_i
22 @offset = Story.offset cnt, params[:offset]
23 @panel_count = Story.panel_count cnt, params[:count]
24 @stories = Story.play_list(@comic, @author, @offset, @panel_count)
25 respond_to do |format|
26 format.html # index.html.erb
27 format.json {render text: Story.list_as_json_text(@stories, @author)}
29 render :json => "callback(" + @stories.to_json_list + ");"
37 respond_to do |format|
38 format.html { render layout: 'system' }# index.html.erb
39 format.json { render json: @stories }
44 @story = Story.find(params[:id])
46 respond_to do |format|
47 format.html { render layout: 'system' } # show.html.erb
48 format.json { render json: @story }
54 # GET /stories/new.json
58 respond_to do |format|
59 format.html # new.html.erb
61 format.json { render json: @story.story_as_json(@author) }
66 # GET /stories/1.js/edit
68 @story = Story.edit(params[:id], @author)
69 respond_to do |format|
80 @story.attributes = params[:story]
81 @story.overwrite @author
82 @comic = Comic.edit(@story.comic_id, @author)
83 @panel = Panel.show(@story.panel_id, @author)
85 respond_to do |format|
87 format.html { redirect_to action: :comic, id: @story.comic_id }
88 format.json { render json: @story.story_as_json(@author) }
90 format.html { render action: "new" }
91 format.json { render json: @story.errors, status: :unprocessable_entity }
99 @story = Story.edit(params[:id], @author)
101 @story.attributes = params[:story]
102 @story.overwrite @author
103 respond_to do |format|
105 format.html { redirect_to action: :comic, id: @story.comic_id }
106 format.json { head :ok }
108 format.html { render action: "edit" }
109 format.json { render json: @story.errors, status: :unprocessable_entity }
115 # DELETE /stories/1.js
116 # DELETE /stories/1.json
118 @story = Story.edit(params[:id], @author)
120 @story.destroy_and_shorten
122 respond_to do |format|
123 format.html { redirect_to story_path(@story.comic) }
124 format.json { head :ok }