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

SupportCustomLayout #52

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

Metalzoid
Copy link
Contributor

Deleting =

  • oas_rails_controller: layout false

Adding =

  • oas_rails_controller:

  • include Rails url_helpers for support route_path

  • modify render html for include layout from configuration OAS_RAILS

  • configuration.rb:

  • attr_accessor :layout

  • initialize @layout to false

  • oas_rails_initializer :

  • config.layout = "application" + documentation

It's works fine for me

@a-chacon
Copy link
Owner

hey @Metalzoid the code looks good. But I was thinking if you add a layout to the page maybe you will be duplicating code like the html, head, body tags. You will be creating a html page inside another html at least you overwrite the index page too.

I mean, the index page already have this structure:

<!DOCTYPE html>
<html>
  <head>
    <title><%= OasRails.config.info.title %></title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <meta charset="utf-8">
    <!-- Important: rapi-doc uses utf8 characters -->
    <script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
  </head>
  <body>
    
  </body>
</html>

Is it ok? So maybe the feature can include a modification in the index view too.

And which is the use case you want to cover here? I mean, Why you need this feature?

@Metalzoid
Copy link
Contributor Author

I see ! I need this feature for adding my custom navbar =)

and if we specify adding this lines in the custom layouts user in the :

    <meta charset="utf-8">
    <!-- Important: rapi-doc uses utf8 characters -->
    <script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>

It's good for you ?

@a-chacon
Copy link
Owner

mm I think, we can use by default the layout of the engine. Move all the code to it, and in the index view let something like this:

    <script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
    <rapi-doc
      spec-url = "<%= OasRails::Engine.routes.find_script_name({}) %>.json"
      theme = "dark"
      bg-color="#0F172A"
      text-color= "#f7f7f7"
      show-header = 'false'
      primary-color = "#2de410"
      font-size="largest"
      show-method-in-nav-bar="as-colored-text"
      nav-text-color="#f7f7f7"
      nav-item-spacing="relaxed"
      allow-spec-file-download="true"
      >
    </rapi-doc>

Then you can replace the engine layout with your layout with the code you defined. Can you understand me? Just leave in the index.html.erb file the things for making the rapidoc works. It should not depend on the client layout because it will be easy to forget.

@Metalzoid
Copy link
Contributor Author

And the charset UTF8??

@a-chacon
Copy link
Owner

mm good question about the utf-8. It should not depend on the user too. Do you have any idea? I will think about it.

@Metalzoid
Copy link
Contributor Author

Since this is code intended for developers, I don't think it will be a problem. At worst, in the docs, in the "use your own layouts" section, specify to use UTF8 in case of character display problems?

@a-chacon
Copy link
Owner

a-chacon commented Aug 28, 2024

ok, you are right. So it may be finished. I will review and merge it at the end of the day. Thank you! And please share it, much people use it much better we can do it 👍🏽

@a-chacon a-chacon merged commit abef8d3 into a-chacon:main Aug 28, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants