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, :new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_admin!, :only => [:list, :browse]
11 @comic = Comic.show(params[:id], @author)
12 cnt = Story.count(:conditions => ['comic_id = ?', @comic.id]).to_i
13 @offset = Story.offset cnt, params[:offset]
14 @panel_count = Story.panel_count cnt, params[:count]
15 @stories = Story.list(@comic, @author, @offset, @panel_count)
16 respond_to do |format|
17 format.html # index.html.erb
19 render :json => @stories.to_json_list
22 render :json => "callback(" + @stories.to_json_list + ");"
30 respond_to do |format|
31 format.html { render layout: 'system' }# index.html.erb
32 format.json { render json: @stories }
37 @story = Story.find(params[:id])
39 respond_to do |format|
40 format.html { render layout: 'system' } # show.html.erb
41 format.json { render json: @story }
47 # GET /stories/new.json
50 @story.supply_default @author
52 respond_to do |format|
53 format.html # new.html.erb
54 format.js { @form_opt = {:remote => true} ; render action: "new" }
55 format.json { render json: @story }
60 # GET /stories/1.js/edit
62 @story = Story.show(params[:id], @author)
63 respond_to do |format|
73 @story.supply_default @author
74 @story.attributes = params[:story]
76 respond_to do |format|
78 format.html { redirect_to action: :show, id: @story.comic_id }
79 format.json { render json: @story.to_json() }
81 format.html { render action: "new" }
82 format.json { render json: @story.errors, status: :unprocessable_entity }
90 @story = Story.show(params[:id], @author)
91 @story.author_id = @author.id
93 @story.attributes = params[:story]
94 respond_to do |format|
96 format.html { redirect_to action: :show, id: @story.comic_id }
97 format.json { head :ok }
99 format.html { render action: "edit" }
100 format.json { render json: @story.errors, status: :unprocessable_entity }
106 # DELETE /stories/1.js
107 # DELETE /stories/1.json
109 @story = Story.show(params[:id], @author)
110 @story.destroy_and_shorten
111 respond_to do |format|
112 format.html { redirect_to story_path(@story.comic) }
113 format.json { head :ok }