diff --git a/NEWS b/NEWS index 3a73ab9..4e86718 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +1.4.4: June 17, 2008: + * Links to embedded images now show up within the note tree's list of links. + * Links to files that have not yet been uploaded (or have been deleted) are + now excluded from the note tree's list of links. + 1.4.3: June 16, 2008: * Fixed a bug in which an image thumbnail could not be loaded unless you had a valid session. This prevented thumbnails from showing up diff --git a/controller/Notebooks.py b/controller/Notebooks.py index 02cf2df..9db711d 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -25,8 +25,9 @@ from view.Update_link_page import Update_link_page class Notebooks( object ): WHITESPACE_PATTERN = re.compile( u"\s+" ) - LINK_PATTERN = re.compile( u']+\s)?href="([^"]+)"(?:\s+target="([^"]*)")?[^>]*)>([^<]+)', re.IGNORECASE ) + LINK_PATTERN = re.compile( u']+\s)?href="([^"]+)"(?:\s+target="([^"]*)")?[^>]*)>(]+>)?([^<]*)', re.IGNORECASE ) FILE_PATTERN = re.compile( u'/files/' ) + NEW_FILE_PATTERN = re.compile( u'/files/new' ) """ Controller for dealing with notebooks and their notes, corresponding to the "/notebooks" URL. @@ -585,7 +586,7 @@ class Notebooks( object ): items = [] for match in self.LINK_PATTERN.finditer( note.contents ): - ( attributes, href, target, title ) = match.groups() + ( attributes, href, target, embedded_image, title ) = match.groups() # if it has a link target, it's a link to an external web site if target: @@ -594,7 +595,10 @@ class Notebooks( object ): # if it has '/files/' in its path, it's an uploaded file link if self.FILE_PATTERN.search( href ): - items.append( Note_tree_area.make_item( title, attributes, u"note_tree_file_link", target = u"_new" ) ) + if not self.NEW_FILE_PATTERN.search( href ): # ignore files that haven't been uploaded yet + if embedded_image: + title = u"embedded image" + items.append( Note_tree_area.make_item( title, attributes, u"note_tree_file_link", target = u"_new" ) ) continue # if it has a note_id, load that child note and see whether it has any children of its own diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py index ca934d3..4028b2f 100644 --- a/controller/test/Test_notebooks.py +++ b/controller/test/Test_notebooks.py @@ -1353,6 +1353,40 @@ class Test_notebooks( Test_controller ): assert link % u' target="_new" class="note_tree_file_link"' in html assert u"tree_expander_empty" in html + def test_load_note_links_with_embedded_image_file_link( self ): + self.login() + + link = u'' + self.note.contents = u"

blah

this is a %s" % ( link % "" ) + self.database.save( self.note ) + + result = self.http_post( "/notebooks/load_note_links/", dict( + notebook_id = self.notebook.object_id, + note_id = self.note.object_id, + ), session_id = self.session_id ) + + html = result.get( "tree_html" ) + assert u"embedded image' in html + assert u"tree_expander_empty" in html + + def test_load_note_links_with_new_file_link( self ): + self.login() + + link = u'link to new file' + self.note.contents = u"

blah

this is a %s" % ( link % "" ) + self.database.save( self.note ) + + result = self.http_post( "/notebooks/load_note_links/", dict( + notebook_id = self.notebook.object_id, + note_id = self.note.object_id, + ), session_id = self.session_id ) + + html = result.get( "tree_html" ) + assert u"