-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Page views: use origin URL instead of page name #7293
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
Changes from 2 commits
f9ce9ca
c27e4df
d267903
70ad4b8
65fcc7c
2e5aa58
552becc
b726251
7a18594
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
from readthedocs.builds.models import Version | ||
from readthedocs.core.utils.extend import SettingsOverrideObject | ||
from readthedocs.projects.constants import MKDOCS, SPHINX_HTMLDIR | ||
from readthedocs.projects.models import Project, Feature | ||
from readthedocs.projects.models import Feature, Project | ||
from readthedocs.projects.version_handling import ( | ||
highest_version, | ||
parse_version_failsafe, | ||
|
@@ -81,6 +81,19 @@ class BaseFooterHTML(APIView): | |
""" | ||
Render and return footer markup. | ||
|
||
Query parameters: | ||
|
||
- project | ||
- version | ||
- page: Sphinx's page name, used for path operations, | ||
like change between languages (deprecated in favor of ``origin``). | ||
- origin: Full path with domain, used for path operations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm avoiding naming this path since it includes the domain as well, we use full path to refer to a path in other parts of the code. Not sure about uri There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, origin isn't the right name, since that's used in HTTP for just the origin hostname: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin I think |
||
- theme: Used to decide how to integrate the flyout menu. | ||
- docroot: Path where all the source documents are. | ||
Used to build the ``edit_on`` URL. | ||
- source_suffix: Suffix from the source document. | ||
Used to build the ``edit_on`` URL. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are passing subproject too, but we are not using it. I can remove it in another PR if that's ok |
||
|
||
.. note:: | ||
|
||
The methods `_get_project` and `_get_version` | ||
|
@@ -229,6 +242,7 @@ def get(self, request, format=None): | |
request=request, | ||
context=context, | ||
resp_data=resp_data, | ||
origin=self.request.GET.get('origin'), | ||
) | ||
|
||
return Response(resp_data) | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from unittest import mock | ||
|
||
from django.contrib.sessions.backends.base import SessionBase | ||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
|
@@ -418,7 +419,7 @@ class TestFooterPerformance(APITestCase): | |
|
||
# The expected number of queries for generating the footer | ||
# This shouldn't increase unless we modify the footer API | ||
EXPECTED_QUERIES = 14 | ||
EXPECTED_QUERIES = 13 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have one query less bc we are not sending the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should test this with an origin. I expect the |
||
|
||
def setUp(self): | ||
self.pip = Project.objects.get(slug='pip') | ||
|
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'm not sure if this is the best approach right now. I think this is going to add a good number of queries to the footer, which is already our most expensive view. If we can just pull the path off the request, I think that is probably best, but maybe calling
unresolve
is correct, and we should focus on optimizations there?