Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 139
    • Merge requests 139
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !333

Open
Created Jul 26, 2017 by Georgios Dagkakis@georgios.dagkakisDeveloper
  • Report abuse
Report abuse

Draft: Always add trailing slashes in the urls of Web Sections and Web Sites

  • Overview 24
  • Commits 16
  • Changes 16

(First some background, that also gives rationale.)

In ERP5 when we have erp5/web_site_module/web_site_xxx/web_section_xxx and erp5/web_site_module/web_site_xxx/web_section_xxx/ they both return response code 200, and the user is typically directed to the same section. This causes duplicate content, that is bad for search engine optimisation.

For this reason, I started to check on what can be done and I asked @romain, who told me that also he for RenderJS to work, it is needed that trailing slash is always there. @gabriel worked on this some time ago, but without finalising. Explanation why RenderJS needs this in the message of 76b9d574

So I started from Gabriel's work and did required extensions.

(end of background)

This merge request introduces:

  • In Web Section, if the URL does not have a trailing slash, we raise a redirect (302) to the url with the slash added.
  • In Web Section we override absolute_url and absolute_url_path to return the url with the trailing slash. This is done to reduce redirects. This affects also Web Site behaviour (since it inherits from Web Section)
  • In Web Site, we make sure that when that language support does not create wrong urls now
  • There are some PythonScripts, like Base_doLanguage that had to be updated, since they use absolute_url of Web Section
  • There is the issue of having actions defined like ${object_url}/xxx, this now would return a double slash for Web Section. Generally, I think we should consider if such string definitions are the optimal, but the last commit 15b56f47 opts to provide compatibility with such definitions.

One big issue with this change, is that absolute_url now is different between Web Section/Site and other types. This is not optimal, but it would be dangerous to raise redirect all the time making sites slower.

Tests pass here (not the same revision you'll see, but because I just rebased and tests have not run yet), but it was run on the head of this.

Note I squashed @gabriel 's commits, his initial ones are here. I did not make any squash that includes both gabriel's and my commits together, in order to keep the author, even though the change in Web Section could semantically be one commit.

Since this affects a lot ERP5 Web and subsequently all projects that have web mode, I need to cc @nexedi Please provide comments and ideas

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: add_trailing_slash_to_url
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7