zola
zola copied to clipboard
Add defalte filters
Add deflate filters as discussed on the forum
Sanity check:
- [X] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Code changes
(Delete or ignore this section for documentation changes)
- [X] Are you doing the PR on the
next
branch?
If the change is a new feature or adding to/changing an existing one:
- [X] Have you created/updated the relevant documentation page(s)?
I can see the need for decompressing but compressing?
Compressing is needed so that a diagram code (PlantUML, Diag, etc) could be compressed and sent to Kroki or to the PlantUML public server (see the compression section in docs). This is my primary use case for this actually :slightly_smiling_face:
Does that mean that you re-do the request on every file change in zola serve?
Yes, right now I'm using the load_data
function exactly as described in the Zola docs. This change will allow me to construct a GET request instead of POST, so it'll be the user's browser that makes requests.
An example use of this filter is like this: in .md file:
{% plantuml(comment="simple diagram") %}
participant Zola
participant Kroki
Zola -> Kroki: POST /plantuml/svg\nContent-type: text/plain\n<diagram_data>
activate Zola
Kroki -> Zola: SVG image
deactivate Zola
Zola -> Zola: embed SVG into HTML
{% end %}
Then in templates/shortcodes/plantuml.html
<figure class="image">
<img src="https://kroki.io/plantuml/svg/{{body | deflate_compress}}"/>
</figure>
Which will render into
<figure class="image">
<img src="https://kroki.io/plantuml/svg/eNpVzsEKwjAMBuB7nyIvMHYfsosHBRWFDQ8ykLiGEWzTUuPQt9daBD3-Px9_EjEpjxxRFE7BoYk_xSaFKxuTe6jaEhs47Lse6uje4u5dfZunQZZBlEQrfUZqQOmhGbAMsrCMU0J_tqjYGhyVZ1Qqxz6LeTqnBrrjCtjjRMbSP_y-UBz5C9miRQOs-932BfL4RXE="/>
</figure>
@Keats , so what do you think about this? Any chances to get it merged until the next release?
I think I need to see some more people wanting that feature before merging it.
What would be the best way to make people aware of such proposals in order to get feedback?
Rust's proposals are mentioned in the "This Week In Rust" newsletter. Maybe for Zola it will make sense to mention such things in changelogs to reach wider audience? I don't think a lot of people check PRs here or the forum.
Yeah the forum is not checked as often. Maybe create an issue on the repo, people do check those before creating a new one usually. You can point to the PR and the forum.
This feature looks interresting to me.
Where does the macro in line {% plantuml(comment="simple diagram") %}
come from?
It would be nice to adjust the image format (svg/png) and maybe the plantuml-server-url, sending the data to. In case the default will be inaccessible or if the data might be secret.
Maybe https://github.com/migmedia/planturl can be usefull.
Where does the macro in line {% plantuml(comment="simple diagram") %} come from?
It's a shortcode templates/shortcodes/plantuml.html
{% set postdata = load_data(
url="https://kroki.io/plantuml/svg",
format="plain", method="POST",
content_type="text/plain",
body=body,
required=true,
)
%}
<figure class="image">
{{ postdata | safe }}
<figcaption class="comment">
{% if comment %}
<em>{{ comment | markdown | safe }}</em>
{% endif %}
<em>Open as <a href="https://kroki.io/plantuml/png/{{body | deflate_compress}}">image</a></em>
</figcaption>
</figure>
You can easily adjust the format and server URL.
This PR adds the possibility to put diagrams in URLs like the one in Open as
above.