witten
/
luminotes
Archived
1
0
Fork 0

Fixed a bug that caused image files to get deleted if there were multiple images embedded within a single note.

Prevented a link pulldown from auto-opening by hovering if another pulldown is already open.
This commit is contained in:
Dan Helfman 2008-06-16 16:22:50 -07:00
parent cfc1c18a55
commit f7626d985c
4 changed files with 101 additions and 3 deletions

6
NEWS
View File

@ -1,3 +1,9 @@
1.4.2: June 16, 2008:
* Fixed a bug that caused image files to get deleted if there were multiple
images embedded within a single note.
* Prevented a link pulldown from auto-opening by hovering if another
pulldown is already open.
1.4.1: June 16, 2008:
* Implemented support for embedded images within wiki notes.
* You can now open a link pulldown by simply hovering the mouse over a link

View File

@ -206,7 +206,7 @@ cherrypy._cpcgifs.FieldStorage = FieldStorage
class Files( object ):
FILE_LINK_PATTERN = re.compile( u'<a\s+href="[^"]*/files/download\?file_id=([^"&]+)(&[^"]*)?">.+</a>', re.IGNORECASE )
FILE_LINK_PATTERN = re.compile( u'<a\s+href="[^"]*/files/download\?file_id=([^"&]+)(&[^"]*)?">(<img )?[^<]+</a>', re.IGNORECASE )
"""
Controller for dealing with uploaded files, corresponding to the "/files" URL.

View File

@ -1728,6 +1728,51 @@ class Test_files( Test_controller ):
assert other_db_file is None
assert not Upload_file.exists( other_file_id )
def test_purge_unused_multiple_files( self ):
self.login()
self.http_upload(
"/files/upload?file_id=%s" % self.file_id,
dict(
notebook_id = self.notebook.object_id,
note_id = self.note.object_id,
),
filename = self.filename,
file_data = self.file_data,
content_type = self.content_type,
session_id = self.session_id,
)
self.note.contents = '<a href="/files/download?file_id=%s">file link</a>' % self.file_id
self.database.save( self.note )
other_file_id = u"23"
self.http_upload(
"/files/upload?file_id=%s" % other_file_id,
dict(
notebook_id = self.notebook.object_id,
note_id = self.note.object_id,
),
filename = u"otherfile.png",
file_data = u"whee",
content_type = self.content_type,
session_id = self.session_id,
)
# one file is linked from the note's contents but the other is not. the file that is not linked
# should be deleted
cherrypy.root.files.purge_unused( self.note )
db_file = self.database.load( File, self.file_id )
assert db_file
assert db_file.object_id == self.file_id
assert db_file.filename == self.filename
assert Upload_file.exists( self.file_id )
other_db_file = self.database.load( File, other_file_id )
assert other_db_file is None
assert not Upload_file.exists( other_file_id )
def test_purge_unused_multiple_files_with_quote_filename( self ):
self.login()
@ -1773,6 +1818,51 @@ class Test_files( Test_controller ):
assert other_db_file is None
assert not Upload_file.exists( other_file_id )
def test_purge_unused_multiple_image_files( self ):
self.login()
self.http_upload(
"/files/upload?file_id=%s" % self.file_id,
dict(
notebook_id = self.notebook.object_id,
note_id = self.note.object_id,
),
filename = self.filename,
file_data = self.file_data,
content_type = self.content_type,
session_id = self.session_id,
)
self.note.contents = '<a href="/files/download?file_id=%s"><img src="/blah"></a>' % self.file_id
self.database.save( self.note )
other_file_id = u"23"
self.http_upload(
"/files/upload?file_id=%s" % other_file_id,
dict(
notebook_id = self.notebook.object_id,
note_id = self.note.object_id,
),
filename = u"otherfile.png",
file_data = u"whee",
content_type = self.content_type,
session_id = self.session_id,
)
# one images file is linked from the note's contents but the other is not. the file that is not
# linked should be deleted
cherrypy.root.files.purge_unused( self.note )
db_file = self.database.load( File, self.file_id )
assert db_file
assert db_file.object_id == self.file_id
assert db_file.filename == self.filename
assert Upload_file.exists( self.file_id )
other_db_file = self.database.load( File, other_file_id )
assert other_db_file is None
assert not Upload_file.exists( other_file_id )
def login( self ):
result = self.http_post( "/users/login", dict(
username = self.username,

View File

@ -875,8 +875,10 @@ Wiki.prototype.editor_focused = function ( editor, synchronous ) {
}
Wiki.prototype.editor_mouse_hovered = function ( editor, target ) {
// if the mouse is hovering over a link, open a link pulldown
if ( target.nodeName == "A" )
var pulldowns = getElementsByTagAndClassName( "div", "pulldown" );
// if the mouse is hovering over a link, and no pulldowns are open, open a link pulldown
if ( target.nodeName == "A" && pulldowns.length == 0 )
this.display_link_pulldown( editor, target, true );
// the mouse is hovering over something else, so clear all ephemeral pulldowns
else