-
Notifications
You must be signed in to change notification settings - Fork 990
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
Conversation
Issues: #32848 |
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine!
587c3f9
to
1e1e668
Compare
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
Line 558 in df3a0b0
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
app/controllers/links_controller.rb
Outdated
@@ -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')) |
There was a problem hiding this comment.
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".
edcc0ce
to
545d262
Compare
I think this was during the NodeJS 14 migration:
[test unit] |
8674e69
to
f26bb3e
Compare
Now with more tests. I think this is ready now. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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)
Updated tests to stub |
Thank you @ekohl, @Thorben-D & @ShimShtein ! |
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:
This is currently untested, but is based on #8613.