Added basic multipage navigation to blog.
Made name of notebook link at the top of the page better for "special" Luminotes notebooks.
This commit is contained in:
parent
6bc242395c
commit
44a1cb79c2
|
@ -723,6 +723,8 @@ class Notebooks( object ):
|
|||
|
||||
result = self.__users.current( user_id )
|
||||
result.update( self.contents( notebook_id, user_id = user_id ) )
|
||||
result[ u"notes" ] = recent_notes
|
||||
result[ "notes" ] = recent_notes
|
||||
result[ "start" ] = start
|
||||
result[ "count" ] = count
|
||||
|
||||
return result
|
||||
|
|
|
@ -118,7 +118,7 @@ class Root( object ):
|
|||
count = Valid_int( min = 1, max = 50 ),
|
||||
user_id = Valid_id( none_okay = True ),
|
||||
)
|
||||
def blog( self, start = 0, count = 10, user_id = None ):
|
||||
def blog( self, start = 0, count = 3, user_id = None ):
|
||||
"""
|
||||
Provide the information necessary to display the blog notebook with notes in reverse
|
||||
chronological order.
|
||||
|
|
|
@ -1673,6 +1673,8 @@ class Test_notebooks( Test_controller ):
|
|||
|
||||
assert result.get( u"parent_id" ) == None
|
||||
assert result.get( u"note_read_write" ) in ( None, True )
|
||||
assert result.get( u"start" ) == 0
|
||||
assert result.get( u"count" ) == 10
|
||||
|
||||
user = self.database.load( User, self.user.object_id )
|
||||
assert user.storage_bytes == 0
|
||||
|
@ -1700,6 +1702,8 @@ class Test_notebooks( Test_controller ):
|
|||
|
||||
assert result.get( u"parent_id" ) == None
|
||||
assert result.get( u"note_read_write" ) in ( None, True )
|
||||
assert result.get( u"start" ) == 1
|
||||
assert result.get( u"count" ) == 10
|
||||
|
||||
user = self.database.load( User, self.user.object_id )
|
||||
assert user.storage_bytes == 0
|
||||
|
@ -1727,6 +1731,8 @@ class Test_notebooks( Test_controller ):
|
|||
|
||||
assert result.get( u"parent_id" ) == None
|
||||
assert result.get( u"note_read_write" ) in ( None, True )
|
||||
assert result.get( u"start" ) == 0
|
||||
assert result.get( u"count" ) == 1
|
||||
|
||||
user = self.database.load( User, self.user.object_id )
|
||||
assert user.storage_bytes == 0
|
||||
|
|
|
@ -117,6 +117,8 @@ class Notebook( Persistent ):
|
|||
( select id, min( revision ) as revision from note where notebook_id = %s group by id ) as note_creation
|
||||
where
|
||||
notebook_id = %s and note_current.id = note_creation.id
|
||||
order by
|
||||
creation desc
|
||||
offset %d limit %d;
|
||||
""" % ( quote( self.object_id ), quote( self.object_id ), start, count )
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ class Main_page( Page ):
|
|||
total_notes_count = None,
|
||||
notes = None,
|
||||
note_read_write = True,
|
||||
start = None,
|
||||
count = None,
|
||||
):
|
||||
startup_note_ids = [ startup_note.object_id for startup_note in startup_notes ]
|
||||
|
||||
|
@ -62,6 +64,15 @@ class Main_page( Page ):
|
|||
else:
|
||||
title = None
|
||||
|
||||
if notebook.name == u"Luminotes":
|
||||
notebook_path = u"/"
|
||||
elif notebook.name == u"Luminotes user guide":
|
||||
notebook_path = u"/guide"
|
||||
elif notebook.name == u"Luminotes blog":
|
||||
notebook_path = u"/blog"
|
||||
else:
|
||||
notebook_path = u"/notebooks/%s" % notebook.object_id
|
||||
|
||||
Page.__init__(
|
||||
self,
|
||||
title,
|
||||
|
@ -102,8 +113,8 @@ class Main_page( Page ):
|
|||
),
|
||||
Rounded_div(
|
||||
( notebook.name == u"trash" ) and u"trash_notebook" or u"current_notebook",
|
||||
( len( notes ) > 0 and notebook.name != u"Luminotes" ) and \
|
||||
A( Strong( notebook.name ), href = u"/notebooks/%s" % notebook.object_id ) \
|
||||
( len( notes ) > 0 ) and \
|
||||
A( Strong( notebook.name ), href = notebook_path ) \
|
||||
or Strong( notebook.name ),
|
||||
parent_id and Span(
|
||||
u" | ",
|
||||
|
@ -134,6 +145,17 @@ class Main_page( Page ):
|
|||
u"document.getElementById( 'static_notes' ).style.display = 'none';",
|
||||
type = u"text/javascript",
|
||||
),
|
||||
# make page navigation for those notebooks that require it (such as the blog)
|
||||
( start is not None and count is not None ) and Div(
|
||||
( start > 0 ) and Div( A(
|
||||
u"previous page",
|
||||
href = "%s?start=%d&count=%d" % ( notebook_path, max( start - count, 0 ), count ),
|
||||
) ) or None,
|
||||
( start + count < total_notes_count ) and Div( A(
|
||||
u"next_page",
|
||||
href = "%s?start=%d&count=%d" % ( notebook_path, min( start + count, total_notes_count - 1 ), count ),
|
||||
) ) or None,
|
||||
) or None,
|
||||
id = u"notebook_background",
|
||||
corners = ( u"tl", ),
|
||||
),
|
||||
|
|
Reference in New Issue