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
51 respond_to do |format|
52 format.html # new.html.erb
54 format.json { render json: @story }
59 # GET /stories/1.js/edit
61 @story = Story.show(params[:id], @author)
62 respond_to do |format|
73 @story.attributes = params[:story]
74 @story.overwrite @author
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.edit(params[:id], @author)
92 @story.attributes = params[:story]
93 @story.overwrite @author
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.edit(params[:id], @author)
111 @story.destroy_and_shorten
113 respond_to do |format|
114 format.html { redirect_to story_path(@story.comic) }
115 format.json { head :ok }