witten
/
luminotes
Archived
1
0
Fork 0

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.
This commit is contained in:
Dan Helfman 2008-06-17 20:25:44 -07:00
parent 9bbed27d73
commit eaf45f5599
3 changed files with 46 additions and 3 deletions

5
NEWS
View File

@ -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

View File

@ -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'<a\s+((?:[^>]+\s)?href="([^"]+)"(?:\s+target="([^"]*)")?[^>]*)>([^<]+)</a>', re.IGNORECASE )
LINK_PATTERN = re.compile( u'<a\s+((?:[^>]+\s)?href="([^"]+)"(?:\s+target="([^"]*)")?[^>]*)>(<img [^>]+>)?([^<]*)</a>', 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

View File

@ -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'<a href="../../files/fileid?blah"%s><img src="/blah"></a>'
self.note.contents = u"<h3>blah</h3> 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"<table"
assert u'<a href="../../files/fileid?blah" target="_new" class="note_tree_file_link">embedded image</a>' in html
assert u"tree_expander_empty" in html
def test_load_note_links_with_new_file_link( self ):
self.login()
link = u'<a href="../../files/new"%s>link to new file</a>'
self.note.contents = u"<h3>blah</h3> 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"<table"
assert link % u' target="_new" class="note_tree_file_link"' not in html
assert u"tree_expander_empty" not in html
def test_load_note_links_with_note_link( self ):
self.login()