18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/galleries_controller.rb', line 18
def show
@gallery = Gallery.find_by_permalink(params[:id])
raise ActiveRecord::RecordNotFound if @gallery.nil?
unless @gallery.status
redirect_to galleries_url
else
@breadcrumb = @gallery
@tags = @gallery.tag_counts
@sub_content = @gallery.children.paginate_by_status(true,
:order => 'created_at ASC, id ASC',
:page => params[:page],
:per_page => this_webapp.,
:total_entries => (@gallery.nb_content))
if @sub_content.size < this_webapp..to_i
params[:page] = 1 if params[:page].nil?
page = params[:page].to_i - (@sub_content.size / this_webapp..to_i)
per_page = this_webapp..to_i - @sub_content.size
if @sub_content.empty?
@sub_content.replace(@sub_content +
@gallery.pictures.paginate_by_status(true,
:order => 'created_at ASC, id ASC',
:page => (page),
:per_page => per_page,
:shift => @gallery.diff_paginate))
else
@sub_content.replace(@sub_content +
@gallery.pictures.paginate_by_status(true,
:order => 'created_at ASC, id ASC',
:page => page,
:per_page => per_page))
end
end
respond_to do |format|
format.html
format.xml { render :xml => @gallery }
format.atom
end
end
rescue ActiveRecord::RecordNotFound
render :status => 404
end
|