Skip to content

Commit

Permalink
Proxito: remove old implementation (#10660)
Browse files Browse the repository at this point in the history
Mostly removing old code, there is only one small custom addition

https://github.com/readthedocs/readthedocs.org/blob/6595bdac198b482e1279c0e3b1925198f6baa631/readthedocs/proxito/views/serve.py#L144-L146

Django doesn't capture the first slash, previously we were getting the path from request.path_info, that includes the slash! When a request is done to `/` the path is set to "" (empty), our code relies on that being `/`.

- Closes #10408
- Closes #8399

### How to deploy this change

- Deploy everything as usual, but don't run the `projects 0105` migration!!!
- After deploy is done, run the `projects 0105`  migration
  • Loading branch information
stsewd authored Aug 28, 2023
1 parent 4be38fa commit 40bfe63
Show file tree
Hide file tree
Showing 21 changed files with 189 additions and 1,298 deletions.
1 change: 0 additions & 1 deletion readthedocs/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Meta:
"documentation_type",
"users",
"canonical_url",
"urlconf",
"custom_prefix",
)

Expand Down
35 changes: 0 additions & 35 deletions readthedocs/core/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def base_resolve_path(
project_relationship=None,
subdomain=None,
cname=None,
urlconf=None,
custom_prefix=None,
):
"""
Expand Down Expand Up @@ -97,38 +96,6 @@ def base_resolve_path(
else:
path = unsafe_join_url_path(path, "{language}/{version}/{filename}")

# TODO: remove this when all projects have migrated to path prefixes.
# Allow users to override their own URLConf
# If a custom prefix is given, we don't use the custom URLConf,
# since they are not compatible with each other.
# We also don't check if the project has the new proxito implementation
# enabled, this is so we can start generating links with the new
# custom prefixes without starting to serve docs with it (this helps to ease
# the migration from urlconf to custom prefixes).
if urlconf and not custom_prefix:
path = urlconf
path = path.replace(
"$version",
"{version}",
)
path = path.replace(
'$language',
'{language}',
)
path = path.replace(
'$filename',
'{filename}',
)
path = path.replace(
"$subproject",
"{subproject}",
)
if "$" in path:
log.warning(
"Unconverted variable in a resolver URLConf.",
path=path,
)

subproject_alias = project_relationship.alias if project_relationship else ""
return path.format(
project=project_slug,
Expand All @@ -147,7 +114,6 @@ def resolve_path(
single_version=None,
subdomain=None,
cname=None,
urlconf=None,
):
"""Resolve a URL with a subset of fields defined."""
version_slug = version_slug or project.get_default_version()
Expand Down Expand Up @@ -181,7 +147,6 @@ def resolve_path(
project_relationship=project_relationship,
cname=cname,
subdomain=subdomain,
urlconf=urlconf or project.urlconf,
custom_prefix=custom_prefix,
)

Expand Down
2 changes: 2 additions & 0 deletions readthedocs/core/unresolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def unresolve_path(self, unresolved_domain, path, append_indexhtml=True):
:param append_indexhtml: If `True` directories will be normalized
to end with ``/index.html``.
"""
# Make sure we always have a leading slash.
path = self._normalize_filename(path)
# We don't call unparse() on the path,
# since it could be parsed as a full URL if it starts with a protocol.
parsed_url = ParseResult(
Expand Down
17 changes: 0 additions & 17 deletions readthedocs/projects/fixtures/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -70,7 +69,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -123,7 +121,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -176,7 +173,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -229,7 +225,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -282,7 +277,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -335,7 +329,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -388,7 +381,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -441,7 +433,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -494,7 +485,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -547,7 +537,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -600,7 +589,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -653,7 +641,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -706,7 +693,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -757,7 +743,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -808,7 +793,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down Expand Up @@ -859,7 +843,6 @@
"default_branch": null,
"requirements_file": null,
"documentation_type": "sphinx",
"urlconf": null,
"external_builds_enabled": false,
"external_builds_privacy_level": "public",
"cdn_enabled": false,
Expand Down
20 changes: 20 additions & 0 deletions readthedocs/projects/migrations/0105_remove_project_urlconf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.4 on 2023-08-23 20:35

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("projects", "0104_alter_httpheader_value"),
]

operations = [
migrations.RemoveField(
model_name="historicalproject",
name="urlconf",
),
migrations.RemoveField(
model_name="project",
name="urlconf",
),
]
Loading

0 comments on commit 40bfe63

Please sign in to comment.