1 class ComicsController < ApplicationController
2 before_filter :authenticate_author!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
3 before_filter :authenticate_admin!, :only => [:list, :browse]
8 comic.author_id = current_author.id
16 respond_to do |format|
17 format.html # index.html.erb
24 @comics = Comic.find(:all,
25 :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 20
28 respond_to do |format|
29 format.html # index.html.erb
30 format.json { render json: @comics }
37 @comic = Comic.find(params[:id])
39 respond_to do |format|
40 # format.html # show.html.erb
41 format.json { render json: @comic }
46 @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
48 respond_to do |format|
49 format.html # index.html.erb
51 render :json => @comic.to_json(
52 :include => [:author, {
53 :panels => {:include => {
54 :panel_pictures => {:include => :resource_picture},
55 :balloons => {:include => :speaches}
61 render :json => "callback(" + @comic.to_json(
63 :panels => {:include => {
64 :panel_pictures => {:include => :resource_picture},
65 :balloons => {:include => :speaches}
76 respond_to do |format|
77 format.html { render layout: 'system' }# index.html.erb
78 format.json { render json: @comics }
83 @comic = Comic.find(params[:id])
85 respond_to do |format|
86 format.html { render layout: 'system' } # show.html.erb
87 format.json { render json: @comic }
92 # GET /comics/new.json
96 respond_to do |format|
97 format.html # new.html.erb
98 format.json { render json: @comic }
104 @comic = Comic.find(params[:id])
110 @comic = Comic.new(params[:comic])
113 respond_to do |format|
115 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
116 format.json { render json: @comic, status: :created, location: @comic }
118 format.html { render action: "new" }
119 format.json { render json: @comic.errors, status: :unprocessable_entity }
127 @comic = Comic.find(params[:id])
128 if @comic.own? current_author
129 respond_to do |format|
130 if @comic.update_attributes(params[:comic])
131 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
132 format.json { head :ok }
134 format.html { render action: "edit" }
135 format.json { render json: @comic.errors, status: :unprocessable_entity }
139 format.html { render action: "edit" }
140 format.json { render json: @comic.errors, status: :unprocessable_entity }
145 # DELETE /comics/1.json
147 @comic = Comic.find(params[:id])
148 if @comic.own? current_author
150 respond_to do |format|
151 format.html { redirect_to comics_url }
152 format.json { head :ok }
155 format.html { render action: "edit" }
156 format.json { render json: @comic.errors, status: :unprocessable_entity }