Module: Hybook::AlbumHelper
- Included in:
- Hybook
- Defined in:
- lib/hybook/std/album.rb
Instance Method Summary collapse
- #render_album(album, opts) ⇒ Object
- #render_picture(pic, opts) ⇒ Object
- #render_pictures(pics, opts) ⇒ Object
Instance Method Details
#render_album(album, opts) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/hybook/std/album.rb', line 47 def render_album( album, opts ) ### ## TODO/FIX: ## use TextUtils::PageTemplate.read( path ).render( binding ) - one line tmpl = File.read_utf8( "#{Hybook.templates_path}/album.md" ) TextUtils::PageTemplate.new( tmpl ).render( binding ) end |
#render_picture(pic, opts) ⇒ Object
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 |
# File 'lib/hybook/std/album.rb', line 19 def render_picture( pic, opts ) size = opts[:size] assets_path = opts[:assets_path] || 'vendor/assets/images/logos' ## puts "[picture] size=#{size}" # NOTE: opts[:size] required for now!!! ## puts "[picture] assets_path=#{assets_path}" ## ## puts "opts:" ## pp opts extname = File.extname( pic.path ) basename_in = File.basename( pic.path, extname ) # NB: remove extname (that is, suffix e.g. .png,.jpg,.gif etc.) # strip leading 1-west- (optional for organizing logos) # e.g. 3-west-austrias becomes austrias basename_out = basename_in.gsub( /[0-9a-z]+-/, '' ) ## puts "path: #{path}, basename_in: #{basename_in}, basename_out: #{basename_out}, extname: #{extname}" path = "#{assets_path}/#{size}x#{size}/#{basename_out}.png" buf = '' buf << "_#{pic.title}_{: .key} " buf << "![#{pic.title}](#{path})" buf end |
#render_pictures(pics, opts) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hybook/std/album.rb', line 6 def render_pictures( pics, opts ) buf = '' ### sort by title for now pics.sort { |l,r| l.title <=> r.title }.each_with_index do |pic,i| buf << ' • ' if i > 0 buf << render_picture( pic, opts ) end buf end |