From 6c46951285c87c970897e44cc1b37afc4a9d34e6 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 22 Sep 2008 14:23:13 -0700 Subject: [PATCH] Mentioned Google Chrome. Added a link to contact info for people to vote for their browser choice. --- config/Version.py | 2 +- controller/Notebooks.py | 6 +++- controller/test/Test_notebooks.py | 55 +++++++++++++++++++++++++++++ static/html/supported browsers.html | 12 +++++-- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/config/Version.py b/config/Version.py index 1bc99e4..62e2669 100644 --- a/config/Version.py +++ b/config/Version.py @@ -1 +1 @@ -VERSION = u"1.5.0" +VERSION = u"1.5.1" diff --git a/controller/Notebooks.py b/controller/Notebooks.py index 5b8be92..07d534e 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -1760,7 +1760,11 @@ class Notebooks( object ): Plaintext contents are left mostly untouched, just stripping HTML and converting newlines to
tags. HTML contents are cleaned of any disallowed/harmful HTML tags, and target="_new" - attributes are added to all links without targets. + attributes are added to all links without targets, except internal note links. + + Internal note links are rewritten such that they point to the newly imported notes. This is + accomplished by looking for a "note_id" column and determining what note each link points out. + Then each internal note link is rewritten to point at the new notebook id and note id. @type file_id: unicode @param file_id: id of the previously uploaded CSV file to import diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py index 7f8df51..a2c7d19 100644 --- a/controller/test/Test_notebooks.py +++ b/controller/test/Test_notebooks.py @@ -1,3 +1,4 @@ +import re import cherrypy import urllib from nose.tools import raises @@ -4348,6 +4349,9 @@ class Test_notebooks( Test_controller ): self.__assert_imported_notebook( expected_notes, result ) + LINK_PATTERN = re.compile( ']*)>([^<]*)', re.IGNORECASE ) + NOTE_URL_PATTERN = re.compile( '(.*)/notebooks/([^?]+)\?note_id=(.*)', re.IGNORECASE ) + def __assert_imported_notebook( self, expected_notes, result, plaintext = True ): assert result[ u"redirect" ].startswith( u"/notebooks/" ) @@ -4381,6 +4385,23 @@ class Test_notebooks( Test_controller ): contents = contents.replace( u"\n", u"
" ) if plaintext is True or u"

" not in contents: contents = u"

%s

%s" % ( title, contents ) + if plaintext is False: + link_match = self.LINK_PATTERN.search( contents ) + + # if there's a link, make sure it is a rewritten note link or has a link target + if link_match: + ( url, attributes, title ) = link_match.groups() + + url_match = self.NOTE_URL_PATTERN.search( url ) + if url_match: + ( protocol_and_host, notebook_id, note_id ) = url_match.groups() + assert attributes == u"" + assert protocol_and_host == u"" + assert notebook_id == self.notebook.object_id + assert note_id # TODO: assert that the note id has been rewritten properly + else: + assert attributes.startswith( u'target="' ) + assert note.contents == contents # make sure the CSV data file has been deleted from the database and filesystem @@ -5037,6 +5058,40 @@ class Test_notebooks( Test_controller ): self.__assert_imported_notebook( expected_notes, result, plaintext = False ) + def test_import_csv_html_content_with_internal_note_link( self ): + self.login() + + # one of the imported notes contains a link to one of the other imported notes + note_url = "/notebooks/%s?note_id=%s" % ( self.notebook.object_id, "idthree" ) + csv_data = '"label 1","label 2","label 3","note_id",\n5,"blah and stuff","3.3  ",idone\n"8","whee","hmm\nfoo",idtwo\n3,4,5,idthree' % note_url + expected_notes = [ + ( "blah and stuff", "3.3  " ), # ( title, contents ) + ( "whee", 'hmm\nfoo' % note_url ), # TODO: expect rewritten URL instead + ( "4", "5" ), + ] + + 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 = csv_data, + content_type = self.content_type, + session_id = self.session_id, + ) + + result = self.http_post( "/notebooks/import_csv/", dict( + file_id = self.file_id, + content_column = 2, + title_column = 1, + plaintext = False, + import_button = u"import", + ), session_id = self.session_id ) + + self.__assert_imported_notebook( expected_notes, result, plaintext = False ) + def test_import_csv_without_login( self ): self.login() diff --git a/static/html/supported browsers.html b/static/html/supported browsers.html index 863f009..125342f 100644 --- a/static/html/supported browsers.html +++ b/static/html/supported browsers.html @@ -8,9 +8,6 @@ so not all browsers will work for editing your wiki. Supported browsers include:

@@ -20,7 +17,16 @@ Luminotes features, at least currently:

+ +

+Want Luminotes to support your browser? See my contact info and cast your vote. The more +people who ask me to support a certain browser, the more likely I'll add +support for that browser in an upcoming release. +

+