-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
two steps to have images end up correctly in _site #59
Comments
Is it because those images are being generated? |
note, this is in context of using |
I think asciidoctor/asciidoctor-diagram#110 and asciidoctor/asciidoctor-diagram#85 shows the issue too. |
And yes, this is for generated images like asciidoctor-diagram. |
It seems the core issue is that asciidoc-diagram are not told the actual output path adn cannot generate a relative path to it. Things works fine if all docs are in the root of the repo, but when using sub-folders the images are now no longer in the right location. |
example https://github.com/ALMighty/almighty-devdoc which was based on jekyll-asciidoc quickstart but have nested folders to make it really clear. boarding a plane now - bbl ;) |
And while on plane I remembered this issue I have hit before. asciidoctor/asciidoctor-diagram#39 So i'm still not sure how to actually best handle this. Seems to be an inherent problem that extensions can't know the relative position they are supposed to generate to. |
Following the recommendations in asciidoctor/asciidoctor-diagram#39 I added this to my
thinking that could make it generate directly into |
Tried: gives no output at all.. Tried ends up in _site/../diagrams. This is definitely following a logic I can currently figure out ;) |
And finally - it seems when jekyll-asciidoc runs it does not actually set any of the to_dir/out_dir/etc. values so asciidoc-diagram have no chance to read them. |
in asciidoctor/asciidoctor-diagram#39 its said tools like maven/gradle should set outsdir. Should jekyll integration not do the same for each doc/page being generated ? |
Adding this hack to get the doc folder https://github.com/ALMighty/almighty-devdoc/blob/master/_plugins/asciidoc.rb#L25 combined with passing that information to Asciidoctor https://github.com/ALMighty/almighty-devdoc/blob/master/_plugins/asciidoc.rb#L79 seems to do the trick. No imagesdir needed to be set in the Doc itself, but Jekyll is still required to run twice to get the images copied to _site/ |
The Jekyll required to run twice issue is 'simply' because on run 1: Setting imagesoutdir to _site/#{page.dir} when doing the convert call fix this, as it will output directly to the destination folder. But this trigger another interesting problem: Jekyll's internal lifecycle is: read, generate, render, clean, write I'm currently working around that by monkey patching Jekyll to not clean _site at all. |
So the two last pieces of research to get Asciidoctor-Diagram to work with Jekyll Rake plugins as well can be seen here: fabric8-services/fabric8-devdoc@75a5113 Need to set Asciidoctor in UNSAFE mode to write outside of the doc root due to Jekyll rake plugin setting --destination /tmp/xxxx and only setting outdir in Asciidoctor Jekyll to avoid relative image link issue in html output when splitting outdir into 'target root folder' and image-dir. |
I have now overhauled the plugin in preparation to address this issue. I'm now ready for it. I've already implemented the (Jekyll 3-only) hooks @aslakknutsen uses in ALMighty, so the stage is set. Now I just need to understand what options/attributes I need to assign. Will report back. |
This one roasted my brain a bit, but I think I have a couple of strategies that are going to work. Thanks @aslakknutsen for your critical research. That saved me a lot of time...esp the heads up about the site cleaner. If we set the outdir attribute correctly when invoking Asciidoctor, then Asciidoctor Diagram actually does the right thing. We'll be able to support the option of a single images folder for all pages or an images folder per collection/nested folder. I'll provide more details when I have the PR ready to push. |
Btw, I think you can avoid the cleanup monkeypatch by setting the keep_files config setting to all files. keep_files: [images] Unfortunately, it only works for a known directory or file, so you can't just say keep everything. |
- set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir
- set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
- set site-related attributes * site-root * site-source * site-destination, * site-baseurl * site-url - set site, implict and default attributes in front of user-defined attributes - set outdir/outfile attributes so extensions know where to write files - automatically configure imagesoutdir if imagesdir starts with / and imagesoutdir is not set - set docfile attribute in addition to docdir - only set docdir if base_dir is :docdir - add tests for docfile, outfile and outdir - include spec_helper using require_relative - update documentation
I'm happy to report that this issue is finally resolved and will be part of the upcoming 2.0.0 release! Information about the new configuration options can be found in the README. See https://github.com/asciidoctor/jekyll-asciidoc#generated-image-location The simplest configuration is as follows: asciidoctor:
base_dir: :docdir
safe: :unsafe
attributes:
- imagesdir=/images In this case, the imagesoutdir is automatically configured since the imagesdir is relative to the site root. Alternatively, you may specify the imagesoutdir explicitly: asciidoctor:
base_dir: :docdir
safe: :unsafe
attributes:
- imagesdir=/images
- imagesoutdir={site-destination}/images In both cases, all images end up (and are expected to be in) a single folder. If you want images to be relative to the document, then set the imagesdir to a relative path. asciidoctor:
base_dir: :docdir
safe: :unsafe
attributes:
- imagesdir=images Of course, if you use a trailing I have sent a pull request to almighty-devdoc with these changes. In the PR, the first example from above is enabled. The rest are in comments. |
Excellent! Thank you @mojavelinux |
@aslakknutsen Thank you for sharing your fork/prototype. That proved to be very useful while implementing this change and catching some other aspects I had previously missed. |
for now I have to do
bundle exec jekyll build && bundle exec rake deploy
to have the_site
have the actual images.This works for deployment but using jekyll watch becomes quite annoying since the images are not linked up correctly.
is there a better way ?
The text was updated successfully, but these errors were encountered: