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


Java ContentStore类代码示例

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


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

示例1: render

import org.jbake.app.ContentStore; //导入依赖的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.ContentStore; //导入依赖的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: loadEngines

import org.jbake.app.ContentStore; //导入依赖的package包/类
/**
 * This method is used internally to load markup engines. Markup engines are found using descriptor files on
 * classpath, so adding an engine is as easy as adding a jar on classpath with the descriptor file included.
 */
private void loadEngines(final Configuration config, final ContentStore db, final File destination, final File templatesPath) {
    try {
        ClassLoader cl = TemplateEngines.class.getClassLoader();
        Enumeration<URL> resources = cl.getResources("META-INF/org.jbake.parser.TemplateEngines.properties");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            Properties props = new Properties();
            props.load(url.openStream());
            for (Map.Entry<Object, Object> entry : props.entrySet()) {
                String className = (String) entry.getKey();
                String[] extensions = ((String) entry.getValue()).split(",");
                registerEngine(config, db, destination, templatesPath, className, extensions);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:23,代码来源:TemplateEngines.java

示例4: propagatesRenderingException

import org.jbake.app.ContentStore; //导入依赖的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

示例5: returnsOneWhenConfigRendersIndices

import org.jbake.app.ContentStore; //导入依赖的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

示例6: doesRenderWhenConfigDoesNotRenderIndices

import org.jbake.app.ContentStore; //导入依赖的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

示例7: get

import org.jbake.app.ContentStore; //导入依赖的package包/类
@Override
public DocumentList get(ContentStore db, Map model, String key) {
	DocumentList dl = new DocumentList();
	Map<String, Object> config = (Map<String, Object>) model.get("config");
	
	String tagPath = config.get(Keys.TAG_PATH.replace(".", "_")).toString();
	
	for (String tag : db.getAllTags()){
		Map<String, Object> newTag = new HashMap<String, Object>();
		String tagName = tag;
		newTag.put("name",tagName);
		
		String uri = tagPath + File.separator + tag + config.get(Keys.OUTPUT_EXTENSION.replace(".", "_")).toString();
		
		newTag.put("uri", uri);
		newTag.put("tagged_posts", db.getPublishedPostsByTag(tagName));
		newTag.put("tagged_documents", db.getPublishedDocumentsByTag(tagName));
		dl.push(newTag);
	}
	return dl;
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:22,代码来源:TagsExtractor.java

示例8: returnsOneWhenConfigRendersIndices

import org.jbake.app.ContentStore; //导入依赖的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

示例9: doesRenderWhenConfigDoesNotRenderIndices

import org.jbake.app.ContentStore; //导入依赖的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

示例10: render

import org.jbake.app.ContentStore; //导入依赖的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.ContentStore; //导入依赖的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.ContentStore; //导入依赖的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.ContentStore; //导入依赖的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: registerEngine

import org.jbake.app.ContentStore; //导入依赖的package包/类
private void registerEngine(final Configuration config, final ContentStore db, final File destination, final File templatesPath, String className, String... extensions) {
    AbstractTemplateEngine engine = tryLoadEngine(config, db, destination, templatesPath, className);
    if (engine != null) {
        for (String extension : extensions) {
            registerEngine(extension, engine);
        }
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:9,代码来源:TemplateEngines.java

示例15: get

import org.jbake.app.ContentStore; //导入依赖的package包/类
@Override
public DocumentList get(ContentStore db, Map model, String key) {
    DocumentList publishedContent = new DocumentList();
    String[] documentTypes = DocumentTypes.getDocumentTypes();
    for (String docType : documentTypes) {
        DocumentList query = db.getPublishedContent(docType);
        publishedContent.addAll(query);
    }
    return publishedContent;
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:11,代码来源:PublishedContentExtractor.java


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