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

Conversation

@courtneycb
Copy link
Contributor

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.

@courtneycb courtneycb requested review from JackMorganNZ and eAlasdair Jul 1, 2019

@courtneycb courtneycb self-assigned this Jul 1, 2019

@eAlasdair

This comment has been minimized.

Copy link
Member

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.

@courtneycb

This comment has been minimized.

Copy link
Contributor Author

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?

@eAlasdair

This comment has been minimized.

Copy link
Member

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

@courtneycb

This comment has been minimized.

Copy link
Contributor Author

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.

@courtneycb courtneycb removed the help wanted label Jul 2, 2019

@courtneycb courtneycb merged commit 54a82c3 into develop Jul 2, 2019

4 checks passed

codecov/patch 100% of diff hit (target 96.07%)
Details
codecov/project 96.07% (+<.01%) compared to 3023f1b
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@courtneycb courtneycb deleted the url-redirect-fixes branch Jul 2, 2019

@courtneycb courtneycb referenced this pull request Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.