Open jbmorley opened 3 years ago
While working on the configuration for the gallery / image handling, I knocked up the following rough ideas for configurations.
Image handler specific configuration block:
- where: glob("*") and metadata(projection="equirectangular")
transform:
- resize("large", width=1000, tags=["image"])
More generic approach, using the plugin instance as a key:
- where: glob("*") and metadata(projection="equirectangular")
import_image(category="instagram"):
- resize("large", width=1000, tags=["image"])
- resize("large", width=1000, tags=["image"])
where: glob("*") and metadata(projection="equirectangular")
transform:
large: resize(width=1000, tags=["image"])
small: resize(width=480, tags=["thumbnail"])
where: glob("*") and metadata(projection="equirectangular")
transform:
resize(width=1000, tags=["image"]) as "image"
resize(width=480, tags=["thumbnail"]) as "small"
What if we were to depart entirely from the idea of YAML for the configuration. The image handler configuration might look like this:
if metadata(projection="equirectangular") {
resize("large", width=10000, tags=["image"])
fisheye("preview-small", width=480, tags=["thumbnail", "previews"])
fisheye("preview-large", width=960, tags=["thumbnail", "previews"])
} else if glob("*.heic") or glob("*.tiff") {
resize("large", width=1000, format="image/jpeg", tags=["image"])
resize("small", width=480, format="image/jpeg", tags=["thumbnail"])
} else {
resize("large", width=1000, tags=["image"])
resize("small", width=480, tags=["thumbnail"])
}
Or, you can start to stretch the idea and imagine that the whole thing flattens out:
if glob("*.markdown") {
markdown
} else if glob("*.{jpeg,jpg,tiff,png,gif}") and metadata(projection="equirectangular") {
image {
resize("large", width=10000, tags=["image"])
fisheye("preview-small", width=480, tags=["thumbnail", "previews"])
fisheye("preview-large", width=960, tags=["thumbnail", "previews"])
}
} else if glob("*.heic") or glob("*.tiff") {
image {
resize("large", width=1000, format="image/jpeg", tags=["image"])
resize("small", width=480, format="image/jpeg", tags=["thumbnail"])
}
} else {
image {
resize("large", width=1000, tags=["image"])
resize("small", width=480, tags=["thumbnail"])
}
}
This still feels clunky, but perhaps it helps set the direction.
The configuration file currently works at the very coarse granularity of handlers, and handlers may then require their own handler-specific configuration. This can lead to inconsistencies in the way things are expressed in the configuration file.
It might be nice if we can come up with a consistent way to express the configuration for all plugins in a consistent (and perhaps flat) way.
Currently, I think plugins only actually need to do a few things, so it might be possible to do this.
Specifically, given 1-or-more input files (expressed in the settings), plugins need to be able to: