Leading/trailing spaces in note titles are now ignored when making links to such notes.
This commit is contained in:
parent
d62fa9f95a
commit
f2b88441ee
5
NEWS
5
NEWS
|
@ -1,3 +1,8 @@
|
||||||
|
1.5.2:
|
||||||
|
* Leading/trailing spaces in note titles are now ignored when making links
|
||||||
|
to such notes. This means that creating a link titled "my note" to a note
|
||||||
|
called "my note " now works properly.
|
||||||
|
|
||||||
1.5.1: September 28, 2008
|
1.5.1: September 28, 2008
|
||||||
* Implemented CSV exporting, so now you can export all of your notes to a
|
* Implemented CSV exporting, so now you can export all of your notes to a
|
||||||
CSV spreadsheet file. This currently doesn't include revision history or
|
CSV spreadsheet file. This currently doesn't include revision history or
|
||||||
|
|
|
@ -25,13 +25,17 @@ class Html_nuker( HTMLParser ):
|
||||||
|
|
||||||
def handle_entityref( self, ref ):
|
def handle_entityref( self, ref ):
|
||||||
if self.allow_refs:
|
if self.allow_refs:
|
||||||
self.result.append( "&%s;" % ref )
|
if ref == "nbsp":
|
||||||
|
self.result.append( " " )
|
||||||
|
else:
|
||||||
|
self.result.append( "&%s;" % ref )
|
||||||
else:
|
else:
|
||||||
self.result.append( {
|
self.result.append( {
|
||||||
"amp": "&",
|
"amp": "&",
|
||||||
"lt": "<",
|
"lt": "<",
|
||||||
"gt": ">",
|
"gt": ">",
|
||||||
"quot": '"',
|
"quot": '"',
|
||||||
|
"nbsp": " ",
|
||||||
}.get ( ref, "" ) )
|
}.get ( ref, "" ) )
|
||||||
|
|
||||||
def handle_comment( self, comment ):
|
def handle_comment( self, comment ):
|
||||||
|
@ -60,4 +64,6 @@ class Html_nuker( HTMLParser ):
|
||||||
self.result = []
|
self.result = []
|
||||||
self.feed( rawstring )
|
self.feed( rawstring )
|
||||||
|
|
||||||
return u"".join( self.result )
|
result = u"".join( self.result ).strip()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
|
@ -462,7 +462,7 @@ class Notebooks( object ):
|
||||||
return note
|
return note
|
||||||
|
|
||||||
# remove all HTML from the contents and also remove the title
|
# remove all HTML from the contents and also remove the title
|
||||||
summary = Html_nuker().nuke( note.contents ).strip()
|
summary = Html_nuker().nuke( note.contents )
|
||||||
if note.title and summary.startswith( note.title ):
|
if note.title and summary.startswith( note.title ):
|
||||||
summary = summary[ len( note.title ) : ]
|
summary = summary[ len( note.title ) : ]
|
||||||
|
|
||||||
|
|
|
@ -1204,6 +1204,22 @@ class Test_notebooks( Test_controller ):
|
||||||
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
|
||||||
|
|
||||||
|
def test_load_note_by_title_with_trailing_whitespace( self ):
|
||||||
|
self.login()
|
||||||
|
|
||||||
|
result = self.http_post( "/notebooks/load_note_by_title/", dict(
|
||||||
|
notebook_id = self.notebook.object_id,
|
||||||
|
note_title = "%s " % self.note.title,
|
||||||
|
), session_id = self.session_id )
|
||||||
|
|
||||||
|
note = result[ "note" ]
|
||||||
|
|
||||||
|
assert note.object_id == self.note.object_id
|
||||||
|
assert note.title == self.note.title
|
||||||
|
assert note.contents == self.note.contents
|
||||||
|
user = self.database.load( User, self.user.object_id )
|
||||||
|
assert user.storage_bytes == 0
|
||||||
|
|
||||||
def test_load_note_by_title_case_insensitive( self ):
|
def test_load_note_by_title_case_insensitive( self ):
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
|
@ -4711,7 +4727,7 @@ class Test_notebooks( Test_controller ):
|
||||||
|
|
||||||
self.__assert_imported_notebook( expected_notes, result )
|
self.__assert_imported_notebook( expected_notes, result )
|
||||||
|
|
||||||
def test_import_csv_html_title( self ):
|
def test_import_csv_html_in_plaintext_title( self ):
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
csv_data = '"label 1","label 2","label 3"\n5,"blah <i>and</i> stuff<br />",3.3\n"8","whee<p>","hmm\nfoo"\n3,4,5'
|
csv_data = '"label 1","label 2","label 3"\n5,"blah <i>and</i> stuff<br />",3.3\n"8","whee<p>","hmm\nfoo"\n3,4,5'
|
||||||
|
@ -5040,7 +5056,7 @@ class Test_notebooks( Test_controller ):
|
||||||
csv_data = '"label 1","label 2","label 3"\n5,"<i>blah</i> and stuff",3.3\n"8","wh ee","hmm\nfoo"\n3,4,5'
|
csv_data = '"label 1","label 2","label 3"\n5,"<i>blah</i> and stuff",3.3\n"8","wh ee","hmm\nfoo"\n3,4,5'
|
||||||
expected_notes = [
|
expected_notes = [
|
||||||
( "blah and stuff", "3.3" ), # ( title, contents )
|
( "blah and stuff", "3.3" ), # ( title, contents )
|
||||||
( "wh ee", "hmm\nfoo" ),
|
( "wh ee", "hmm\nfoo" ),
|
||||||
( "4", "5" ),
|
( "4", "5" ),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5103,7 +5119,7 @@ class Test_notebooks( Test_controller ):
|
||||||
|
|
||||||
csv_data = '"label 1","label 2","label 3"\n5,"blah and stuff","3.<b>3 </b>"\n"8","whee","hmm\n<i>foo</i>"\n3,4,5'
|
csv_data = '"label 1","label 2","label 3"\n5,"blah and stuff","3.<b>3 </b>"\n"8","whee","hmm\n<i>foo</i>"\n3,4,5'
|
||||||
expected_notes = [
|
expected_notes = [
|
||||||
( "3.3 ", "3.<b>3 </b>" ), # ( title, contents )
|
( "3.3", "3.<b>3 </b>" ), # ( title, contents )
|
||||||
( "hmm", "hmm\n<i>foo</i>" ),
|
( "hmm", "hmm\n<i>foo</i>" ),
|
||||||
( "5", "5" ),
|
( "5", "5" ),
|
||||||
]
|
]
|
||||||
|
|
|
@ -49,6 +49,60 @@ class Test_note( object ):
|
||||||
assert self.note.user_id == self.user_id
|
assert self.note.user_id == self.user_id
|
||||||
assert self.note.creation == self.creation
|
assert self.note.creation == self.creation
|
||||||
|
|
||||||
|
def test_set_contents_with_title_with_trailing_whitespace( self ):
|
||||||
|
new_title = u"new title"
|
||||||
|
new_contents = u"<h3>%s </h3>new blah" % new_title
|
||||||
|
previous_revision = self.note.revision
|
||||||
|
|
||||||
|
self.note.contents = new_contents
|
||||||
|
|
||||||
|
assert self.note.revision > previous_revision
|
||||||
|
assert self.note.contents == new_contents
|
||||||
|
assert self.note.summary == None
|
||||||
|
assert self.note.title == new_title
|
||||||
|
assert self.note.notebook_id == self.notebook_id
|
||||||
|
assert self.note.startup == self.startup
|
||||||
|
assert self.note.deleted_from_id == None
|
||||||
|
assert self.note.rank == self.rank
|
||||||
|
assert self.note.user_id == self.user_id
|
||||||
|
assert self.note.creation == self.creation
|
||||||
|
|
||||||
|
def test_set_contents_with_title_with_trailing_nbsp( self ):
|
||||||
|
new_title = u"new title"
|
||||||
|
new_contents = u"<h3>%s </h3>new blah" % new_title
|
||||||
|
previous_revision = self.note.revision
|
||||||
|
|
||||||
|
self.note.contents = new_contents
|
||||||
|
|
||||||
|
assert self.note.revision > previous_revision
|
||||||
|
assert self.note.contents == new_contents
|
||||||
|
assert self.note.summary == None
|
||||||
|
assert self.note.title == new_title
|
||||||
|
assert self.note.notebook_id == self.notebook_id
|
||||||
|
assert self.note.startup == self.startup
|
||||||
|
assert self.note.deleted_from_id == None
|
||||||
|
assert self.note.rank == self.rank
|
||||||
|
assert self.note.user_id == self.user_id
|
||||||
|
assert self.note.creation == self.creation
|
||||||
|
|
||||||
|
def test_set_contents_with_title_with_internal_nbsp( self ):
|
||||||
|
new_title = u"new title"
|
||||||
|
new_contents = u"<h3>%s</h3>new blah" % new_title
|
||||||
|
previous_revision = self.note.revision
|
||||||
|
|
||||||
|
self.note.contents = new_contents
|
||||||
|
|
||||||
|
assert self.note.revision > previous_revision
|
||||||
|
assert self.note.contents == new_contents
|
||||||
|
assert self.note.summary == None
|
||||||
|
assert self.note.title == u"new title"
|
||||||
|
assert self.note.notebook_id == self.notebook_id
|
||||||
|
assert self.note.startup == self.startup
|
||||||
|
assert self.note.deleted_from_id == None
|
||||||
|
assert self.note.rank == self.rank
|
||||||
|
assert self.note.user_id == self.user_id
|
||||||
|
assert self.note.creation == self.creation
|
||||||
|
|
||||||
def test_set_contents_with_html_title( self ):
|
def test_set_contents_with_html_title( self ):
|
||||||
new_title = u"new title"
|
new_title = u"new title"
|
||||||
new_contents = u"<h3>new<br /> title</h3>new blah"
|
new_contents = u"<h3>new<br /> title</h3>new blah"
|
||||||
|
|
Reference in New Issue