-
Notifications
You must be signed in to change notification settings - Fork 109
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
Add Cacoo support #43
Conversation
No objections to merging this. The only thing I'm wondering is how incremental rendering of the asciidoc document should work for this type of diagram. At the moment asciidoctor-diagram only recreates images when the source code changes. In this case the source code is the diagram id, but that doesn't change when the diagram is updated on the web site. We could query the update timestamp via the cacoo api but that means an additional roundtrip to the server for each image. Alternatively we could just shortcut the conditional image rendering in this case, but that's a bit wasteful on bandwidth (and perhaps server processing work). Any thoughts on how you would like this to behave? |
In general, I like the idea of providing more options. However, I'm not sure how I feel yet about integrating proprietary services directly into Asciidoctor Diagram core. I think this is a case where we should draw the line and introduce a dedicated gem. The gem could depend on Asciidoctor Diagram, so you could still load it with a single commandline flag. But it allows these service integration to have their own space. It's really not that difficult to setup and publish a new gem, so we're not talking about a lot of extra work. I propose the name of the gem to be:
As a side note, I think we should do the memegenerator.net integration using a similar separation. As for the cache question, I think for now we should simply require that the .cache file be deleted to force an update. We could also consider performing an "update to date" check either at a fixed interval (1 hour, 1 day, etc) or a flag to force update to date checks. Something like |
memegenerator integration + deck.js backend makes for some nice slide decks :) Agreed on drawing the line at integrating proprietary web services; that makes sense. That means I'm going to have to start thinking about public API, semantic versioning, etc... Life's so simple when you're the only API user. So are you proposing to have an asciidoctor-diagram-cacoo gem under the asciidoctor umbrella or is this something @hnakamur should do instead? |
Hell yeah! You can find the discussion about it in the asciidoctor-extensions-lab project: asciidoctor/asciidoctor-extensions-lab#8 |
I think all new projects should incubate in the creators own namespace, then we migrate them into Asciidoctor when we get buy-in from the group. This gives equal opportunity to all and allows the group to be part of the process. |
Thank you all for comments. I created https://github.com/hnakamur/asciidoctor-diagram-cacoo As for image cache, I would like to write like:
and let asciidoctor-diagram-cacoo create cacoo-${my_cacoo_diagram_id_here}.png and cacoo-${my_cacoo_diagram_id_here}.png.cache. Could you tell me how can I get the filename "cacoo-${my_cacoo_diagram_id_here}" above? After that, I would like to create a rake task to delete the outdated image cache files using |
I read the asciidoctor-diagram source code and found the target filename is set to a local variable at:
However,
Can we modify the line like the below?
With this change, I can write like
instead of
The former way is much better since I do not have to repeat the cacoo diagram ID both in the target filename and in the source code. |
You can go even more concise by using the block macro syntax. That could take the form
in this syntax the bit between In order to support this I think I'm going to need to add some additional hooks in the diagram base class. One of the things I'm thinking of exposing is a method that you can override that determines the target filename. The default would be the current behavior (value of |
Thanks for considering those changes. It would be nice if the logic that checks images are outdated will be run once before each image generation code will be called. Since I would like to decrease Cacoo API call roundtrips, it would be nice that I can use https://cacoo.com/lang/en/api_diagrams API just once and check each Cacoo image in the document is outdated. I am looking forward to see those changes. Thanks! |
@hnakamur I've made some progress on defining a proper API that you can use. Could you have a look at https://github.com/pepijnve/asciidoctor-diagram/tree/afbc882cef8fbdc06f2504196c5fbac903800a37 to see if this is turning out to be usable for you. |
@pepijnve Thanks a lot for the update of asciidoctor-diagram and my Cacoo implementation! I also created the example project at https://github.com/hnakamur/asciidoctor-diagram-cacoo-example Right now, it does not check images are up to date. I will work on that form now. Can I ask you a question? I had to add the code section like below between two
In this way, CacooBlockProcessor#create_source is called. However, when I tried an example without the code like:
I suppose CacooBlockMacroProcessor#create_source will be called, but actually it was not called and no images were created. One more thing. I looked the generated source code at http://hnakamur.github.io/asciidoctor-diagram-cacoo-example/sample.html and found the
However, I would like to set the
|
I'm excited to see the progress on this issue! Thanks for setting up the new gem @hnakamur! I'll keep following along and chime in when ever I can help out! |
The block macro syntax takes the general form
So to trigger your CacooBlockMacroProcessor you would have to write
Regarding the
|
I've reviewed the updated cacoo code. The only thing I would tweak is to change
to
The cacoo Source class is overriding all of the methods from FileSource so it doesn't make sense to extend from it. |
@pepijnve Thanks for your explanation and review! I updated my gem hnakamur/asciidoctor-diagram-cacoo and an example code hnakamur/asciidoctor-diagram-cacoo-example and an example page. @mojavelinux I'm excited to see the achievement on this issue too! Thanks again both of you for your great support. It was very helpful. |
That's what I love to hear! |
@pepijnve Hi, I updated hnakamur/asciidoctor-diagram-cacoo following changes by Rename Asciidoctor::Diagram::API to Asciidoctor::Diagram::Extensions · e04ef75 · pepijnve/asciidoctor-diagram. By the way, I created another asciidoctor-diagram extension for including diagrams created with D3.js.
Could you review this? |
@hnakamur I posted some feedback on the list. http://discuss.asciidoctor.org/d3-js-integration-for-Asciidoctor-Diagram-td2259.html |
Closing this PR since the code was moved to a separate project instead and there are no further issues to be resolved for the time being. |
Hi, I added the Cacoo support to the asciidoctor-diagram.
Please refer README.adoc for the usage.
I confirmed this pull request works successfully.
Could you review this?
Thanks.