/** * Render an index file using the supplied content. * * @param indexFile The name of the output file * @throws Exception if IOException or SecurityException are raised */ public void renderIndex(String indexFile) throws Exception { render(new DefaultRenderingConfig(indexFile, MASTERINDEX_TEMPLATE_NAME)); }
render(renderConfig);
/** * Render an XML feed file using the supplied content. * * @param feedFile The name of the output file * @throws Exception if default rendering configuration is not loaded correctly */ public void renderFeed(String feedFile) throws Exception { render(new DefaultRenderingConfig(feedFile, FEED_TEMPLATE_NAME)); }
render(renderConfig);
/** * Render an XML sitemap file using the supplied content. * * @param sitemapFile configuration for site map * @throws Exception if can't create correct default rendering config * @see <a href="https://support.google.com/webmasters/answer/156184?hl=en&ref_topic=8476">About Sitemaps</a> * @see <a href="http://www.sitemaps.org/">Sitemap protocol</a> */ public void renderSitemap(String sitemapFile) throws Exception { render(new DefaultRenderingConfig(sitemapFile, SITEMAP_TEMPLATE_NAME)); }
/** * Render an archive file using the supplied content. * * @param archiveFile The name of the output file * @throws Exception if default rendering configuration is not loaded correctly */ public void renderArchive(String archiveFile) throws Exception { render(new DefaultRenderingConfig(archiveFile, ARCHIVE_TEMPLATE_NAME)); }
map.put(Attributes.ROOTPATH, FileUtil.getUriPathToDestinationRoot(config, path)); render(new ModelRenderingConfig(path, Attributes.TAG, model, findTemplateName(Attributes.TAG))); render(new ModelRenderingConfig(path, "tagindex", model, findTemplateName("tagsindex"))); renderedCount++; } catch (Exception e) {
renderer.render(document); renderedCount++;
@Test public void renderPage() throws Exception { // setup String filename = "about.html"; File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + filename); Map<String, Object> content = parser.processFile(sampleFile); content.put(Crawler.Attributes.URI, "/" + filename); renderer.render(content); File outputFile = new File(destinationFolder, filename); Assert.assertTrue(outputFile.exists()); // verify String output = FileUtils.readFileToString(outputFile, Charset.defaultCharset()); for (String string : getOutputStrings("page")) { assertThat(output).contains(string); } }
@Test public void renderPost() throws Exception { // setup String filename = "second-post.html"; File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + "blog" + File.separator + "2013" + File.separator + filename); Map<String, Object> content = parser.processFile(sampleFile); content.put(Crawler.Attributes.URI, "/" + filename); renderer.render(content); File outputFile = new File(destinationFolder, filename); Assert.assertTrue(outputFile.exists()); // verify String output = FileUtils.readFileToString(outputFile, Charset.defaultCharset()); for (String string : getOutputStrings("post")) { assertThat(output).contains(string); } }
/** * See issue #300 * * @throws Exception */ @Test public void testRenderFileWorksWhenPathHasDotInButFileDoesNot() throws Exception { Assume.assumeFalse("Ignore running on Windows", TestUtils.isWindows()); String FOLDER = "real.path"; final String FILENAME = "about"; config.setOutputExtension(""); config.setTemplateFolder(folder.newFolder("templates")); Renderer renderer = new Renderer(db, config, renderingEngine); Map<String, Object> content = new HashMap<>(); content.put(Crawler.Attributes.TYPE, "page"); content.put(Crawler.Attributes.URI, "/" + FOLDER + "/" + FILENAME); content.put(Crawler.Attributes.STATUS, "published"); renderer.render(content); File outputFile = new File(outputPath.getAbsolutePath() + File.separatorChar + FOLDER + File.separatorChar + FILENAME); assertThat(outputFile).isFile(); } }
@Test public void renderCustomTypePaper() throws Exception { // setup config.setTemplateFileNameForDocType("paper", "paper." + templateExtension); DocumentTypes.addDocumentType("paper"); db.updateSchema(); Crawler crawler = new Crawler(db, config); crawler.crawl(); Parser parser = new Parser(config); Renderer renderer = new Renderer(db, config); String filename = "published-paper.html"; File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + "papers" + File.separator + filename); Map<String, Object> content = parser.processFile(sampleFile); content.put(Crawler.Attributes.URI, "/" + filename); renderer.render(content); File outputFile = new File(destinationFolder, filename); Assert.assertTrue(outputFile.exists()); // verify String output = FileUtils.readFileToString(outputFile, Charset.defaultCharset()); for (String string : getOutputStrings("paper")) { assertThat(output).contains(string); } }
@Test public void shouldThrowAnExceptionWithCollectedErrorMessages() throws Exception { String fakeExceptionMessage = "fake exception"; // expect exception.expect(RenderingException.class); exception.expectMessage(fakeExceptionMessage + "\n" + fakeExceptionMessage); // given DocumentTypes.addDocumentType("customType"); DocumentList documentList = new DocumentList(); HashMap<String, Object> document = emptyDocument(); HashMap<String, Object> document2 = emptyDocument(); documentList.add(document); documentList.add(document2); // throw an exception for every call of renderer's render method doThrow(new Exception(fakeExceptionMessage)).when(renderer).render(ArgumentMatchers.<String, Object>anyMap()); when(db.getUnrenderedContent(anyString())).thenReturn(emptyDocumentList); when(db.getUnrenderedContent("customType")).thenReturn(documentList); // when int renderResponse = documentsRenderer.render(renderer, db, configuration); // then assertThat(renderResponse).isEqualTo(2); }
firstDoc.put("previousContent", null); verify(renderer, times(4)).render(argument.capture());
/** * Render an index file using the supplied content. * * @param indexFile The name of the output file * @throws Exception if IOException or SecurityException are raised */ public void renderIndex(String indexFile) throws Exception { render(new DefaultRenderingConfig(indexFile, MASTERINDEX_TEMPLATE_NAME)); }
/** * Render an archive file using the supplied content. * * @param archiveFile The name of the output file * @throws Exception if default rendering configuration is not loaded correctly */ public void renderArchive(String archiveFile) throws Exception { render(new DefaultRenderingConfig(archiveFile, ARCHIVE_TEMPLATE_NAME)); }
/** * Render an XML sitemap file using the supplied content. * * @param sitemapFile configuration for site map * @throws Exception if can't create correct default rendering config * @see <a href="https://support.google.com/webmasters/answer/156184?hl=en&ref_topic=8476">About Sitemaps</a> * @see <a href="http://www.sitemaps.org/">Sitemap protocol</a> */ public void renderSitemap(String sitemapFile) throws Exception { render(new DefaultRenderingConfig(sitemapFile, SITEMAP_TEMPLATE_NAME)); }
/** * Render an XML feed file using the supplied content. * * @param feedFile The name of the output file * @throws Exception if default rendering configuration is not loaded correctly */ public void renderFeed(String feedFile) throws Exception { render(new DefaultRenderingConfig(feedFile, FEED_TEMPLATE_NAME)); }
map.put(Attributes.ROOTPATH, FileUtil.getUriPathToDestinationRoot(config, path)); render(new ModelRenderingConfig(path, Attributes.TAG, model, findTemplateName(Attributes.TAG))); render(new ModelRenderingConfig(path, "tagindex", model, findTemplateName("tagsindex"))); renderedCount++; } catch (Exception e) {
renderer.render(document); renderedCount++;