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

Capture source path segment and append to destination path #63

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eecavanna
Copy link
Collaborator

@eecavanna eecavanna commented Jul 12, 2024

In this branch, I deleted the two original redirects that existed and replaced them with a new one. The new one is designed to capture the portion of the original URL following /reference/metadata and append it to https://w3id.org/nmdc/, and then redirect the user to the resulting URL.

For example: If a user visits https://nmdc-documentation.readthedocs.io/en/latest/reference/metadata/xylene.html, I designed the redirect to redirect them to https://w3id.org/nmdc/xylene (which will, in turn, redirect them to https://microbiomedata.github.io/nmdc-schema/xylene/).

I am not sure this redirection plugin supports having a combination of wildcard and non-wildcard sources, which is what the two original redirects—together—were. It may be the case that the wildcard overrode any other sources. This is not addressed in the plugin's documentation.

@eecavanna
Copy link
Collaborator Author

I have created this PR because I don't know how I can get the "dev" MakeTheDocs site to pull from an arbitrary, non-main branch. Merging this into main will not automatically cause it to be deployed to our production documentation website (or the development documentation website). It will, however, allow me to deploy it to those when I choose to.

I will check with @yxu-lanl about the possibility of deploying this PR branch to the development documentation site.

@eecavanna
Copy link
Collaborator Author

I found a way I could deploy this to https://dev-nmdc-documentation.readthedocs.io for testing, without merging it into main first.

Unfortunately, I misunderstood how the "capturing" of the * worked. Instead of capturing only the part of the source path that the * matches, what gets captured is actually the entire source path.

As a result, instead of https://dev-nmdc-documentation.readthedocs.io/en/dev/reference/metadata/xylene.html redirecting to https://w3id.org/nmdc/Study, it redirects to https://w3id.org/nmdc/reference/metadata/Study (which is not what I want to happen).

@eecavanna
Copy link
Collaborator Author

There's already an issue about this behavior, in the plugin's GitHub repo: documatt/sphinx-reredirects#2

@eecavanna
Copy link
Collaborator Author

I commented on that issue. I'll keep this code in a draft PR for now. I have "unassigned" all the reviewers as I'm not ready for this to be merged in anymore.

@eecavanna eecavanna marked this pull request as draft July 12, 2024 22:03
@eecavanna
Copy link
Collaborator Author

After having checked the source code of the Sphinx plugin that handles redirects, I am not confident the plugin will be updated to capture the portion of the URL that matches the *.

As an alternative, we could add a RewriteRule in https://github.com/perma-id/w3id.org/blob/master/nmdc/.htaccess to remove the leading /reference/metadata. This isn't something I would do without talking to my team members about it first.

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.

Hackathon: Replace obsolete schema documentation with HTTP Redirect to latest docs
1 participant