use of com.eden.orchid.api.resources.resource.OrchidResource in project Orchid by JavaEden.
the class WikiGenerator method setupGlossary.
private void setupGlossary() {
OrchidResource glossary = resources.getLocalResourceEntry(wikiBaseDir + "GLOSSARY.md");
if (glossary == null) {
return;
}
String content = context.getTheme().compile(glossary.getReference().getExtension(), glossary.getContent());
Document doc = Jsoup.parse(content);
for (Element h2 : doc.select("h2")) {
String id = h2.text().replaceAll("\\s+", "_").toLowerCase();
String path = wikiBaseDir + "glossary/#" + id;
String url = OrchidUtils.applyBaseUrl(context, path);
Element link = new Element("a");
link.attr("href", url);
link.text(h2.text());
h2.attr("id", id);
h2.empty();
h2.appendChild(link);
JSONObject index = new JSONObject();
index.put("name", h2.text());
index.put("url", url);
terms.add(index);
}
String safe = doc.toString();
glossary = new StringResource(context, wikiBaseDir + "glossary.md", safe);
glossary.getReference().setTitle("Glossary");
WikiPage page = new WikiPage(glossary);
page.getReference().setUsePrettyUrl(true);
page.setType("wiki");
wiki.add(page);
}
use of com.eden.orchid.api.resources.resource.OrchidResource in project Orchid by JavaEden.
the class WikiGenerator method setupSummary.
private void setupSummary() {
OrchidResource summary = resources.getLocalResourceEntry(wikiBaseDir + "SUMMARY.md");
if (summary == null) {
return;
}
String content = context.getTheme().compile(summary.getReference().getExtension(), summary.getContent());
Document doc = Jsoup.parse(content);
Elements links = doc.select("a[href]");
WikiPage previous = null;
for (Element a : links) {
String file = wikiBaseDir + a.attr("href");
String path = wikiBaseDir + FilenameUtils.removeExtension(a.attr("href"));
OrchidResource resource = resources.getLocalResourceEntry(file);
if (resource == null) {
Clog.w("Could not find wiki resource page at '#{$1}'", new Object[] { file });
resource = new StringResource(context, path + File.separator + "index.md", a.text());
}
WikiPage page = new WikiPage(resource);
if (!EdenUtils.isEmpty(FilenameUtils.getExtension(a.attr("href")))) {
page.getReference().setUsePrettyUrl(true);
} else {
page.getReference().setUsePrettyUrl(true);
}
page.getReference().setTitle(a.text());
page.setType("wiki");
wiki.add(page);
if (previous != null) {
previous.setNext(page);
page.setPrevious(previous);
previous = page;
} else {
previous = page;
}
a.attr("href", page.getReference().toString());
}
String safe = doc.toString();
summary = new StringResource(context, wikiBaseDir + "summary.md", safe);
summary.getReference().setTitle("Summary");
WikiPage page = new WikiPage(summary);
page.getReference().setUsePrettyUrl(true);
page.setType("wiki");
wiki.add(page);
}
use of com.eden.orchid.api.resources.resource.OrchidResource in project Orchid by JavaEden.
the class LocalResourceSource method getResourceEntries.
@Override
public List<OrchidResource> getResourceEntries(String path, String[] fileExtensions, boolean recursive) {
List<OrchidResource> entries = new ArrayList<>();
String fullPath = getDirectory() + "/" + path;
File file = new File(fullPath);
if (file.exists() && file.isDirectory()) {
Collection newFiles = FileUtils.listFiles(file, fileExtensions, recursive);
if (!EdenUtils.isEmpty(newFiles)) {
for (Object object : newFiles) {
File newFile = (File) object;
if (shouldAddEntry(newFile.getName())) {
FileResource entry = new FileResource(context, newFile);
entry.setPriority(getPriority());
entries.add(entry);
}
}
}
}
return entries;
}
use of com.eden.orchid.api.resources.resource.OrchidResource in project Orchid by JavaEden.
the class AssetsGenerator method startIndexing.
@Override
public List<? extends OrchidPage> startIndexing() {
List<OrchidResource> resourcesList = resources.getResourceEntries("assets", null, true);
List<OrchidPage> assets = new ArrayList<>();
for (OrchidResource entry : resourcesList) {
// entry.getReference().setBasePath("assets");
assets.add(new OrchidPage(entry));
}
return assets;
}
Aggregations