Open salbeira opened 1 year ago
This should work now. Please check in your particular setting.
Also, paths are now only adjusted if the referenced file actually exists. All other values are left untouched.
This works for simple path lists but not complex objects.
If I want something like
author: Author
data Author: string | {
name: string
url: string
affiliation: Affiliation
}
data Affiliation = string | {
name: string
url: string
logo: string
}
and I declare
compiletime-path-variable:
- author.affiliation.logo
Then it immediatly breaks on any Author that is a string, saying it can not access the attribute affiliation of the author string.
Also this may be again a case of "what lists get merged how" but this is the result of my test deck:
project-test-variable is a runtime-path-variable defined in decker.yaml
local-test-variable is a runtime-path-variable defined in the frontmatter of the -deck.md
unused is defined but not in the runtime-path-variable list
the one that is really confounding me is why the project variable of all places is the one not getting resolved
Hm, I cannot reproduce this. Have look at this slide http://localhost:8888/test/decks/meta-resources-deck.html#/runtime-path-variables.
runtime-path-variables
is properly merged from three different sources: decker.yaml
, default.yaml
and the document meta.
This works for simple path lists but not complex objects.
If I want something like
author: Author data Author: string | { name: string url: string affiliation: Affiliation } data Affiliation = string | { name: string url: string logo: string }
and I declare
compiletime-path-variable: - author.affiliation.logo
Then it immediatly breaks on any Author that is a string, saying it can not access the attribute affiliation of the author string.
Please provide a complete example deck that fails and the concrete error message it fails with.
For my test image: Branch runtime-variable-test
, file test/decks/subdirectory/runtime-variable-deck.md
, relevant values for the runtime-path-variables are in both decker.yaml as well as the test deck.
For the described error: Branch template-improvements
, compiletime-path-variables defined in resource/decker/template/default.yaml
, the error is:
Error when running Shake build system:
at want, called at app\Decker.hs:91:3 in main:Decker
* Depends on: html
at need, called at app\Decker.hs:53:3 in main:Decker
* Depends on: public/test/decks/author-page.html
* Raised the exception:
Cannot adjust meta value on non object at: "affiliation.logo"
This looks to me that runtime-path-variables from default.yaml are not merged into the list - I put a "print me all runtime-path-variables" in front of the adjustMetaVariables and made a stack clean
, make clean
, stack run -- --server -j1
and got this output.
After a lot of debugging I can confirm that either way (both building and running from built executable or running stack run --
in the decker repo) I am unable to make the runtime-path-variables appear from inside the default.yaml . Adding them to the deck works at least though so I can confirm: path resolution for logos
and affilation.logo
works but resolution from inside a list of objects (authors.affiliation.logo
where authors
is a list of objects) simply resolves into "true" for the whole authors
subtree of metadata.
Have a look at test/decks/meta-resources-deck.md
, slide #/runtime-path-variables
.
Current value
: [:meta](runtime-path-variables)
resolves correctly to:
Current value
rpv-test.leaf-path, rpv-test.leaf-no-path, rpv-test.branch, one.from.decker.yaml, one.more.from.doc.meta
with the following definitions:
decker.yaml
runtime-path-variables:
- one.from.decker.yaml
resource/decker/template/default.yaml
runtime-path-variables:
- rpv-test.leaf-path
- rpv-test.leaf-no-path
- rpv-test.branch
test/decks/meta-resources-deck.md
runtime-path-variables:
- one.more.from.doc.meta
Can you reproduce that?
I finally found my error: I had my runtime-path-variable declaration at the top of the default.yaml and the merge silently put your rpv-test at the bottom of the file where I never bothered to look, so everything I placed into the list got overwritten.
The adjustment of the paths works for single object paths (logos
, affiliation.logo
, author.affiliation.logo
) but the issue of lists being replaced by "true" remains (authors.affiliation.logo
) - I can simply use authors
but that would semantically mean eventually some value in that list will be interpreted as a path where it shouldn't.
The adjustment of the paths works for single object paths (
logos
,affiliation.logo
,author.affiliation.logo
) but the issue of lists being replaced by "true" remains (authors.affiliation.logo
) - I can simply useauthors
but that would semantically mean eventually some value in that list will be interpreted as a path where it shouldn't.
Please point me to a deck where whatever this is fails, and tell me what you actually want to happen. I need to see (and be able to compile) the metedata definitions, the template code and the deck source. All that in a small example would be nice.
This is still in branch template-improvements
test-deck title-header-deck.md
. Resource Pack with defined runtime-path-variables
is the default decker one.
What I want to happen: in the list of authors, have every author's affiliation's logo be path variables (paths resolved relative to current file).
What happens: authors are resolved to "true" with authors.affiliation.logo
inside realtime-path-variables
.
@monofon One more thing:
I put a file from the support directory into a path-variable (logos
) in the template-improvements
branch tudo
pack:
File: default.yaml
logos:
- /support/assets/tu-logo-light.svg
The value of this file does not get adjusted and I think before your "more admissable" change to the path variable resolution it also got declared as "not found" in every case. Is there something I am doing wrong here?
Postponed until after the next milestone.
This will be solved together with #109.
I might not fully understand when and how the paths of runtime-path-variables are evaluated but I did add a branch with a dedicated test where variables get added to the runtime-path-variables list in different locations.
The results depend on where the variable was added to the list: Doing it locally inside a deck causes the build system to fail, reporting they are unable to find the file inside the runtime-path-variable.
In my actual project where I wanted to add files both inside the support directory of the resource pack and the local project directory the project directory items are reported as missing:
default.yaml:
decker.yaml: