Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[WIP] Search update #12689

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/_static/js/docversion.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
function setVersion(){
let doc = window.location.pathname.match(/^\/(api\/.*)$/) || window.location.pathname.match(/^\/versions\/[^*]+\/(api\/.*)$/);
let doc = window.location.pathname.match(/^\/versions\/[0-9.master]+\/([^*]+.*)$/);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this fail if the version user is looking at is master, where /versions/ is missing from the URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep... good catch... I was testing the other side of the use case.

I've been thinking about a related point. I could just force all the default traffic to /versions/master. This would solve a variety of thorny issues. Also, help with analytics. WDYT about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think I'd personally like to see /versions/xyz in the URL all the time. In the future if we decide to change default to latest release rather than master, we can easily change the redirect and everything else should work as expected.

if (doc) {
if (document.getElementById('dropdown-menu-position-anchor-version')) {
versionNav = $('#dropdown-menu-position-anchor-version a.main-nav-link');
$(versionNav).each( function( index, el ) {
currLink = $( el ).attr('href');
version = currLink.match(/\/versions\/([0-9.master]+)\//);
if (version) {
versionedDoc = '/versions/' + version[1] + '/' + doc[1] + (window.location.hash || '');
versionedDoc = '/versions/' + version[1] + '/' + doc[1] + (window.location.hash || '') + (window.location.search || '');
$( el ).attr('href', versionedDoc);
}
});
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/_static/searchtools_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ var Search = {
}
Search.title.text(_('Search Results'));
if (!resultCount)
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
Search.status.text(_('Your search did not match any documents in this version of the documentation. You can use the dropdown selector in the navigation bar to try another version. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
else
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
Search.status.fadeIn(500);
Expand Down