本文整理汇总了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;
}
}
示例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;
}
}
示例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();
}
}
示例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");
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}