witten
/
luminotes
Archived
1
0
Fork 0

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:
Dan Helfman 2007-11-10 01:46:56 +00:00
parent 6bc242395c
commit 44a1cb79c2
5 changed files with 36 additions and 4 deletions

View File

@ -723,6 +723,8 @@ class Notebooks( object ):
result = self.__users.current( user_id ) result = self.__users.current( user_id )
result.update( self.contents( notebook_id, user_id = 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 return result

View File

@ -118,7 +118,7 @@ class Root( object ):
count = Valid_int( min = 1, max = 50 ), count = Valid_int( min = 1, max = 50 ),
user_id = Valid_id( none_okay = True ), 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 Provide the information necessary to display the blog notebook with notes in reverse
chronological order. chronological order.

View File

@ -1673,6 +1673,8 @@ class Test_notebooks( Test_controller ):
assert result.get( u"parent_id" ) == None assert result.get( u"parent_id" ) == None
assert result.get( u"note_read_write" ) in ( None, True ) 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 ) user = self.database.load( User, self.user.object_id )
assert user.storage_bytes == 0 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"parent_id" ) == None
assert result.get( u"note_read_write" ) in ( None, True ) 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 ) user = self.database.load( User, self.user.object_id )
assert user.storage_bytes == 0 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"parent_id" ) == None
assert result.get( u"note_read_write" ) in ( None, True ) 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 ) user = self.database.load( User, self.user.object_id )
assert user.storage_bytes == 0 assert user.storage_bytes == 0

View File

@ -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 ( select id, min( revision ) as revision from note where notebook_id = %s group by id ) as note_creation
where where
notebook_id = %s and note_current.id = note_creation.id notebook_id = %s and note_current.id = note_creation.id
order by
creation desc
offset %d limit %d; offset %d limit %d;
""" % ( quote( self.object_id ), quote( self.object_id ), start, count ) """ % ( quote( self.object_id ), quote( self.object_id ), start, count )

View File

@ -23,6 +23,8 @@ class Main_page( Page ):
total_notes_count = None, total_notes_count = None,
notes = None, notes = None,
note_read_write = True, note_read_write = True,
start = None,
count = None,
): ):
startup_note_ids = [ startup_note.object_id for startup_note in startup_notes ] startup_note_ids = [ startup_note.object_id for startup_note in startup_notes ]
@ -62,6 +64,15 @@ class Main_page( Page ):
else: else:
title = None 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__( Page.__init__(
self, self,
title, title,
@ -102,8 +113,8 @@ class Main_page( Page ):
), ),
Rounded_div( Rounded_div(
( notebook.name == u"trash" ) and u"trash_notebook" or u"current_notebook", ( notebook.name == u"trash" ) and u"trash_notebook" or u"current_notebook",
( len( notes ) > 0 and notebook.name != u"Luminotes" ) and \ ( len( notes ) > 0 ) and \
A( Strong( notebook.name ), href = u"/notebooks/%s" % notebook.object_id ) \ A( Strong( notebook.name ), href = notebook_path ) \
or Strong( notebook.name ), or Strong( notebook.name ),
parent_id and Span( parent_id and Span(
u" | ", u" | ",
@ -134,6 +145,17 @@ class Main_page( Page ):
u"document.getElementById( 'static_notes' ).style.display = 'none';", u"document.getElementById( 'static_notes' ).style.display = 'none';",
type = u"text/javascript", 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", id = u"notebook_background",
corners = ( u"tl", ), corners = ( u"tl", ),
), ),