class ComicsController < ApplicationController
- before_filter :authenticate_author!, :except => [:index, :show, :play]
+ before_filter :authenticate_author!, :only => [:top, :index, :show, :play, :create, :update, :destroy]
+ before_filter :authenticate_admin!, :only => [:list, :browse]
private
public
def top
+ @comics = Comic.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ end
end
# GET /comics
# GET /comics.json
def index
- @comics = Comic.all
+ @comics = Comic.find(:all,
+ :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 20
+ )
respond_to do |format|
format.html # index.html.erb
@comic = Comic.find(params[:id])
respond_to do |format|
- format.html # show.html.erb
+# format.html # show.html.erb
format.json { render json: @comic }
end
end
def play
- @comic = Comic.find(params[:id], include: {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}, order: 'panels.t')
+ @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
respond_to do |format|
format.html # index.html.erb
format.json {
render :json => @comic.to_json(
- :include => {
+ :include => [:author, {
:panels => {:include => {
:panel_pictures => {:include => :resource_picture},
:balloons => {:include => :speaches}
}}
- }
+ }]
)
}
format.jsonp {
end
end
+ def list
+ @comics = Comic.all
+
+ respond_to do |format|
+ format.html { render layout: 'system' }# index.html.erb
+ format.json { render json: @comics }
+ end
+ end
+
+ def browse
+ @comic = Comic.find(params[:id])
+
+ respond_to do |format|
+ format.html { render layout: 'system' } # show.html.erb
+ format.json { render json: @comic }
+ end
+ end
+
# GET /comics/new
# GET /comics/new.json
def new