mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
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:
parent
b988ce349c
commit
3da682b36b
11 changed files with 69 additions and 54 deletions
|
@ -2,10 +2,12 @@
|
||||||
layout: base
|
layout: base
|
||||||
lang: en
|
lang: en
|
||||||
---
|
---
|
||||||
{% if page.redirect != nil %}
|
|
||||||
<script>window.location.href='/en/alert/{{ page.redirect }}';</script>
|
{% if page.canonical != nil %}
|
||||||
<link rel="canonical" href="http://bitcoin.org/en/alert/{{ page.redirect }}"/>
|
<script>window.location.href='{{ page.canonical }}';</script>
|
||||||
|
<link rel="canonical" href="http://bitcoin.org{{ page.canonical }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link rel="alternate" type="application/rss+xml" href="/en/rss/alerts.rss" title="Bitcoin network status and alerts">
|
<link rel="alternate" type="application/rss+xml" href="/en/rss/alerts.rss" title="Bitcoin network status and alerts">
|
||||||
<div class="alerttext">
|
<div class="alerttext">
|
||||||
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>
|
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>
|
||||||
|
|
11
_layouts/redirect.html
Normal file
11
_layouts/redirect.html
Normal 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>
|
|
@ -2,10 +2,6 @@
|
||||||
layout: base
|
layout: base
|
||||||
lang: en
|
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">
|
<link rel="alternate" type="application/rss+xml" href="/en/rss/releases.rss" title="Bitcoin-Qt releases">
|
||||||
<div class="versiontext">
|
<div class="versiontext">
|
||||||
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>
|
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>
|
||||||
|
|
|
@ -881,6 +881,19 @@ h2 .rssicon{
|
||||||
font-weight:bold;
|
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{
|
.download{
|
||||||
text-align:center;
|
text-align:center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Jekyll
|
||||||
self.data['date'] = date
|
self.data['date'] = date
|
||||||
self.data['layout'] = 'alert'
|
self.data['layout'] = 'alert'
|
||||||
if dstdir == ''
|
if dstdir == ''
|
||||||
self.data['redirect'] = src.split('.')[0]
|
self.data['canonical'] = '/en/alert/' + src.split('.')[0]
|
||||||
else
|
else
|
||||||
self.data['category'] = 'alert'
|
self.data['category'] = 'alert'
|
||||||
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].length>0
|
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].length>0
|
||||||
|
|
|
@ -14,7 +14,8 @@ module Jekyll
|
||||||
self.data['date'] = year + '-' + month + '-' + day
|
self.data['date'] = year + '-' + month + '-' + day
|
||||||
self.data['layout'] = 'release'
|
self.data['layout'] = 'release'
|
||||||
if dstdir.index('/releases/') === 0
|
if dstdir.index('/releases/') === 0
|
||||||
self.data['redirect'] = dst.gsub('.md','')
|
self.data['redirect'] = '/en/release/' + dst.gsub('.md','')
|
||||||
|
self.data['layout'] = 'redirect'
|
||||||
else
|
else
|
||||||
self.data['category'] = 'release'
|
self.data['category'] = 'release'
|
||||||
if !site.config.has_key?('DOWNLOAD_DATE') or site.config['DOWNLOAD_DATE'] < year + '-' + month + '-' + day
|
if !site.config.has_key?('DOWNLOAD_DATE') or site.config['DOWNLOAD_DATE'] < year + '-' + month + '-' + day
|
||||||
|
|
|
@ -71,7 +71,7 @@ module Jekyll
|
||||||
next if !/\.html$/.match(file2)
|
next if !/\.html$/.match(file2)
|
||||||
#Ignore static redirect pages
|
#Ignore static redirect pages
|
||||||
data = File.read(file1+'/'+file2)
|
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 '<url>'
|
||||||
sitemap.puts ' <loc>http://bitcoin.org/'+file1+'/'+file2.gsub('.html','')+'</loc>'
|
sitemap.puts ' <loc>http://bitcoin.org/'+file1+'/'+file2.gsub('.html','')+'</loc>'
|
||||||
sitemap.puts '</url>'
|
sitemap.puts '</url>'
|
||||||
|
@ -81,7 +81,7 @@ module Jekyll
|
||||||
next if file1 == 'index.html'
|
next if file1 == 'index.html'
|
||||||
#Ignore static redirect pages and google webmaster tools
|
#Ignore static redirect pages and google webmaster tools
|
||||||
data = File.read(file1)
|
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 '<url>'
|
||||||
sitemap.puts ' <loc>http://bitcoin.org/'+file1.gsub('.html','')+'</loc>'
|
sitemap.puts ' <loc>http://bitcoin.org/'+file1.gsub('.html','')+'</loc>'
|
||||||
sitemap.puts '</url>'
|
sitemap.puts '</url>'
|
||||||
|
|
|
@ -22,9 +22,17 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TranslateRedirect < StaticFile
|
class PageRedirect < Page
|
||||||
def write(dest)
|
def initialize(site, base, lang, srcdir, src, dstdir, dst, red)
|
||||||
# do nothing
|
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,23 +71,16 @@ module Jekyll
|
||||||
end
|
end
|
||||||
redirects.each do |id,redirect|
|
redirects.each do |id,redirect|
|
||||||
next if redirect.has_key?('except') and redirect['except'].has_key?(lang)
|
next if redirect.has_key?('except') and redirect['except'].has_key?(lang)
|
||||||
src = locs[lang]['url'][id]
|
src = redirect['dst']
|
||||||
next if src.nil? or src == ''
|
src = src + '.html'
|
||||||
src = src+'.html'
|
dst = locs[lang]['url'][id]
|
||||||
dst = redirect['dst']
|
|
||||||
dst = locs[lang]['url'][dst]
|
|
||||||
next if dst.nil? or dst == ''
|
next if dst.nil? or dst == ''
|
||||||
if !File.directory?(site.dest + '/' + lang)
|
dst = dst + '.html'
|
||||||
Dir.mkdir(site.dest + '/' + lang)
|
red = redirect['dst']
|
||||||
end
|
red = locs[lang]['url'][red]
|
||||||
File.open(site.dest + '/' + lang + '/' + src, 'w+') do |file|
|
next if red.nil? or red == ''
|
||||||
file.puts '<!DOCTYPE HTML>'
|
red = '/' + lang + '/' + CGI::escape(red)
|
||||||
file.puts '<html><head>'
|
site.pages << PageRedirect.new(site, site.source, lang, '_templates', src, lang, dst, red)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
13
about.html
13
about.html
|
@ -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-->
|
layout: redirect
|
||||||
<html>
|
redirect: /en/faq
|
||||||
<head>
|
lang: en
|
||||||
<meta name="robots" content="noindex">
|
---
|
||||||
<script>window.location.href='/en/faq';</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
||||||
|
|
13
clients.html
13
clients.html
|
@ -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-->
|
layout: redirect
|
||||||
<html>
|
redirect: /en/choose-your-wallet
|
||||||
<head>
|
lang: en
|
||||||
<meta name="robots" content="noindex">
|
---
|
||||||
<script>window.location.href='/en/choose-your-wallet';</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
||||||
|
|
13
news.html
13
news.html
|
@ -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-->
|
layout: redirect
|
||||||
<html>
|
redirect: /en/version-history
|
||||||
<head>
|
lang: en
|
||||||
<meta name="robots" content="noindex">
|
---
|
||||||
<script>window.location.href='/en/version-history';</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue