asciidocfx / AsciidocFX

Asciidoc Editor and Toolchain written with JavaFX 21 (Build PDF, Epub, Mobi and HTML books, documents and slides)
http://www.asciidocfx.com/
Apache License 2.0
1.86k stars 296 forks source link

Usage of Templates #558

Closed gillesB closed 1 year ago

gillesB commented 1 year ago

I would like to add the support for templates as a new feature to AsciidocFX. A template could be a predefined single file (e.g. an adoc-file) or a zipped-folder (e.g containing a adoc-file referencing a pdf-theme-yaml). The user should be able to define these templates and apply them to the current working directory with a few clicks. To achieve this the following could be implemented:

There should be a new settings tab Templates containing a List similar to the Asciidoctor Attributes. The first column is the name of the template, the second column contains the location. The location can be a local file or an http(s)-URL. For example: Name: CJK (Chinese) fonts Location: https://github.com/asciidocfx/asciidoctor-cjk-demo/archive/refs/heads/master.zip (Granted it might not be the best example as the .zip is 38 MB large. On the other side it works after it is extracted to an empty folder and it is official as it is part of the AsciidocFX-Github-organization.)

The template names appear in the menu. I would place a submenu Templates below Asciidoc Cheatsheet and Sample Book. This submenu is filled with one entry per template in the settings.

With a click on the menu entry the file is downloaded, then copied or extracted to the current working directory. The exact operations depend on the template-location (e.g. if it is a local single file or a remote-zip-file)

(I implemented (or experimented with JavaFx) already a bit, but it might take same time till I implemented the whole feature.)

rahmanusta commented 1 year ago

Hey @gillesB , I like the a lot. I'll wait for the next commits :) Thank you

gillesB commented 1 year ago

Hello @rahmanusta,

if I have not missed anything, the feature is ready.

During development I renamed the classes sometimes and moved code around, so I needed quite a few commits. Do you prefer a squashed commit?

If you want I can also create a repository containing a small template with a Word look-alike theme which can be used as a template. Afterwards you can fork it, so that is in the AsciidocFX Project Organization. Then it can be used as official example in the templates_config.json.

Best regards Gilles

rahmanusta commented 1 year ago

Hi @gillesB , Thanks for the feature completion!

Sure, I would like to accept your proposed theme project under AsciidocFX organization. I look forward to seeing your request.

Btw, I'm checking your commits and I'll merge it soon when I complete review. Squashed commit is not a necessity.

Thank you! Rahman

gillesB commented 1 year ago

Hello,

I just pushed the theme to https://github.com/gillesB/asciidoc_pdf_word_like_theme.

Unfortunately Github does not render asciidoc nicely. And the logo is also quickly made and rather ugly, but the user will replace or delete it anyway, so I think it is good enough.

BR Gilles

gillesB commented 1 year ago

Sorry for the inconvenience, but I detected a bug.

As the commit message already says, a column logger was shown in the Templates settings. The AsciidocTemplateFXs now contain no logic but only their data. The download/coping is now done by TemplateService. Besides the bug, I think it now better fits the Spring based architecture of AsciidocFx.

rahmanusta commented 1 year ago

Hi @gillesB , can we transfer the https://github.com/gillesB/asciidoc_pdf_word_like_theme template to asciidocfx org ?

gillesB commented 1 year ago

I can not transfer the repo to the asciidocfx org, as I do not have the permission to create repos in the asciidocfx org. I added you as collaborator, perhaps you can transfer it yourself?

rahmanusta commented 1 year ago

Seems I just have limited permission on the repo. Can you click the Transfer button under the Settings page ? Just type there the organization name asciidocfx, then it should create a request for transfer.

gillesB commented 1 year ago

Transferring to another organization does not work:

image

But I can transfer it to your personal account. You should have received a request.

rahmanusta commented 1 year ago

@gillesB I just gave you the permission, can you try it again ? Thank you

gillesB commented 1 year ago

Finally: Moving repository to asciidocfx/asciidoc_pdf_word_like_theme. This may take a few minutes. :)