module View
(@@proc_table ||= {})['album_page'] = proc do
_buf = ""; _buf << "\n";
pagename='albums'
_buf << "\n";
language=nil
_buf << "
\n";
item_ctr = 0
for item in @album.breadcrumbs
item_ctr += 1
if item_ctr > 1
_buf << " ::\n";
end
item_path = item[:path] # retrieve path and
item_title = item[:title] # title from a hash
if item_path.nil? # if path is null then
_buf << (item_title).to_s; else
_buf << " \n";
_buf << (item_title).to_s; _buf << " \n";
end
end
_buf << " |
"; _buf << ERB::Util.h(@album.nr_leaves); _buf << " "; _buf << ERB::Util.h(@resource.photos); _buf << "\n";
if @album.nr_childs>0 then
_buf << " "; _buf << ERB::Util.h(@album.nr_childs); _buf << " sub-albums\n";
end
_buf << " |
"; _buf << ERB::Util.h(@album.description); _buf << "
|
\n";
if not @album.root? then
_buf << "
| \n";
end
_buf << "
|
\n";
if @album.leaves.length>0 then
_buf << "
"; _buf << ERB::Util.h(@resource.thumbnails); _buf << " |
|
\n";
end
_buf << "
\n";
if @album.leaves.length>0 then
_buf << "
\n";
start_pos = 1
while start_pos <= @album.leaves.length
idx = start_pos
_buf << " \n";
while idx <= @album.leaves.length && idx % 7 != 0
photo = @album.leaves[ idx-1 ]
_buf << "
| \n";
idx += 1
end
_buf << " \n";
idx = start_pos
_buf << " \n";
while idx <= @album.leaves.length && idx % 7 != 0
photo = @album.leaves[ idx-1 ]
_buf << "
"; _buf << ERB::Util.h(photo.name); _buf << "
| \n";
idx += 1
end
_buf << " \n";
start_pos += 7
end
_buf << "
|
\n";
end
_buf << "
\n";
if @album.childs.length>0 then
_buf << "
"; _buf << ERB::Util.h(@resource.subalbums); _buf << " |
|
\n";
end
_buf << "
\n";
if @album.childs.length>0 then
_buf << "
\n";
col = 1
for subalbum in @album.childs
if col == 1
_buf << " \n";
end
_buf << "
|
"; _buf << ERB::Util.h(subalbum.name); _buf << "
"; _buf << ERB::Util.h(subalbum.nr_leaves); _buf << " photos\n";
if subalbum.nr_childs>0 then
_buf << " , "; _buf << ERB::Util.h(subalbum.nr_childs); _buf << " sub-albums\n";
end
_buf << "
"; _buf << ERB::Util.h(subalbum.description); _buf << "
|
\n";
col += 1
if col == 3
col = 1
_buf << " \n";
end
end
if col != 1
_buf << " \n";
end
_buf << "
|
\n";
end
_buf << "
\n";
; _buf
end#proc
module_function
def expand_album_page(context={})
if context.is_a?(Hash)
hash = context
context = Object.new
hash.each { |key, val| context.instance_variable_set("@#{key}", val) }
end
proc_obj = @@proc_table['album_page']
context.instance_eval(&proc_obj)
end
end