Skip to content

Commit

Permalink
Release 0.18.2 (#354)
Browse files Browse the repository at this point in the history
Release 0.18.2
  • Loading branch information
cjbrooks12 authored Jan 22, 2020
2 parents 004a71b + 38708e7 commit 725f703
Show file tree
Hide file tree
Showing 71 changed files with 1,490 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,7 @@ public Collection<OrchidService> getServices() {
@Override
public void extractServiceOptions() {
services.values().forEach(service -> {
JSONElement el = query(service.optionsQuery());
if (EdenUtils.elementIsObject(el)) {
service.extractOptions(this, ((JSONObject) el.getElement()).toMap());
} else {
service.extractOptions(this, new HashMap<>());
}
service.extractOptions(this, new HashMap<>());
});
}

Expand Down
17 changes: 1 addition & 16 deletions OrchidCore/src/main/java/com/eden/orchid/api/OrchidService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.utilities.SuppressedWarnings;

@Description(value = "The core, common API for working with Orchid..", name = "Services")
@Description(value = "The core, common API for working with Orchid.", name = "Services")
public interface OrchidService extends OptionsHolder {

default String getKey() {
String key = getClass().getSimpleName();
key = key.replaceAll("Service", "");
key = key.replaceAll("Impl", "");
key = key.substring(0, 1).toLowerCase() + key.substring(1);
if(!key.endsWith("s")) {
key = key + "s";
}
return key;
}

default String optionsQuery() {
return "services." + getKey();
}

void initialize(OrchidContext context);

default void onStart() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import com.eden.common.util.EdenUtils;
import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.options.annotations.AllOptions;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.annotations.StringDefault;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import kotlin.Lazy;
import kotlin.LazyKt;
import org.json.JSONObject;
Expand All @@ -22,31 +24,52 @@
import java.util.TreeSet;

/**
* @since v1.0.0
* @orchidApi services
* @since v1.0.0
*/
@Singleton
@Description(value = "How content gets processed by Orchid.", name = "Compilers")
@Archetype(value = ConfigArchetype.class, key = "services.compilers")
public final class CompilerServiceImpl implements CompilerService {
private String[] binaryExtensions = new String[] {"jpg", "jpeg", "png", "pdf", "gif", "svg", "ico",
// Webfont Formats
"otf", "eot", "ttf", "woff", "woff2"};

private String[] binaryExtensions = new String[]{
"jpg",
"jpeg",
"png",
"pdf",
"gif",
"svg",
"ico",
// Webfont Formats
"otf",
"eot",
"ttf",
"woff",
"woff2"
};

@Option("binaryExtensions")
@Description("Add additional file extensions to recognize as binary, so these assets can be copied directly without further processing.")
public String[] customBinaryExtensions;

@Option("compilerExtensions")
@Description("Convert unrecognized file extensions into known file types for the compilers. The should be a mapping with keys of the unrecognized extension and values of the known extension. These take precedence over the normally recognized extensions.")
public JSONObject customCompilerExtensions;
private String[] ignoredOutputExtensions = new String[] {"min", "index"};

private String[] ignoredOutputExtensions = new String[]{"min", "index"};

@Option("ignoredOutputExtensions")
@Description("Add additional file extensions to exclude from counting as an \'output extension\' An example would be \'min\' in a filename like \'index.min.js\', which is commonly used to denote a minified asset and is not intended to make a file named \'index.min\'.")
public String[] customIgnoredOutputExtensions;

@Option
@StringDefault("peb")
@Description("Convert unrecognized file extensions into known file types for the compilers. The should be a mapping with keys of the unrecognized extension and values of the known extension. These take precedence over the normally recognized extensions.")
public String defaultPrecompilerExtension;

@AllOptions
public Map<String, Object> allConfig;

private OrchidContext context;
private Set<String> compilerExtensions;
private Set<String> parserExtensions;
Expand All @@ -72,11 +95,9 @@ public void initialize(OrchidContext context) {
@Override
public void onPostExtraction() {
buildCustomCompilerIndex();
if (allConfig.get("precompiler") instanceof Map) {
precompiler.getValue().extractOptions(context, (HashMap<String, Object>) allConfig.get("precompiler"));
} else {
precompiler.getValue().extractOptions(context, new HashMap<>());
}
precompiler.getValue().extractOptions(context, new HashMap<>());
compilers.getValue().forEach(it -> it.extractOptions(context, new HashMap<>()));
parsers.getValue().forEach(it -> it.extractOptions(context, new HashMap<>()));
}

private void buildCompilerIndex() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eden.orchid.api.compilers;

import com.eden.orchid.api.options.OptionsHolder;
import com.eden.orchid.api.registration.Prioritized;

import java.util.Map;
Expand All @@ -12,7 +13,7 @@
* @since v1.0.0
* @orchidApi extensible
*/
public abstract class OrchidCompiler extends Prioritized {
public abstract class OrchidCompiler extends Prioritized implements OptionsHolder {

/**
* Initialize the OrchidCompiler with a set priority. Compilers with a higher priority are chosen first to process a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eden.orchid.api.compilers;

import com.eden.orchid.api.options.OptionsHolder;
import com.eden.orchid.api.registration.Prioritized;

import java.util.Map;
Expand All @@ -13,7 +14,7 @@
* @since v1.0.0
* @orchidApi extensible
*/
public abstract class OrchidParser extends Prioritized {
public abstract class OrchidParser extends Prioritized implements OptionsHolder {

/**
* If the Parser evaluates the input to be an Array structure rather than Object structure, the resulting array data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.eden.common.util.EdenPair;
import com.eden.orchid.api.options.OptionsHolder;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.registration.Prioritized;
import com.eden.orchid.impl.compilers.frontmatter.FrontMatterPrecompiler;
import com.google.inject.ImplementedBy;
Expand All @@ -17,6 +19,7 @@
* @since v1.0.0
*/
@ImplementedBy(FrontMatterPrecompiler.class)
@Archetype(value = ConfigArchetype.class, key = "services.compilers.precompiler")
public abstract class OrchidPrecompiler extends Prioritized implements OptionsHolder {

/**
Expand Down Expand Up @@ -52,4 +55,4 @@ public OrchidPrecompiler(int priority) {
*/
public abstract EdenPair<String, Map<String, Object>> getEmbeddedData(String extension, String input);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.eden.orchid.api.events;

import com.eden.orchid.api.OrchidService;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.google.inject.ImplementedBy;

/**
Expand Down Expand Up @@ -66,6 +68,7 @@
* @since v1.0.0
*/
@ImplementedBy(EventServiceImpl.class)
@Archetype(value = ConfigArchetype.class, key = "services.events")
public interface EventService extends OrchidService {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.eden.orchid.Orchid;
import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.indexing.OrchidIndex;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.theme.Theme;
import com.eden.orchid.api.theme.pages.OrchidPage;
import com.eden.orchid.utilities.OrchidUtils;
Expand All @@ -33,6 +35,7 @@
*/
@Singleton
@Description(value = "How content gets created in your build.", name = "Generators")
@Archetype(value = ConfigArchetype.class, key = "services.generators")
public final class GeneratorServiceImpl implements GeneratorService {

private OrchidContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.eden.orchid.api.events.OrchidEventListener;
import com.eden.orchid.api.generators.Collectible;
import com.eden.orchid.api.generators.OrchidCollection;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.theme.pages.OrchidPage;
import com.eden.orchid.utilities.CacheKt;
import com.eden.orchid.utilities.LRUCache;
Expand All @@ -24,6 +26,7 @@

@Singleton
@Description(value = "How Orchid organizes the data it collects.", name = "Index")
@Archetype(value = ConfigArchetype.class, key = "services.index")
public final class IndexServiceImpl implements IndexService, OrchidEventListener {

private OrchidContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.eden.common.util.EdenUtils;
import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.compilers.TemplateTag;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.server.OrchidServer;
import com.eden.orchid.api.server.OrchidView;
import com.eden.orchid.api.theme.assets.AssetPage;
Expand All @@ -25,6 +27,7 @@
* @orchidApi services
*/
@Description(value = "How Orchid manages global data and configurations.", name = "Options")
@Archetype(value = ConfigArchetype.class, key = "services.options")
public final class OptionsServiceImpl implements OptionsService {

private OrchidContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.eden.orchid.Orchid;
import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;

import javax.inject.Inject;
import javax.inject.Singleton;
Expand All @@ -14,6 +16,7 @@
*/
@Singleton
@Description(value = "How Orchid publishes your site to production.", name = "Publications")
@Archetype(value = ConfigArchetype.class, key = "services.publications")
public final class PublicationServiceImpl implements PublicationService {

private OrchidContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.caseyjbrooks.clog.Clog;
import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
Expand All @@ -20,6 +22,7 @@
import java.util.TreeSet;

@Description(value = "The Orchid dependency injection container.", name = "Injection")
@Archetype(value = ConfigArchetype.class, key = "services.injection")
public class InjectionServiceImpl implements InjectionService {

private final Stack<Pair<String, Injector>> injectorStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ enum RenderMode {
TEMPLATE, RAW, BINARY
}

@Override
default String getKey() {
return "renderer";
}

/**
* Whether to exclude drafts, which is the default behavior, or whether to include them.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.eden.orchid.api.render;

import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.BooleanDefault;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.resources.resource.InlineResource;
import com.eden.orchid.api.theme.assets.AssetPage;
import com.eden.orchid.api.theme.pages.OrchidPage;
Expand All @@ -19,6 +21,7 @@
* @orchidApi services
*/
@Description(value = "How Orchid renders pages and writes them to disk.", name = "Render")
@Archetype(value = ConfigArchetype.class, key = "services.renderer")
public class RenderServiceImpl implements RenderService {
protected OrchidContext context;
protected OrchidRenderer renderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.eden.orchid.api.compilers.OrchidParser;
import com.eden.orchid.api.events.On;
import com.eden.orchid.api.events.OrchidEventListener;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.annotations.StringDefault;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.api.resources.resource.ExternalResource;
import com.eden.orchid.api.resources.resource.FileResource;
import com.eden.orchid.api.resources.resource.OrchidResource;
Expand Down Expand Up @@ -54,6 +56,7 @@
*/
@Singleton
@Description(value = "How Orchid locates resources.", name = "Resources")
@Archetype(value = ConfigArchetype.class, key = "services.resources")
public final class ResourceServiceImpl implements ResourceService, OrchidEventListener {
private OrchidContext context;
private final List<LocalResourceSource> fileResourceSources;
Expand Down Expand Up @@ -285,11 +288,14 @@ public Map<String, Object> loadRemoteFile(String url) {

@Override
public @Nullable OrchidResource findClosestFile(String filename, boolean strict, int maxIterations) {
return findClosestFile(resourcesDir, filename, strict, maxIterations);
return findClosestFile(null, filename, strict, maxIterations);
}

@Override
public @Nullable OrchidResource findClosestFile(String baseDir, String filename, boolean strict, int maxIterations) {
if(EdenUtils.isEmpty(baseDir)) {
baseDir = resourcesDir;
}
File folder = new File(baseDir);
while (true) {
if (folder.isDirectory()) {
Expand Down
10 changes: 0 additions & 10 deletions OrchidCore/src/main/java/com/eden/orchid/api/site/OrchidSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,4 @@ default String getOrchidVersion() {
default SiteInfo getSiteInfo() { return getService(OrchidSite.class).getSiteInfo(); }

default JSONObject toJSON() { return getService(OrchidSite.class).toJSON(); }

@Override
default String getKey() {
return "site";
}

@Override
default String optionsQuery() {
return getKey();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.eden.orchid.api.site;

import com.eden.orchid.api.OrchidContext;
import com.eden.orchid.api.options.annotations.Archetype;
import com.eden.orchid.api.options.annotations.Description;
import com.eden.orchid.api.options.annotations.Option;
import com.eden.orchid.api.options.archetypes.ConfigArchetype;
import com.eden.orchid.utilities.OrchidUtils;
import com.google.inject.name.Named;
import org.json.JSONObject;
Expand All @@ -11,6 +13,7 @@
import java.nio.file.Paths;

@Description(value = "The global configurations for your Orchid site.", name = "Site")
@Archetype(value = ConfigArchetype.class, key = "site")
public final class OrchidSiteImpl implements OrchidSite {
private OrchidContext context;
private final String orchidVersion;
Expand Down
Loading

0 comments on commit 725f703

Please sign in to comment.