def runTest(self): '''Test proper linking of files in export''' notebook = tests.new_notebook(fakedir='/source/dir/') linker = StaticLinker('html', notebook) linker.set_usebase(True) # normally set by html format module linker.set_path(Path('foo:bar')) # normally set by exporter linker.set_base(Dir('/source/dir/foo')) # normally set by exporter self.assertEqual(linker.link_page('+dus'), './bar/dus.html') self.assertEqual(linker.link_page('dus'), './dus.html') self.assertEqual(linker.link_file('./dus.pdf'), './bar/dus.pdf') self.assertEqual(linker.link_file('../dus.pdf'), './dus.pdf') self.assertEqual(linker.link_file('../../dus.pdf'), '../dus.pdf') ## setup environment for interwiki link if os.name == 'nt': uri = 'file:///C:/foo' else: uri = 'file:///foo' list = get_notebook_list() list.append(NotebookInfo(uri, interwiki='foo')) list.write() ## href = interwiki_link('foo?Ideas:Task List') self.assertIsNotNone(href) self.assertEqual(linker.link('foo?Ideas:Task List'), uri + '/Ideas/Task_List.txt')
def _link_interwiki(self, link): href = interwiki_link(link) if href and href != link: return self.link(href) # recurs else: logger.warn('No URL found for interwiki link "%s"', link) return None
def runTest(self): dir = Dir(self.get_tmp_name()) notebook = tests.new_notebook(fakedir=dir.subdir('notebook')) for name in ( 'foo', 'bar', 'foo:bar', ): p = notebook.get_page(Path(name)) p.parse('wiki', "test 123") notebook.store_page(p) layout = MultiFileLayout(dir.subdir('layout'), 'html') source = Path('foo:bar') output = layout.page_file(source) linker = ExportLinker(notebook, layout, source=source, output=output, usebase=True) self.assertEqual(linker.link('+dus'), './bar/dus.html') self.assertEqual(linker.link('dus'), './dus.html') self.assertEqual(linker.link('./dus.pdf'), './bar/dus.pdf') self.assertEqual(linker.link('../dus.pdf'), './dus.pdf') self.assertEqual(linker.link('../../dus.pdf'), '../dus.pdf') self.assertEqual(linker.link('/dus.pdf'), File('/dus.pdf').uri) # TODO: # img # icon # resource # resolve_source_file # page_object # file_object # # document_root_url ## setup environment for interwiki link if os.name == 'nt': uri = 'file:///C:/foo' else: uri = 'file:///foo' list = get_notebook_list() list.append(NotebookInfo(uri, interwiki='foo')) list.write() ## href = interwiki_link('foo?Ideas:Task List') self.assertIsNotNone(href) self.assertEqual(linker.link('foo?Ideas:Task List'), uri + '/Ideas/Task_List.txt')
def runTest(self): notebook = self.setUpNotebook(content=( 'foo', 'bar', 'foo:bar', )) dir = Dir(notebook.folder.parent().folder('layout').path) layout = MultiFileLayout(dir.subdir('layout'), 'html') source = Path('foo:bar') output = layout.page_file(source) linker = ExportLinker(notebook, layout, source=source, output=output, usebase=True) self.assertEqual(linker.link('+dus'), './bar/dus.html') self.assertEqual(linker.link('dus'), './dus.html') self.assertEqual(linker.link('./dus.pdf'), './bar/dus.pdf') self.assertEqual(linker.link('../dus.pdf'), './dus.pdf') self.assertEqual(linker.link('../../dus.pdf'), '../dus.pdf') extpath = 'C:\\dus.pdf' if os.name == 'nt' else '/duf.pdf' self.assertEqual(linker.link(extpath), FilePath(extpath).uri) # TODO: # img # icon # resource # resolve_source_file # page_object # file_object # # document_root_url ## setup environment for interwiki link if os.name == 'nt': uri = 'file:///C:/foo' else: uri = 'file:///foo' list = get_notebook_list() list.append(NotebookInfo(uri, interwiki='foo')) list.write() ## href = interwiki_link('foo?Ideas:Task List') self.assertIsNotNone(href) self.assertEqual(linker.link('foo?Ideas:Task List'), uri + '/Ideas/Task_List.txt')