-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Redirects: improvements from design doc #10881
Conversation
Matches readthedocs/readthedocs.org#10881. Applied the same code we have for automation rules.
Matches readthedocs/readthedocs.org#10881. Applied the same code we have for automation rules.
@@ -1283,6 +1283,8 @@ class VersionAutomationRule(PolymorphicModel, TimeStampedModel): | |||
choices=VERSION_TYPES, | |||
) | |||
|
|||
_position_manager = ProjectItemPositionManager(position_field_name="priority") |
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.
This can be a mixin + a class attribute, not strong opinion.
def __init__(self, position_field_name): | ||
self.position_field_name = position_field_name | ||
|
||
def change_position_before_save(self, item): |
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.
All this code comes from automation rules, it's the same code, just changed to use self.position_field_name
instead of priority
.
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.
This looks like a great change. I'd be curious to hear more about the performance changes that come from this. If we think we can do redirect queries on each pageview, I'd be strongly in favor of removing the limitations around Forced redirects, and enabling them by default I think.
For this redirect to work, your old version must be disabled, | ||
if the version is still active, you can use the ``Force Redirect`` option. | ||
|
||
Creating a shortlink |
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.
Love all the examples in this page 💯
readthedocs/redirects/querysets.py
Outdated
|
||
if filename in ["/index.html", "/"]: | ||
# If the filename is the root index file, we only need to match page and exact redirects. | ||
# Since we don't have a filename to redirect to, since ``/``/``/index.html`` is already the root. |
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 don't understand the /``/``/index.html
-- is that just the path ///index.html
?
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's A/B
, I have reworded this to make it less confusing.
We can decide about enabling them after shipping these changes. Currently, matching redirects takes less than 1ms, so they are already fast, I don't think we will have any problems with that. |
Sounds good. I'm 👍 on merging this and doing that work next. |
Matches readthedocs/readthedocs.org#10881. Applied the same code we have for automation rules.
Migrate to the new redirect format introduced by ReadTheDocs in readthedocs/readthedocs.org#10881 The wildcard redirect is broken at the moment due to faulty handling of infinite redirect detection on the ReadTheDocs side. Signed-off-by: Bence Szépkúti <[email protected]>
Migrate to the new redirect format introduced by ReadTheDocs in readthedocs/readthedocs.org#10881 The wildcard redirect is broken at the moment due to faulty infinite redirect detection on the ReadTheDocs side. Signed-off-by: Bence Szépkúti <[email protected]>
Migrate to the new redirect format introduced by ReadTheDocs in readthedocs/readthedocs.org#10881 Signed-off-by: Bence Szépkúti <[email protected]>
Implements https://dev.readthedocs.io/en/latest/design/redirects.html
For the templates, I also re-used the styles from automation rules.
$rest
), or use the old types.get_redirect_path
was previously re-running the same checks fromget_redirect_path_with_status
, we don't do this anymore, we avoid duplication and should be a little faster.Questions
How to deploy
redirects 0006
redirects 0007
We would experiment some redirects not working while the migration takes place,
we don't have that many redirects, so it should be quick. We need to save each redirect individually so they are normalized as the new code expects.
Screenshots
Closing credits?
/$rest -> example.com
redirects PR previews (external domain) to target domain #9614