当前位置: 首页>>代码示例>>Java>>正文


Java Renderer类代码示例

本文整理汇总了Java中org.jbake.app.Renderer的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Renderer类属于org.jbake.app包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
    int renderedCount = 0;
    final List<String> errors = new LinkedList<String>();
    for (String docType : DocumentTypes.getDocumentTypes()) {
        DocumentList documentList = db.getUnrenderedContent(docType);
        for (Map<String, Object> page : documentList) {
            try {
                renderer.render(page);
                renderedCount++;
            } catch (Exception e) {
                errors.add(e.getMessage());
            }
        }
    }
    if (!errors.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        sb.append("Failed to render documents. Cause(s):");
        for (String error : errors) {
            sb.append("\n").append(error);
        }
        throw new RenderingException(sb.toString());
    } else {
        return renderedCount;
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:27,代码来源:DocumentsRenderer.java

示例2: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
    if (config.getBoolean(Keys.RENDER_INDEX)) {
        try {
            if (shouldPaginateIndex(config)) {
                renderer.renderIndexPaging(config.getString(Keys.INDEX_FILE));
            } else {
                renderer.renderIndex(config.getString(Keys.INDEX_FILE));
            }
            return 1;
        } catch (Exception e) {
            throw new RenderingException(e);
        }
    } else {
        return 0;
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:18,代码来源:IndexRenderer.java

示例3: propagatesRenderingException

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test(expected = RenderingException.class)
public void propagatesRenderingException() throws Exception {
    IndexRenderer renderer = new IndexRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
    compositeConfiguration.setProperty(PAGINATE_INDEX, false);
    ContentStore contentStore = mock(ContentStore.class);
    Renderer mockRenderer = mock(Renderer.class);

    doThrow(new Exception()).when(mockRenderer).renderIndex(anyString());

    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    verify(mockRenderer, never()).renderIndex("random string");
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:17,代码来源:IndexRendererTest.java

示例4: returnsOneWhenConfigRendersIndices

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsOneWhenConfigRendersIndices() throws Exception {
    TagsRenderer renderer = new TagsRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
    ContentStore contentStore = mock(ContentStore.class);
    Renderer mockRenderer = mock(Renderer.class);

    Set<String> tags = new HashSet(Arrays.asList("tag1", "tags2"));
    when(contentStore.getTags()).thenReturn(tags);

    when(mockRenderer.renderTags("random string")).thenReturn(1);

    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    assertThat(renderResponse).isEqualTo(1);
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:19,代码来源:TagsRendererTest.java

示例5: doesRenderWhenConfigDoesNotRenderIndices

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void doesRenderWhenConfigDoesNotRenderIndices() throws Exception {
    TagsRenderer renderer = new TagsRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
    ContentStore contentStore = mock(ContentStore.class);
    Renderer mockRenderer = mock(Renderer.class);

    Set<String> tags = new HashSet(Arrays.asList("tag1", "tags2"));
    when(contentStore.getTags()).thenReturn(tags);

    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    verify(mockRenderer, times(1)).renderTags("random string");
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:17,代码来源:TagsRendererTest.java

示例6: testRenderFileWorksWhenPathHasDotInButFileDoesNot

import org.jbake.app.Renderer; //导入依赖的package包/类
/**
 * See issue #300
 * 
 * @throws Exception
 */
@Test
   public void testRenderFileWorksWhenPathHasDotInButFileDoesNot() throws Exception {
	final String FOLDER = "real.path";
	final String FILENAME = "about";
	config.setProperty(Keys.OUTPUT_EXTENSION, "");
	Renderer renderer = new Renderer(db, outputPath, folder.newFolder("templates"), config, renderingEngine);
	
	Map<String, Object> content = new HashMap<String, Object>();
	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();
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:23,代码来源:RendererTest.java

示例7: returnsOneWhenConfigRendersIndices

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsOneWhenConfigRendersIndices() throws Exception {
    TagsRenderer renderer = new TagsRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
    ContentStore contentStore = mock(ContentStore.class);
    Renderer mockRenderer = mock(Renderer.class);

    Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2"));
    when(contentStore.getTags()).thenReturn(tags);

    when(mockRenderer.renderTags("random string")).thenReturn(1);

    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    assertThat(renderResponse).isEqualTo(1);
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:19,代码来源:TagsRendererTest.java

示例8: doesRenderWhenConfigDoesNotRenderIndices

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void doesRenderWhenConfigDoesNotRenderIndices() throws Exception {
    TagsRenderer renderer = new TagsRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
    ContentStore contentStore = mock(ContentStore.class);
    Renderer mockRenderer = mock(Renderer.class);

    Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2"));
    when(contentStore.getTags()).thenReturn(tags);

    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    verify(mockRenderer, times(1)).renderTags("random string");
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:17,代码来源:TagsRendererTest.java

示例9: testRenderFileWorksWhenPathHasDotInButFileDoesNot

import org.jbake.app.Renderer; //导入依赖的package包/类
/**
 * See issue #300
 * 
 * @throws Exception
 */
@Test
   public void testRenderFileWorksWhenPathHasDotInButFileDoesNot() throws Exception {
	String FOLDER = "real.path";

	final String FILENAME = "about";
	config.setProperty(Keys.OUTPUT_EXTENSION, "");
	Renderer renderer = new Renderer(db, outputPath, folder.newFolder("templates"), config, renderingEngine);
	
	Map<String, Object> content = new HashMap<String, Object>();
	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();
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:24,代码来源:RendererTest.java

示例10: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
	if (config.getBoolean(Keys.RENDER_SITEMAP)) {
		try {
			renderer.renderSitemap(config.getString(Keys.SITEMAP_FILE));
			return 1;
		} catch (Exception e) {
			throw new RenderingException(e);
		}
	} else {
		return 0;
	}
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:14,代码来源:SitemapRenderer.java

示例11: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
	if (config.getBoolean(Keys.RENDER_ARCHIVE)) {
		try {
			renderer.renderArchive(config.getString(Keys.ARCHIVE_FILE));
			return 1;
		} catch (Exception e) {
			throw new RenderingException(e);
		}
	} else {
		return 0;
	}
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:14,代码来源:ArchiveRenderer.java

示例12: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
	if (config.getBoolean(Keys.RENDER_FEED)) {
		try {
			renderer.renderFeed(config.getString(Keys.FEED_FILE));
			return 1;
		} catch (Exception e) {
			throw new RenderingException(e);
		}
	} else {
		return 0;
	}
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:14,代码来源:FeedRenderer.java

示例13: render

import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
	if (config.getBoolean(Keys.RENDER_TAGS)) {
		try {
			return renderer.renderTags(config.getString(Keys.TAG_PATH));
		} catch (Exception e) {
			throw new RenderingException(e);
		}
	} else {
		return 0;
	}
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:13,代码来源:TagsRenderer.java

示例14: setUp

import org.jbake.app.Renderer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    documentsRenderer = new DocumentsRenderer();

    db = mock(ContentStore.class);
    renderer = mock(Renderer.class);
    configuration = mock(CompositeConfiguration.class);
    emptyDocumentList = new DocumentList();

    destinationFile = new File("fakefile");
    templatePath = new File("fakepath");
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:13,代码来源:DocumentsRendererTest.java

示例15: returnsZeroWhenConfigDoesNotRenderFeeds

import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsZeroWhenConfigDoesNotRenderFeeds() throws RenderingException {
    FeedRenderer renderer = new FeedRenderer();

    CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(false);
    ContentStore contentStore = mock(ContentStore.class);

    Renderer mockRenderer = mock(Renderer.class);
    int renderResponse = renderer.render(mockRenderer, contentStore,
            new File("fake"), new File("fake"), compositeConfiguration);

    assertThat(renderResponse).isEqualTo(0);
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:14,代码来源:FeedRendererTest.java


注:本文中的org.jbake.app.Renderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。