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

Fix redirects #649

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@
page '/documentation/*', :layout => :section_reference
page '/blog/*', :layout => :blog

for dir in ['docs/yardoc', 'documentation'] do
redirect "#{dir}/file.SASS_REFERENCE.html", to: '/documentation'
redirect "#{dir}/file.SASS_CHANGELOG.html", to: 'https://github.com/sass/dart-sass/blob/master/CHANGELOG.md'
redirect "#{dir}/file.INDENTED_SYNTAX.html", to: '/documentation/syntax'
redirect "#{dir}/file.SCSS_FOR_SASS_USERS.html", to: '/documentation/syntax'
redirect "#{dir}/Sass/Script/Functions.html", to: '/documentation/modules'
redirect "#{dir}/Sass/Script/Functions.html", to: '/documentation/modules'
redirect "#{dir}/functions.html", to: '/documentation/functions'
redirect "#{dir}/functions/css.html", to: '/documentation/at-rules/function#plain-css-functions'

Dir['source/documentation/modules/*.html.md.erb'].each do |file|
module_name = File.basename(file, ".html.md.erb")
redirect "#{dir}/functions/#{module_name}.html", to: "/documentation/modules/#{module_name}"
end
end

Dir['source/documentation/breaking-changes/**'].each do |file|
basename = File.basename(file).gsub(/\..*/, '')
redirect "d/#{basename}.html", to: "/documentation/breaking-changes/#{basename}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only nitpick is that before some redirects were any /d/whatever to /doc.../break.../whatever, regardless of whether the url was known or not, and now it redirects on known URLs only

(Same on others)

I assume that's intended because it would throw 404 regardless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These redirects are actually compiled down to HTML pages with <meta http-equiv="refresh"> tags, so we unfortunately can't do wildcard redirects anymore. Otherwise I'd keep them if I could.

end

redirect 'tutorial.html', to: '/guide'
redirect 'download.html', to: '/install'
redirect 'try.html', to: 'http://sassmeister.com'
redirect 'about.html', to: '/'
redirect 'blog/posts/560719.html', to: '/blog/dropping-support-for-old-ruby-versions'
redirect 'blog/posts/1305238.html', to: '/blog/dart-sass-is-on-chocolatey'
redirect 'blog/posts/1404451.html', to: '/blog/sass-and-browser-compatibility'
redirect 'blog/posts/1909151.html', to: '/blog/dart-sass-is-in-beta'
redirect 'blog/posts/7081811.html', to: '/blog/ruby-sass-is-deprecated'

configure :development do
config[:host] = 'http://localhost:4567'
end
Expand Down
38 changes: 0 additions & 38 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,6 @@ require "rack/contrib/try_static"
# Make sure we don't force SSL on domains that don't have SSL certificates.
use Rack::Conditional, proc {|env| env["SERVER_NAME"] == "sass-lang.com"}, Rack::SSL

use Rack::Rewrite do
r301 %r{/docs/yardoc/(.*)}, '/documentation/$1'
r301 '/tutorial.html', '/guide'
r301 '/download.html', '/install'
r301 '/try', 'http://sassmeister.com'
r301 '/try.html', 'http://sassmeister.com'
r301 '/about', '/'
r301 '/about.html', '/'

r301 '/documentation/file.SASS_REFERENCE.html', '/documentation'
r301 '/documentation/file.SASS_CHANGELOG.html', 'https://github.com/sass/dart-sass/blob/master/CHANGELOG.md'
r301 '/documentation/file.INDENTED_SYNTAX.html', '/documentation/syntax'
r301 '/documentation/file.SCSS_FOR_SASS_USERS.html', '/documentation/syntax'
r301 '/documentation/Sass/Script/Functions.html', '/documentation/modules'
r301 '/documentation/Sass/Script/Functions', '/documentation/modules'
r301 %r{/documentation/(Sass.*)}, 'http://www.rubydoc.info/gems/sass/$1'
r301 '/documentation/functions/css', '/documentation/at-rules/function#plain-css-functions'
r301 %r{/documentation/functions(.*)}, '/documentation/modules$1'

r301 %r{/(.+)/$}, '/$1'
r301 %r{/(.+)/index\.html$}, '/$1'

# We used to redirect Logdown URLs to the sass.logdown.com, but now we
# redirect them to the local site's corresponding blog URLs.
r301 %r{/blog/posts/\d+-(.*)}, '/blog/$1'

# Some blog posts didn't have slugs in Logdown.
r301 %r{/blog/posts/560719}, '/blog/dropping-support-for-old-ruby-versions'
r301 %r{/blog/posts/1305238}, '/blog/dart-sass-is-on-chocolatey'
r301 %r{/blog/posts/1404451}, '/blog/sass-and-browser-compatibility'
r301 %r{/blog/posts/1909151}, '/blog/dart-sass-is-in-beta'
r301 %r{/blog/posts/7081811}, '/blog/ruby-sass-is-deprecated'

# Provide short links for breaking changes so that they can be tersely
# referenced from warning and errors.
r301 %r{/d/(.*)}, '/documentation/breaking-changes/$1'
end

use Rack::Deflater

use Rack::TryStatic,
Expand Down