lask79 / asciidoctor-treeview

Generates tree views based on ascii-tree with beautiful icons for folders and icons
Mozilla Public License 2.0
10 stars 0 forks source link

allow local configuration for cdn assets #4

Closed DryHumorInDC closed 5 months ago

DryHumorInDC commented 5 months ago

One of my environments is offline/air-gapped, and this environment does not jive well with this extension. Can you find a way to specify a local location in lieu of fetching over the network? It looks like that resource is hard-coded in ./lib/converter/treeline-to-html-converter.sh

I can install the material-icon-theme npm module by bringing that resource over manually, but I need a way to point at that local resource.

lask79 commented 5 months ago

Can you tell me more about your use case? Are you using plain asciidoctorjs or antora?

Would it be enough to provide a way to override the path so that you can define where to look for the icons?

Something like this:

const default path =  `https://cdn.jsdelivr.net/npm/material-icon-theme@4.32.0/icons`
const url = (getPathFromConfiguration() || default_path) + `/${icon}`

Is that enough? I also was thinking about retrieving all used icons into a local folder and then to point to the local folder in a relative way.

DryHumorInDC commented 5 months ago

I'm using Antora.

Yes -- if I could configure a path, that would be great. Ideally, it would be something that could be set in any runtime, but my priority is Antora.

DryHumorInDC commented 5 months ago

I wonder if it's possible to also add these icons to the Antora UI Bundle? I'd be willing to throw these in there, but I'd still need a way to specify an alternate path.

lask79 commented 5 months ago

About Antora I was thinking about directly adding the icons into the UI catalog so that the build process is putting then into the right folders. Putting them into UI bundle might not be effective because then you need to know upfront which icons you want to use and adding all icons would make the ui-bundle quite big. Doing this during the Antora build has the benefit that only the files will be copied that are used in the pages.

I will take a look into this how easy this could be implemented or if there could be also an intermediate solution. A dynamic and a configurable static approach.

DryHumorInDC commented 5 months ago

That would be terrific, thank you!

lask79 commented 5 months ago

So I implemented multiple improvements:

lask79 commented 5 months ago

@DryHumorInDC is this working for you?

DryHumorInDC commented 5 months ago

So sorry, I just saw this. Unfortunately, I am not only without Internet connectivity at runtime, but also at build-time. Therefore, I shall try moving the assets and utilizing the :treeview-icon-source property. I should have time to do this by Friday, and I'll let you know. The approach seems quite doable, so thank you in advance!

lask79 commented 5 months ago

@DryHumorInDC I do not think that you need to move the assets on your own. As long as you use Antora and have the needed dependencies in the local nodemodules the icons are copied from the local material-icons-theme module to the Antora /img/treeview folder and not downloaded from the internet. IMHO is should fit your use case quite well.

DryHumorInDC commented 5 months ago

Ah, gotcha. I just need to wait a few more days on this. My administrators promise to have your npm module pulled in by Friday. Will tag up then. Thanks for your patience. And my have you been busy! I just looked at what you had to do to make this happen; I'm grateful. :-)

DryHumorInDC commented 5 months ago

Success!

Thank you so much. I'm very grateful to you. I'm using the antora method, but also tested embedded with equal success.

lask79 commented 5 months ago

That is great. Thx for using it and asking for new features to make it even better.

Have fun with the extension.