lib/openwfe/representations.rb
#
# generate the links for a given item
#
generate the links for a given item
generate the links for a given item
def gen_links (res, item, &block)
      if block 
        [ link('via', res), link('self', res, block.call(item)) ]
      elsif item.respond_to?(:current_page) and item.total_pages > 1
        a = [
          link('via', ''),
          link('self', res, 'page' => item.current_page)
        ]
        a << link('prev', res, 'page' => item.current_page - 1) \
          if item.current_page > 1
        a << link('next', res, 'page' => item.current_page + 1) \
          if item.current_page < item.total_pages
        a
      else 
        [ link('via', ''), link('self', res) ]
      end
    end
def gen_links ( res , item , & block ) if block [ link ( 'via' , res ) , link ( 'self' , res , block . call ( item ) ) ] elsif item . respond_to? ( :current_page ) and item . total_pages > 1 a = [ link ( 'via' , '' ) , link ( 'self' , res , 'page' => item . current_page ) ] a << link ( 'prev' , res , 'page' => item . current_page - 1 ) if item . current_page > 1 a << link ( 'next' , res , 'page' => item . current_page + 1 ) if item . current_page < item . total_pages a else [ link ( 'via' , '' ) , link ( 'self' , res ) ] end end
generate the links for a given item
generate the links for a given item
# unique element # collection
res
<not_specific>
item
<not_specific>
block
<not_specific>