-
Notifications
You must be signed in to change notification settings - Fork 26
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
Links to images are absolute -> does not work in docker #32
Comments
you need to set |
plugin.py need some change self._site_url = config.get("site_url", "/") # find this line
# I added the following 2 lines of code
if self._site_url is None:
self._site_url = "/" |
I set it to |
Unfortunately, this does not work, as the |
your pull request will fix this issue. 😄 |
Relative URLs would be preferable. |
The same issue happens if you try to open the site as a file ( a significant issue if you're trying to automatically generate pdfs from the pages, like me ) |
DownloadImages: True
DownloadDir: images
def _download_dir(self):
return Path(self._tmp_dir.name)
def _save_kroki_image_and_get_url(self, file_name, image_data, files, page): # <-------
downloadPath = self._download_dir() / page.url / Path(self.config["DownloadDir"]) # <-------
filepath = downloadPath / file_name # <-------
os.makedirs(downloadPath ,exist_ok = True) # <-------
with open(filepath, 'wb') as file:
file.write(image_data)
get_url = relpath(filepath, self._tmp_dir.name)
mkdocs_file = File(get_url, self._tmp_dir.name, self._output_dir, False)
files.append(mkdocs_file)
return Path(self.config["DownloadDir"]) / file_name # <------- use real relative path
def _replace_kroki_block(self, match_obj, files, page):
....
if image_data:
file_name = self._kroki_filename(kroki_data, kroki_type, page)
get_url = self._save_kroki_image_and_get_url(file_name, image_data, files, page) # <------- |
First of all, thanks ALL for the great collaboration! I would prefer a solution that always works (without a configuration option like in #33 ). Feedback from others are welcome: |
Thank you @oniboni : I have tested the module on your PR branch (PR #46) and this works perfectly to resolve this issue. site_url: ""
# [..]
plugins:
# [..]
- kroki:
HttpMethod: GET
DownloadImages: True However, one thing I wasn't sure about, you mention in your PR that you deprecate the
If my test is correct this would mean a breaking change instead of deprecating. |
@jortkoopmans The Any suggestions? |
The ideal status of the config option would be: abandoned but not removed (yet) for backward compatibility. But this status currently does not exist it seems. It seems there is no way to truly remove the config option without raising the validation error. This line I think Alternatively, not removing the option and just deprecating with a |
I use the
DownloadImages
feature to serve static content. I'm using mkdocs inside a docker container and therefor runmkdocs serve -a 0.0.0.0:8000
.Unfortunately, the links to the generated diagrams point to
http://0.0.0.0:8000/images/kroki_generated/...
Is it possible to use relative paths for the images?
I'm using
mkdocs-kroki-plugin==0.6.1
The text was updated successfully, but these errors were encountered: