Skip to content

Commit

Permalink
Fix redirects including URL fragments (#1424)
Browse files Browse the repository at this point in the history
* Update changelog page and contributors

* Don't render canonical man pages as redirects

Middleman redirects create pages with empty body that request a client
side redirect through meta tags. This does not play nice with URL
fragments.

Also, I suspect this is why our SEO is not great at the moment.

* Only add a canonical tag to the latest version of man pages

The `/v2.6/man/` and `/v2.5/man/` urls actually serve different content,
so they should not all have the same canonical URL. Only make `/man/` the
canonical page of the latest version, `/v2.6/man/`.
  • Loading branch information
deivid-rodriguez authored Jan 8, 2025
1 parent c067907 commit 6da0c6e
Show file tree
Hide file tree
Showing 39 changed files with 74 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ source/conduct.html.md
source/doc

# man pages built from the bundler repo
/source/man/
/source/v*/man/

# deploy key
Expand Down
9 changes: 1 addition & 8 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,14 @@
redirect "v#{version}/guides/bundler_2_upgrade.html", to: "guides/bundler_2_upgrade.html"
end

# Redirect to the latest man page when version isn't specified
man_files = Dir.glob("./source/#{config[:current_version]}/man/*.html.erb")
man_files.each do |file|
url = file.delete_prefix("./source/#{config[:current_version]}/").delete_suffix(".erb")
latest_man = "#{config[:current_version]}/#{url}"
redirect url, to: latest_man
end

redirect "sponsors.html", to: "https://rubygems.org/pages/sponsors" # Backwards compatibility

page "/changelog.html", layout: :two_column_layout
page "/conduct.html", layout: :two_column_layout
page "/compatibility.html", layout: :two_column_layout
page /\/v(\d+.\d+)\/(?!bundle_|commands|docs|man)(.*)/, layout: :two_column_layout
page /\/v(.*)\/man\/(.*)/, layout: :two_column_layout
page /man\/(.*)/, layout: :two_column_layout
page /\/v(.*)\/guides\/(.*)/, layout: :two_column_layout
page /guides\/(.*)/, layout: :two_column_layout
page /\/doc\/(.*)/, layout: :two_column_layout # Imported from rubygems/bundler
Expand Down
18 changes: 9 additions & 9 deletions data/contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
:commits: 303
:href: https://github.com/bronzdoc
:name: bronzdoc
- :avatar_url: https://avatars.githubusercontent.com/u/193936?v=4&s=40
:commits: 285
:href: https://github.com/simi
:name: simi
- :avatar_url: https://avatars.githubusercontent.com/in/29110?v=4&s=40
:commits: 283
:commits: 290
:href: https://github.com/apps/dependabot
:name: dependabot[bot]
- :avatar_url: https://avatars.githubusercontent.com/u/193936?v=4&s=40
:commits: 287
:href: https://github.com/simi
:name: simi
- :avatar_url: https://avatars.githubusercontent.com/u/237?v=4&s=40
:commits: 278
:href: https://github.com/chad
Expand Down Expand Up @@ -335,6 +335,10 @@
:commits: 14
:href: https://github.com/Shekharrajak
:name: Shekharrajak
- :avatar_url: https://avatars.githubusercontent.com/u/24788699?v=4&s=40
:commits: 14
:href: https://github.com/soda92
:name: soda92
- :avatar_url: https://avatars.githubusercontent.com/u/174?v=4&s=40
:commits: 14
:href: https://github.com/wilson
Expand Down Expand Up @@ -415,10 +419,6 @@
:commits: 11
:href: https://github.com/ryanfox1985
:name: ryanfox1985
- :avatar_url: https://avatars.githubusercontent.com/u/24788699?v=4&s=40
:commits: 11
:href: https://github.com/soda92
:name: soda92
- :avatar_url: https://avatars.githubusercontent.com/u/22021150?v=4&s=40
:commits: 10
:href: https://github.com/ankitkataria
Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/versions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace :versions do
render_whats_new(succ)
puts "Creating announcement blog post..."
sh "middleman article 'Bundler #{succ}'"
puts "Updating latest version symlinks..."
Dir.glob("source/#{succ}/man/*.html.erb") do |file|
url = file.delete_prefix("source/#{succ}/")
latest_man = "source/#{url}"
FileUtils.ln_sf Pathname.new(file).relative_path_from(File.dirname(latest_man)), latest_man
end
end
end

Expand Down
24 changes: 24 additions & 0 deletions source/changelog.html.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# 3.6.2 / 2024-12-23

## Security:

* Fix Gem::SafeMarshal buffer overrun when given lengths larger than fit
into a byte. Pull request
[#8305](https://github.com/rubygems/rubygems/pull/8305) by segiddins
* Improve type checking in marshal_load methods. Pull request
[#8306](https://github.com/rubygems/rubygems/pull/8306) by segiddins

## Enhancements:

* Skip rdoc hooks and their tests on newer rdoc versions. Pull request
[#8340](https://github.com/rubygems/rubygems/pull/8340) by
deivid-rodriguez
* Installs bundler 2.6.2 as a default gem.

## Bug fixes:

* Fix serialized metadata including an empty `@original_platform`
attribute. Pull request
[#8355](https://github.com/rubygems/rubygems/pull/8355) by
deivid-rodriguez

# 3.6.1 / 2024-12-17

## Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion source/layouts/two_column_layout.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- is_command = command?(current_page.url) || whats_new?(current_page.url)
- v = current_page.url.scan(/v\d\.\d+/).first || current_version

- if /v\d\.\d+\//.match?(current_page.destination_path)
- if current_page.destination_path.start_with?(current_version)
- content_for(:canonical, commands_toplevel_path(current_page.destination_path))

~ wrap_layout :base do
Expand Down
1 change: 1 addition & 0 deletions source/man/bundle-add.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-binstubs.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-cache.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-check.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-clean.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-config.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-console.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-doctor.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-env.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-exec.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-fund.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-gem.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-help.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-info.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-init.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-inject.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-install.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-issue.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-licenses.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-list.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-lock.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-open.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-outdated.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-platform.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-plugin.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-pristine.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-remove.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-show.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-update.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-version.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle-viz.1.html.erb
1 change: 1 addition & 0 deletions source/man/bundle.1.html.erb
1 change: 1 addition & 0 deletions source/man/gemfile.5.html.erb

0 comments on commit 6da0c6e

Please sign in to comment.