@Override public DocumentList get(ContentStore db, Map model, String key) { String tag = null; if (model.get(Crawler.Attributes.TAG) != null) { tag = model.get(Crawler.Attributes.TAG).toString(); } // fetch the tag posts from db return db.getPublishedPostsByTag(tag); }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList dl = new DocumentList(); Map<?, ?> config = (Map<?, ?>) model.get("config"); String tagPath = config.get(TAG_PATH.replace(".", "_")).toString(); for (String tag : db.getAllTags()) { Map<String, Object> newTag = new HashMap<>(); String tagName = tag; newTag.put("name", tagName); String uri = tagPath + FileUtil.URI_SEPARATOR_CHAR + tag + config.get(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; }
@Test public void crawl() { Crawler crawler = new Crawler(db, config); crawler.crawl(); Assert.assertEquals(4, db.getDocumentCount("post")); Assert.assertEquals(3, db.getDocumentCount("page")); DocumentList results = db.getPublishedPosts(); assertThat(results.size()).isEqualTo(3); for (Map<String, Object> content : results) { assertThat(content) .containsKey(Crawler.Attributes.ROOTPATH) .containsValue("../../../"); } DocumentList allPosts = db.getAllContent("post"); assertThat(allPosts.size()).isEqualTo(4); for (Map<String, Object> content : allPosts) { if (content.get(Crawler.Attributes.TITLE).equals("Draft Post")) { assertThat(content).containsKey(Crawler.Attributes.DATE); } } // covers bug #213 DocumentList publishedPostsByTag = db.getPublishedPostsByTag("blog"); Assert.assertEquals(3, publishedPostsByTag.size()); }
@Override public DocumentList get(ContentStore db, Map model, String key) { String tag = null; if (model.get(Crawler.Attributes.TAG) != null) { tag = model.get(Crawler.Attributes.TAG).toString(); } // fetch the tag posts from db return db.getPublishedPostsByTag(tag); }
@Override public DocumentList get(ContentStore db, Map model, String key) { DocumentList dl = new DocumentList(); Map<?, ?> config = (Map<?, ?>) model.get("config"); String tagPath = config.get(TAG_PATH.replace(".", "_")).toString(); for (String tag : db.getAllTags()) { Map<String, Object> newTag = new HashMap<>(); String tagName = tag; newTag.put("name", tagName); String uri = tagPath + FileUtil.URI_SEPARATOR_CHAR + tag + config.get(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; }