Skip to content
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 parameter singleFile #61

Closed
GordeevArt opened this issue Sep 10, 2020 · 7 comments · Fixed by #62
Closed

Add parameter singleFile #61

GordeevArt opened this issue Sep 10, 2020 · 7 comments · Fixed by #62
Labels
enhancement New feature or request released

Comments

@GordeevArt
Copy link
Contributor

Motivation: publicate asyncapi into services that accept only single documents.

Add parameter singleFile to get html with scripts and styles in one file.

"singleFile": {
        "description": "If set this parameter to true generate single html file with scripts and styles inside",
        "required": false,
        "default": false
      }

Make something like this in index.html:

  {% if params.singleFile %}
    <style type="text/css">
    {% include "template/css/tailwind.min.css" %}
    </style>
    <style type="text/css">
    {% include "template/css/atom-one-dark.min.css" %}
    </style>
    <style type="text/css">
    {% include "template/css/main.css" %}
    </style>
  {% else %}
  <link href="css/tailwind.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/atom-one-dark.min.css" />
  <link rel="stylesheet" href="css/main.css" />
  {% endif %}
  {% if params.singleFile %}
    <script defer type="text/javascript">
    {% include "template/js/highlight.min.js" %}

    {% include "template/js/main.js" %}
    </script>
  {% else %}
  <script src="js/highlight.min.js" type="application/javascript"></script>
  <script src="js/main.js" type="application/javascript"></script>
  {% endif %}
@GordeevArt GordeevArt added the enhancement New feature or request label Sep 10, 2020
@derberg
Copy link
Member

derberg commented Sep 10, 2020

@GordeevArt looks good to me, I like it, I think that one day someone asked about it. Did you think about creating a PR for it. The only missing part I see is to add a hook that would react to this parameter and would remove all unnecessary files from the output directory, something similar to https://github.com/asyncapi/java-spring-template/blob/master/hooks/02_removeNotRelevantParts.js. You can access params in hooks -> const params = generator.templateParams; and then something like params.singleFile === 'true'

@GordeevArt
Copy link
Contributor Author

@derberg there is a problem with --watch-template when removing the directories by the hooks. Infinite recreating.

GordeevArt added a commit to GordeevArt/html-template that referenced this issue Sep 11, 2020
Add singleFile param to output all in
one html file

asyncapi#61
GordeevArt added a commit to GordeevArt/html-template that referenced this issue Sep 11, 2020
@derberg
Copy link
Member

derberg commented Sep 11, 2020

@GordeevArt crap, could you please report a bug here?

@GordeevArt
Copy link
Contributor Author

@derberg yep. What about unpassed checks? https://github.com/asyncapi/html-template/pull/62/checks

How can it be fixed?

@derberg
Copy link
Member

derberg commented Sep 11, 2020

@GordeevArt our pipelines are based on GitHub Actions and when we added them, they did not support nicely fork workflows. Welcome message could not be posted by the bot as on the PR from fork it has only read GitHub Token. They changed it now and introduced an alternative pull request event that takes GitHub workflows files from the upstream and not the fork (which makes it secure to assign read/write token. We just didn’t have time to update our workflows in all our repositories. I hope I explained it well.

In theory, it is enough to replace this with pull_request_target but I didn't have time yet to test it

GordeevArt added a commit to GordeevArt/html-template that referenced this issue Sep 11, 2020
@GordeevArt
Copy link
Contributor Author

@derberg thanks it helps. Waiting for merge.

GordeevArt added a commit to GordeevArt/html-template that referenced this issue Sep 11, 2020
update to the Highlight.js 10.2.0
without dirty hacks

asyncapi#61
@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants