mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
redirect blog path to subdomain
This commit is contained in:
parent
07a1d569b7
commit
766ca009ca
1 changed files with 2 additions and 17 deletions
19
app/blog.rb
19
app/blog.rb
|
@ -1,22 +1,7 @@
|
||||||
require 'net/http'
|
|
||||||
require 'uri'
|
|
||||||
|
|
||||||
get '/blog/?' do
|
get '/blog/?' do
|
||||||
expires 60, :public, :must_revalidate
|
redirect 'https://blog.neocities.org', 301
|
||||||
return Net::HTTP.get_response(URI('http://blog.neocities.org')).body
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/blog/:article' do |article|
|
get '/blog/:article' do |article|
|
||||||
expires 60, :public, :must_revalidate
|
redirect "https://blog.neocities.org/#{article}.html", 301
|
||||||
|
|
||||||
attempted = false
|
|
||||||
|
|
||||||
begin
|
|
||||||
return Net::HTTP.get_response(URI("http://blog.neocities.org/#{article}.html")).body
|
|
||||||
rescue => e
|
|
||||||
raise e if attempted
|
|
||||||
attempted = true
|
|
||||||
article = article.match(/^[a-zA-Z0-9-]+/).to_s
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue