mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
allow globs in config file paths
The configuration parser will have to be changed again because YAML does not support asterisks in its key names.
This commit is contained in:
parent
49813d0c68
commit
fdca530591
5 changed files with 86 additions and 22 deletions
31
README.md
31
README.md
|
|
@ -65,9 +65,20 @@ A file called `index.gmi` will always take precedence over a directory listing.
|
|||
|
||||
### Meta-Presets
|
||||
|
||||
You can put a file called `.meta` in a directory. This file stores some metadata about these files which Agate will use when serving these files. The file should be UTF-8 encoded. Like the `.directory-listing-ok` file, this file does not have an effect on sub-directories. (*1)
|
||||
This file is parsed as a YAML file and should contain a "hash" datatype with file names as the keys. This means:
|
||||
Lines starting with a `#` are comments and will be ignored like empty lines. All other lines must start with a file name, followed by a colon and a space and then the metadata.
|
||||
You can put a file called `.meta` in any content directory. This file stores some metadata about the adjacent files which Agate will use when serving these files. The `.meta` file must be UTF-8 encoded.
|
||||
You can also enable a central configuration file with the `-C` flag (or the long version `--central-conf`). In this case Agate will always look for the `.meta` configuration file in the content root directory and will ignore `.meta` files in other directories.
|
||||
|
||||
The `.meta` file is parsed as a YAML file and should contain a "hash" datatype with file names as the keys. This means:
|
||||
* Lines starting with a `#` are comments and will be ignored, as will empty lines.
|
||||
* All other lines must have the form `<path>: <metadata`, i.e. start with a file path, followed by a colon and a space and then the metadata.
|
||||
|
||||
`<path>` is a case sensitive file path, which may or may not exist on disk. If <path> leads to a directory, it is ignored.
|
||||
If central configuration file mode is not used, using a path that is not a file in the current directory is undefined behaviour (for example: `../index.gmi` would be undefined behaviour).
|
||||
You can use Unix style patterns in existing paths. For example `content/*` will match any file within `content`, and `content/**` will additionally match any files in subdirectories of `content`.
|
||||
However, the `*` and `**` globs on their own will by default not match files or directories that start with a dot because of their special meaning (see Directory listing).
|
||||
This behaviour can be disabled with `--serve-secret` or by explicitly matching files starting with a dot with e.g. `content/.*` or `content/**/.*` respectively.
|
||||
For more information on the patterns you can use, please see the [documentation of `glob::Pattern`](https://https://docs.rs/glob/0.3.0/glob/struct.Pattern.html).
|
||||
Rules can overwrite other rules, so if a file is matched by multiple rules, the last one applies.
|
||||
|
||||
The metadata can take one of four possible forms:
|
||||
1. empty
|
||||
|
|
@ -85,14 +96,21 @@ If a line violates the format or looks like case 3, but is incorrect, it might b
|
|||
Such a configuration file might look like this:
|
||||
```text
|
||||
# This line will be ignored.
|
||||
**.de.gmi: ;lang=de
|
||||
nl/**.gmi: ;lang=nl
|
||||
index.gmi: ;lang=en-UK
|
||||
LICENSE: text/plain;charset=UTF-8
|
||||
gone.gmi: 52 This file is no longer here, sorry.
|
||||
```
|
||||
|
||||
You can enable a central configuration file with the `-C` flag (or the long version `--central-conf`). In this case Agate will always look for the `.meta` configuration file in the content root directory and will ignore `.meta` files in other directories.
|
||||
|
||||
(*1) It is *theoretically* possible to specify information on files which are in sub-directories. The problem would only be to make sure that this file is loaded before the respective path/file is requested. This is because Agate does not actively check that the "no sub-directories" regulation is met. In fact this might be dropped in a change of configuration format in the foreseeable future.
|
||||
If this is the `.meta` file in the content root directory and the `-C' flag is used, this will result in the following:
|
||||
requested filename|response header
|
||||
---|---
|
||||
`/ ` or `/index.gmi`|`20 text/gemini;lang=en-UK`
|
||||
`/LICENSE`|`20 text/plain;charset=UTF-8`
|
||||
`/gone.gmi`|`52 This file is no longer here, sorry.`
|
||||
any non-hidden file ending in `.de.gmi` (including in non-hidden subdirectories)|`20 text/gemini;lang=de`
|
||||
any non-hidden file in the `nl` directory ending in `.gmi` (including in non-hidden subdirectories)|`20 text/gemini;lang=nl`
|
||||
|
||||
### Logging Verbosity
|
||||
|
||||
|
|
@ -109,7 +127,6 @@ If you want to serve the same content for multiple domains, you can instead disa
|
|||
[Gemini]: https://gemini.circumlunar.space/
|
||||
[Rust]: https://www.rust-lang.org/
|
||||
[home]: gemini://gem.limpet.net/agate/
|
||||
[rustup]: https://www.rust-lang.org/tools/install
|
||||
[source]: https://github.com/mbrubeck/agate
|
||||
[crates.io]: https://crates.io/crates/agate
|
||||
[documentation of `env_logger`]: https://docs.rs/env_logger/0.8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue