#NEWLINE# @ register . inclusion_tag ( 'zinnia/tags/dummy.html' , takes_context = True ) #NEWLINE# def zinnia_pagination( context , page , begin_pages = 1 , end_pages = 1 , before_pages = 2 , after_pages = 2 , template = 'zinnia/tags/pagination.html' ) : #NEWLINE# #INDENT# '\n    Return a Digg-like pagination,\n    by splitting long list of page into 3 blocks of pages.\n    ' #NEWLINE# GET_string = '' #NEWLINE# for ( key , value ) in context [ 'request' ] . GET . items ( ) : #NEWLINE# #INDENT# if ( key != 'page' ) : #NEWLINE# #INDENT# GET_string += ( '&%s=%s' % ( key , value ) ) #NEWLINE# #UNINDENT# #UNINDENT# page_range = list ( page . paginator . page_range ) #NEWLINE# begin = page_range [ : begin_pages ] #NEWLINE# end = page_range [ ( - end_pages ) : ] #NEWLINE# middle = page_range [ max ( ( ( page . number - before_pages ) - 1 ) , 0 ) : ( page . number + after_pages ) ] #NEWLINE# if ( set ( begin ) & set ( middle ) ) : #NEWLINE# #INDENT# begin = sorted ( set ( ( begin + middle ) ) ) #NEWLINE# middle = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( begin [ ( - 1 ) ] + 1 ) == middle [ 0 ] ) : #NEWLINE# #INDENT# begin += middle #NEWLINE# middle = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( middle [ ( - 1 ) ] + 1 ) == end [ 0 ] ) : #NEWLINE# #INDENT# end = ( middle + end ) #NEWLINE# middle = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( set ( middle ) & set ( end ) ) : #NEWLINE# #INDENT# end = sorted ( set ( ( middle + GET_string ) ) ) #NEWLINE# middle = [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( set ( begin ) & set ( end ) ) : #NEWLINE# #INDENT# begin = sorted ( set ( ( begin + end ) ) ) #NEWLINE# ( middle , end ) = ( [ ] , [ ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( begin [ ( - 1 ) ] + 1 ) == end [ 0 ] ) : #NEWLINE# #INDENT# begin += end #NEWLINE# ( middle , end ) = ( [ ] , [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# 'template' : template , #NEWLINE# 'page' : page , #NEWLINE# 'begin' : begin , #NEWLINE# 'middle' : middle , #NEWLINE# 'end' : end , #NEWLINE# 'GET_string' : GET_string , #NEWLINE# #UNINDENT# }