asciidoctor / asciidoctor-chart

A set of Asciidoctor extensions that add a chart block and block macro to AsciiDoc for including charts in your AsciiDoc document.
Other
29 stars 13 forks source link

Add support to use Chart.js engines offline #25

Closed uniqueck closed 2 years ago

uniqueck commented 2 years ago

We use asciidoctor-chart in combination with asciidoctor-revealjs and the generate slides are deployed in a kubernetes cluster without internet access.

In the extension asciidoctor-revealjs, I can define which reveal.js directory should be used, instead of linking them online. The same approach would be nice for asciidoctor-chart.

So I can download them and point with an asciidoctor attribute to the chart.js directory and the chart extension link the specific scripts relativ to the directory.

ggrossetie commented 2 years ago

That's a good idea, I think we should introduce a new attribute named chartjs-dir. Though, It would be more generic to use the terminology chartjs-location to be able to specify either a URL or a local path.

Any opinion on this @mojavelinux ?

uniqueck commented 2 years ago

OK I'm not a ruby developer, but I will try to provide a PR for that.

ggrossetie commented 2 years ago

The Chart.js URL is defined here (as a constant):

https://github.com/asciidoctor/asciidoctor-chart/blob/53e24b41b6d6fbea751456b3cc205c7ad3969984/lib/asciidoctor/chart/docinfo_processor.rb#L20

You will need to get the value of the attribute chartjsdir from the doc in the process method. If the attribute is defined then you should use normalize_web_path to concat the filename chart.min.js with the Chart.js directory. Here's an example: https://github.com/asciidoctor/asciidoctor/blob/1f90be5f63a7bd9092d8510d88cd6db20caa87bd/lib/asciidoctor/converter/html5.rb#L133

ggrossetie commented 2 years ago

You can add a test here to make sure that everything is working as expected: https://github.com/asciidoctor/asciidoctor-chart/blob/master/spec/docinfo_processor_spec.rb

mojavelinux commented 2 years ago

That's a good idea, I think we should introduce a new attribute named chartjs-dir. Though, It would be more generic to use the terminology chartjs-location to be able to specify either a URL or a local path.

The convention in AsciiDoc is to name it chartsjsdir (just like highlightjsdir), which can be a local directory or a URL.

uniqueck commented 2 years ago

I'm ready with this change, should we also introduce these kind of attributes for c3js and chartist? There is no changelog, should we introduce some? Where I have to document this new attribute? There is no integration for the antora documentation process of https://docs.asciidoctor.org, is this planned for the future?

ggrossetie commented 2 years ago

should we also introduce these kind of attributes for c3js and chartist?

Yes, I think we should to do it to keep things consistent. We might also want to introduce a generic chartdir where all resources could be found (C3.js, Chartist and Chart.js). Might be a bad idea, not sure... 🤔 Anyway, we should do it as a follow-up issue/pull request.

Where I have to document this new attribute? There is no integration for the antora documentation process of docs.asciidoctor.org, is this planned for the future?

For now, I think it's enough to add a "Configuration" section in the "Getting started" section (after "Usage") to document this new attribute. We should also document what files are expected to be found in the chartjsdir.

There is no changelog, should we introduce some?

Maybe later.

uniqueck commented 2 years ago

sorry for the delay, but I'm busy until today.