Normalize page redirections

Use a fallback HTML page with a manual and javascript redirect
Keep canonical pages only for alerts
This commit is contained in:
Saivann 2013-10-14 14:59:10 -04:00
parent b988ce349c
commit 3da682b36b
11 changed files with 69 additions and 54 deletions

View file

@ -2,10 +2,12 @@
layout: base
lang: en
---
{% if page.redirect != nil %}
<script>window.location.href='/en/alert/{{ page.redirect }}';</script>
<link rel="canonical" href="http://bitcoin.org/en/alert/{{ page.redirect }}"/>
{% if page.canonical != nil %}
<script>window.location.href='{{ page.canonical }}';</script>
<link rel="canonical" href="http://bitcoin.org{{ page.canonical }}"/>
{% endif %}
<link rel="alternate" type="application/rss+xml" href="/en/rss/alerts.rss" title="Bitcoin network status and alerts">
<div class="alerttext">
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>

11
_layouts/redirect.html Normal file
View file

@ -0,0 +1,11 @@
---
layout: base
---
<meta name="robots" content="noindex">
<script>window.location.href='{{ page.redirect }}';</script>
<div class="redirectmsg">
<h1>This page has been moved</h1>
<p><a href="{{ page.redirect }}">bitcoin.org{{ page.redirect }}</a></p>
</div>

View file

@ -2,10 +2,6 @@
layout: base
lang: en
---
{% if page.redirect != nil %}
<script>window.location.href='/en/release/{{ page.redirect }}';</script>
<link rel="canonical" href="http://bitcoin.org/en/release/{{ page.redirect }}"/>
{% endif %}
<link rel="alternate" type="application/rss+xml" href="/en/rss/releases.rss" title="Bitcoin-Qt releases">
<div class="versiontext">
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>

View file

@ -881,6 +881,19 @@ h2 .rssicon{
font-weight:bold;
}
.redirectmsg{
text-align:center;
margin:20px 0px;
}
.redirectmsg h1{
color:#7b7c7c;
font-weight:400;
font-size:180%;
}
.redirectmsg p{
font-size:150%;
}
.download{
text-align:center;
}

View file

@ -14,7 +14,7 @@ module Jekyll
self.data['date'] = date
self.data['layout'] = 'alert'
if dstdir == ''
self.data['redirect'] = src.split('.')[0]
self.data['canonical'] = '/en/alert/' + src.split('.')[0]
else
self.data['category'] = 'alert'
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].length>0

View file

@ -14,7 +14,8 @@ module Jekyll
self.data['date'] = year + '-' + month + '-' + day
self.data['layout'] = 'release'
if dstdir.index('/releases/') === 0
self.data['redirect'] = dst.gsub('.md','')
self.data['redirect'] = '/en/release/' + dst.gsub('.md','')
self.data['layout'] = 'redirect'
else
self.data['category'] = 'release'
if !site.config.has_key?('DOWNLOAD_DATE') or site.config['DOWNLOAD_DATE'] < year + '-' + month + '-' + day

View file

@ -71,7 +71,7 @@ module Jekyll
next if !/\.html$/.match(file2)
#Ignore static redirect pages
data = File.read(file1+'/'+file2)
next if !data.index('window.location.href=').nil?
next if !data.index('window.location.href=').nil? or !data.index('redirect:').nil?
sitemap.puts '<url>'
sitemap.puts ' <loc>http://bitcoin.org/'+file1+'/'+file2.gsub('.html','')+'</loc>'
sitemap.puts '</url>'
@ -81,7 +81,7 @@ module Jekyll
next if file1 == 'index.html'
#Ignore static redirect pages and google webmaster tools
data = File.read(file1)
next if !data.index('window.location.href=').nil? or !data.index('google-site-verification:').nil?
next if !data.index('window.location.href=').nil? or !data.index('redirect:').nil? or !data.index('google-site-verification:').nil?
sitemap.puts '<url>'
sitemap.puts ' <loc>http://bitcoin.org/'+file1.gsub('.html','')+'</loc>'
sitemap.puts '</url>'

View file

@ -22,9 +22,17 @@ module Jekyll
end
end
class TranslateRedirect < StaticFile
def write(dest)
# do nothing
class PageRedirect < Page
def initialize(site, base, lang, srcdir, src, dstdir, dst, red)
@site = site
@base = base
@dir = '/'+dstdir
@name = dst
self.process(dst)
self.read_yaml(File.join(base, srcdir), src)
self.data['lang'] = lang
self.data['redirect'] = red
self.data['layout'] = 'redirect'
end
end
@ -63,23 +71,16 @@ module Jekyll
end
redirects.each do |id,redirect|
next if redirect.has_key?('except') and redirect['except'].has_key?(lang)
src = locs[lang]['url'][id]
next if src.nil? or src == ''
src = redirect['dst']
src = src + '.html'
dst = redirect['dst']
dst = locs[lang]['url'][dst]
dst = locs[lang]['url'][id]
next if dst.nil? or dst == ''
if !File.directory?(site.dest + '/' + lang)
Dir.mkdir(site.dest + '/' + lang)
end
File.open(site.dest + '/' + lang + '/' + src, 'w+') do |file|
file.puts '<!DOCTYPE HTML>'
file.puts '<html><head>'
file.puts '<meta name="robots" content="noindex">'
file.puts '<script>window.location.href=\'/'+lang+'/'+CGI::escape(dst)+'\';</script>'
file.puts '</head></html>'
end
site.static_files << TranslateRedirect.new(site, site.source, '', lang+'/'+src)
dst = dst + '.html'
red = redirect['dst']
red = locs[lang]['url'][red]
next if red.nil? or red == ''
red = '/' + lang + '/' + CGI::escape(red)
site.pages << PageRedirect.new(site, site.source, lang, '_templates', src, lang, dst, red)
end
end
end

View file

@ -1,8 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Javascript redirect to the new url-->
<html>
<head>
<meta name="robots" content="noindex">
<script>window.location.href='/en/faq';</script>
</head>
</html>
---
layout: redirect
redirect: /en/faq
lang: en
---

View file

@ -1,8 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Javascript redirect to the new url-->
<html>
<head>
<meta name="robots" content="noindex">
<script>window.location.href='/en/choose-your-wallet';</script>
</head>
</html>
---
layout: redirect
redirect: /en/choose-your-wallet
lang: en
---

View file

@ -1,8 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Javascript redirect to the new url-->
<html>
<head>
<meta name="robots" content="noindex">
<script>window.location.href='/en/version-history';</script>
</head>
</html>
---
layout: redirect
redirect: /en/version-history
lang: en
---