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

Fixes #32848 - Support linking to docs.theforeman.org #9756

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Jun 27, 2023

An effort is under way to use docs.theforeman.org as the primary documentation source. It is already the official documentation source for Katello, but until now it wasn't easily possible to (correctly) link to it.

The documentation is built in 3 flavors:

  • Katello (index-katello.html)
  • Debian/Ubuntu (index-deb.html)
  • Enterprise Linux (index-el.html)

This is currently untested, but is based on #8613.

@theforeman-bot
Copy link
Member

Issues: #32848

app/controllers/links_controller.rb Outdated Show resolved Hide resolved
@@ -302,8 +302,8 @@ def edit_inline(object, property, options = {})
editable(object, property, {:type => type, :title => title, :value => value, :class => klass, :source => select_values, :url => update_url, :placeholder => placeholder}.compact)
end

def documentation_url(section = "", options = {})
main_app.external_link_url(options.merge(type: 'manual', params: { section: section }))
def documentation_url(section = nil, type: 'manual', **options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be safe, but I'm not 100% sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine!

def documentation_url(section = "", options = {})
main_app.external_link_url(options.merge(type: 'manual', params: { section: section }))
def documentation_url(section = nil, type: 'manual', **options)
main_app.external_link_url(type: type, section: section, params: options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external_link_url should receive only two parameters: type and options. I think splitting the section out of the options will cause a different output

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? The route is includes the section:

get 'links/:type(/:section)' => 'links#show', :as => 'external_link', :constraints => { section: %r{.*} }

Now I'll immediately admit my knowledge of Rails routing may be lacking, but I don't see a difference between type and section there, other than that section is optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you are correct:

[9] pry(main)> external_link_path(type: 'foo', section: 'bar', zzz: 'qqq')
=> "/links/foo/bar?zzz=qqq"

As long as it works - I'm good :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check if passing it without a section also works, but I'm assuming it does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. When no section is passed, the final url does not contain a fragment.
So, as expected.

@@ -25,6 +25,8 @@ def external_url(type:, options: {})
'https://projects.theforeman.org/projects/foreman/issues'
when 'vmrc'
'https://www.vmware.com/go/download-vmrc'
when 'docs'
docs_url(guide: options['section'], **options.slice('chapter', 'flavor'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think generally you don't want to link to other flavors, but this is here so you can do something like "this requires Katello, see katello-flavor".

@ekohl ekohl force-pushed the 32848-doc-url branch 3 times, most recently from edcc0ce to 545d262 Compare October 26, 2023 15:09
@ekohl
Copy link
Member Author

ekohl commented Oct 30, 2023

I think this was during the NodeJS 14 migration:

[2023-10-26T15:14:52.894Z] ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

[test unit]

@ekohl ekohl force-pushed the 32848-doc-url branch 2 times, most recently from 8674e69 to f26bb3e Compare October 31, 2023 15:07
@ekohl
Copy link
Member Author

ekohl commented Oct 31, 2023

Now with more tests. I think this is ready now.

Copy link
Contributor

@Thorben-D Thorben-D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me...
Thanks, @ekohl

@@ -302,8 +302,8 @@ def edit_inline(object, property, options = {})
editable(object, property, {:type => type, :title => title, :value => value, :class => klass, :source => select_values, :url => update_url, :placeholder => placeholder}.compact)
end

def documentation_url(section = "", options = {})
main_app.external_link_url(options.merge(type: 'manual', params: { section: section }))
def documentation_url(section = nil, type: 'manual', **options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine!

def documentation_url(section = "", options = {})
main_app.external_link_url(options.merge(type: 'manual', params: { section: section }))
def documentation_url(section = nil, type: 'manual', **options)
main_app.external_link_url(type: type, section: section, params: options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. When no section is passed, the final url does not contain a fragment.
So, as expected.

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nitpicks, but apart from that it works nicely.

app/services/foreman/version.rb Outdated Show resolved Hide resolved
app/controllers/links_controller.rb Outdated Show resolved Hide resolved
adamruzicka
adamruzicka previously approved these changes Nov 7, 2023
Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's get this in

An effort is under way to use docs.theforeman.org as the primary
documentation source. It is already the official documentation source
for Katello, but until now it wasn't easily possible to (correctly) link
to it.

The documentation is built in 3 flavors:

* Katello (index-katello.html)
* Debian/Ubuntu (index-deb.html)
* Enterprise Linux (index-el.html)
@ekohl
Copy link
Member Author

ekohl commented Nov 8, 2023

Updated tests to stub installed? so tests should be green now.

@adamruzicka adamruzicka merged commit b566ea8 into theforeman:develop Nov 9, 2023
14 checks passed
@adamruzicka
Copy link
Contributor

Thank you @ekohl, @Thorben-D & @ShimShtein !

@ekohl ekohl deleted the 32848-doc-url branch November 9, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants