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

URL redirects #1058

Merged
merged 3 commits into from Jul 2, 2019
Merged

URL redirects #1058

merged 3 commits into from Jul 2, 2019

Conversation

@courtneycb
Copy link
Contributor

@courtneycb courtneycb commented Jul 1, 2019

This PR redirects https://csfieldguide.org.nz/index.html to https://csfieldguide.org.nz/ and tidies some code in the urls.py files.

HELP WANTED:

  • Currently the redirects for permalinks are incorrect. For example /chapters/algorithms.html#searching should redirect to /chapters/algorithms/searching/ but instead it redirects to http://localhost:81/en/chapters/algorithms/#searching.

  • Here are the two redirects I found that do not work:
    In chapters/urls.py:

    # eg: redirect /chapters/algorithms.html#searching to /chapters/algorithms/searching/
    url(
        r"^(?P<chapter_slug>[-\w]+).html#(?P<chapter_section_slug>[-\w]+)$",
        RedirectView.as_view(permanent=True, pattern_name="chapters:chapter_section"),
    ),

In curriculum_guides/urls.py:

    # eg: redirect /curriculum-guides/apcsp/index.html#abstraction to /curriculum-guides/apcsp/abstraction/
    url(
        r"^(?P<curriculum_guide_slug>[-\w]+)/index.html#(?P<curriculum_guide_section_slug>[-\w]+)$",
        RedirectView.as_view(permanent=True,
                             pattern_name="curriculum_guides:curriculum_guide_section"),
    ),

I tried overriding the get_url_redirect method in views.py but the code would never get hit? Not sure what's going on and don't seem to be getting very far with it.

@eAlasdair
Copy link
Collaborator

@eAlasdair eAlasdair commented Jul 2, 2019

Did some research. Anchor parameters (the bit after the #) do not get sent as part of the request, so the server never knows about them. Your code never got hit because those redirects never got hit. There is no way those redirects can do what they are attempting, so they can be removed.

Loading

@courtneycb
Copy link
Contributor Author

@courtneycb courtneycb commented Jul 2, 2019

Did some research. Anchor parameters (the bit after the #) do not get sent as part of the request, so the server never knows about them. Your code never got hit because those redirects never got hit. There is no way those redirects can do what they are attempting, so they can be removed.

That's a pain. Thanks for doing that research. Should we re-word sentences so the user doesn't expect to be taken directly to the section?

Loading

@eAlasdair
Copy link
Collaborator

@eAlasdair eAlasdair commented Jul 2, 2019

Did some research. Anchor parameters (the bit after the #) do not get sent as part of the request, so the server never knows about them. Your code never got hit because those redirects never got hit. There is no way those redirects can do what they are attempting, so they can be removed.

That's a pain. Thanks for doing that research. Should we re-word sentences so the user doesn't expect to be taken directly to the section?

Which sentences? Any current content will take the user directly to the section, because it uses the current style. It's just links to the old version can only link to the introduction page of the new version

Loading

@courtneycb
Copy link
Contributor Author

@courtneycb courtneycb commented Jul 2, 2019

Which sentences? Any current content will take the user directly to the section, because it uses the current style. It's just links to the old version can only link to the introduction page of the new version

Oh man, ignore me. Got confused with something else.

Loading

@courtneycb courtneycb merged commit 54a82c3 into develop Jul 2, 2019
4 checks passed
Loading
@courtneycb courtneycb deleted the url-redirect-fixes branch Jul 2, 2019
@courtneycb courtneycb mentioned this pull request Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants