Add "Network status and alerts" page and RSS feed (fixes #170)

Generate alerts pages through alerts.rb plugin
Allow to keep short alias urls for each alert
Move alert pages in _alerts
Update sitemap plugin to include alerts
This commit is contained in:
Saivann 2013-06-18 23:50:37 -04:00
parent cd597fdb21
commit ec44853934
18 changed files with 385 additions and 54 deletions

View file

@ -69,9 +69,9 @@ Any change in the english texts can be done through a pull request on github. If
## Advanced Usage ## Advanced Usage
### Alerts ### Alert banner
You can easily put an alert on the website by changing the ALERT and ALERT\_CLASS variables in _config.yml. You can put an alert banner on the website by changing the ALERT and ALERT\_CLASS variables in _config.yml.
You can both set one fallback alert for all languages and many translated alerts for specific languages. You can both set one fallback alert for all languages and many translated alerts for specific languages.
Example: Example:
@ -88,6 +88,32 @@ ALERT_CLASS:
This will produce an english red alert box for all languages, and a translated red alert box for french language. This will produce an english red alert box for all languages, and a translated red alert box for french language.
Possible classes are: **error** (red), **info** (blue), **success** (green) and **warning** (yellow) Possible classes are: **error** (red), **info** (blue), **success** (green) and **warning** (yellow)
### Network alerts
Network alerts should be placed in `_alerts/YYYY-MM-DD-SHORTITLE.html` and adhere to this format:
```
---
title: "11/12 March 2013 Chain Fork"
lastmod: "Fri Mar 16 22:58:00 UTC 2012"
alias: "chainfork"
active: true
---
<p>
A chain fork is happening. Please stop mining on bitcoin version 0.8.0. Your bitcoins are safe but it is recommended that you postpone your Bitcoin transactions for the next hours.
</p>
<p>
More information will follow.
</p>
```
* `SHORTTITLE` is used to construct the URL.
* `title: ...` will be used as the title in the layout.
* `lastmod: ...` will be used as the last modification date in the layout.
* `alias: ...` (optional) a short alias to be used for Bitcoin-Qt alerts. Ex. "dos" will produce /dos.html
* `active: ...` (true or false) define if the alert should appear as ongoing in the network status page.
### Release Notes ### Release Notes
Release notes should be placed in `_posts/releases/YEAR-MONTH-DAY-SHORTTITLE.md` and adhere to this format: Release notes should be placed in `_posts/releases/YEAR-MONTH-DAY-SHORTTITLE.md` and adhere to this format:

View file

@ -1,11 +1,9 @@
--- ---
layout: base
lang: en
title: "February 20, 2012 Protocol Changes" title: "February 20, 2012 Protocol Changes"
lastmod: "Mon Feb 20 00:10:00 UTC 2012"
alias: "feb20"
active: false
--- ---
<div class="container">
<section id="feb20">
<h1>February 20, 2012 Protocol Changes</h1>
<p> <p>
In June 2010 the Bitcoin reference software version 0.2.10 introduced In June 2010 the Bitcoin reference software version 0.2.10 introduced
a change to the protocol: the 'version' messages exchanged by nodes a change to the protocol: the 'version' messages exchanged by nodes
@ -36,8 +34,3 @@ channel</a> on Freenode IRC.
If there are unexpected difficulties this page will be updated with If there are unexpected difficulties this page will be updated with
relevant information. relevant information.
</p> </p>
<div style="text-align:right">
<i>This notice last updated: Mon Feb 20 00:10:00 UTC 2012</i>
</div>
</section>
</div>

View file

@ -1,11 +1,9 @@
--- ---
layout: base
lang: en
title: "Potentially Critical Security Vulnerability" title: "Potentially Critical Security Vulnerability"
lastmod: "Fri Mar 16 22:58:00 UTC 2012"
alias: "critfix"
active: false
--- ---
<div class="container">
<section id="critfix">
<h1>Potentially Critical Security Vulnerability</h1>
<p> <p>
A potential security vulnerability has been discovered in the Windows A potential security vulnerability has been discovered in the Windows
version of Bitcoin-Qt. If you are running Bitcoin-Qt versions 0.5 version of Bitcoin-Qt. If you are running Bitcoin-Qt versions 0.5
@ -227,9 +225,3 @@ href="https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.0/test/
href="https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.3/"> href="https://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.5.3/">
0.5.3.1 för Windows och 0.5.3 för Linux</a> 0.5.3.1 för Windows och 0.5.3 för Linux</a>
</p> </p>
<div style="text-align:right">
<i>This notice last updated: Fri Mar 16 22:58:00 UTC 2012</i>
</div>
</section>
</div>

View file

@ -1,11 +1,9 @@
--- ---
layout: base
lang: en
title: "CVE-2012-2459: Critical Vulnerability (denial-of-service)" title: "CVE-2012-2459: Critical Vulnerability (denial-of-service)"
lastmod: "Mon May 14 17:00:00 UTC 2012"
alias: "dos"
active: false
--- ---
<div class="container">
<section id="dos">
<h1>CVE-2012-2459: Critical Vulnerability (denial-of-service)</h1>
<h2>Risks</h2> <h2>Risks</h2>
<p> <p>
A denial-of-service vulnerability that affects all versions of A denial-of-service vulnerability that affects all versions of
@ -61,8 +59,3 @@ Could this bug be used to install malware on my system?
<p> <p>
No. No.
</p> </p>
<div style="text-align:right">
<i>This notice last updated: Mon May 14 17:00:00 UTC 2012</i>
</div>
</section>
</div>

View file

@ -1,11 +1,9 @@
--- ---
layout: base
lang: en
title: "11/12 March 2013 Chain Fork Information" title: "11/12 March 2013 Chain Fork Information"
lastmod: "16 May 2013 01:37 UTC"
alias: "chainfork"
active: false
--- ---
<div class="container">
<section id="dos">
<h1>11/12 March 2013 Chain Fork Information</h1>
<h2>What happened</h2> <h2>What happened</h2>
<p> <p>
A bitcoin miner running version 0.8.0 created a large block (at height 225,430) that is incompatible A bitcoin miner running version 0.8.0 created a large block (at height 225,430) that is incompatible
@ -37,8 +35,3 @@ The core developers have investigated what caused the old versions to reject the
blocks, and have released a 0.8.1 version that avoids creating blocks that are incompatible with blocks, and have released a 0.8.1 version that avoids creating blocks that are incompatible with
older versions. <a href="https://en.bitcoin.it/wiki/BIP_50">A full post-mortem document has been published</a>. older versions. <a href="https://en.bitcoin.it/wiki/BIP_50">A full post-mortem document has been published</a>.
</p> </p>
<div style="text-align:right">
<i>This notice last updated: 16 May 2013 01:37 UTC</i>
</div>
</section>
</div>

View file

@ -1,11 +1,9 @@
--- ---
layout: base
lang: en
title: "15 May 2013 Upgrade Deadline" title: "15 May 2013 Upgrade Deadline"
lastmod: "10 May 2013 21:30 UTC"
alias: "may15"
active: false
--- ---
<div class="container">
<section id="upgrade">
<h1>15 May 2013 Upgrade Deadline</h1>
<h2>What is happening</h2> <h2>What is happening</h2>
<p> <p>
If you are using an old version of Bitcoin-Qt (or bitcoind, the server bitcoin software), If you are using an old version of Bitcoin-Qt (or bitcoind, the server bitcoin software),
@ -68,8 +66,3 @@ that bug, we determined that the bug can happen even if the entire network was
still running old versions of Bitcoin-Qt/bitcoind. Therefore, the only option is to still running old versions of Bitcoin-Qt/bitcoind. Therefore, the only option is to
require everybody to either upgrade or workaround the bug. require everybody to either upgrade or workaround the bug.
</p> </p>
<div style="text-align:right">
<i>This notice last updated: 10 May 2013 21:30 UTC</i>
</div>
</section>
</div>

17
_layouts/alert.html Normal file
View file

@ -0,0 +1,17 @@
---
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 }}"/>
{% endif %}
<link rel="alternate" type="application/rss+xml" href="/en/rss/alerts.rss" title="Bitcoin network status and alerts">
<div class="versiontext">
<h1>{{ page.title }}<br><small>{{ page.date | date:"%e %B %Y" }}</small></h1>
{{ content }}
<div style="text-align:right">
<i>This notice last updated: {{ page.lastmod }}</i>
</div>
</div>
<a href="/en/alerts">Go back to the network alerts history</a>

View file

@ -95,7 +95,7 @@ menu:
<a href="/{{ page.lang }}/{% translate support-bitcoin url %}"><img src="/img/but_involve.svg" alt="Icon">{% translate button-support layout %}</a> <a href="/{{ page.lang }}/{% translate support-bitcoin url %}"><img src="/img/but_involve.svg" alt="Icon">{% translate button-support layout %}</a>
</div> </div>
</div> </div>
<div id="footer"><div>{% translate footer layout %}</div></div> <div id="footer"><div><a href="/en/alerts">Network Status</a><span>{% translate footer layout %}</span></div></div>
</div> </div>
<script type="text/javascript">svgfallback();</script> <script type="text/javascript">svgfallback();</script>
</body> </body>

View file

@ -382,6 +382,9 @@ li p{
#footer div{ #footer div{
padding-top:6px; padding-top:6px;
} }
#footer>div>a{
margin-right:15px;
}
/*Styles specific to elements in pages*/ /*Styles specific to elements in pages*/
@ -624,6 +627,27 @@ li p{
text-align:left; text-align:left;
margin-bottom:40px; margin-bottom:40px;
} }
.rssicon{
vertical-align:bottom;
margin-bottom:9px;
margin-left:10px;
}
.alertstatusinactive{
font-size:130%;
color:#0d579b;
margin-bottom:30px;
}
.alertstatusactive{
font-size:130%;
color:#d57700;
margin-bottom:30px;
}
.alertsactive{
margin-bottom:20px;
}
.alertsactive a{
font-weight:bold;
}
.download a{ .download a{
font-size:125%; font-size:125%;

49
_plugins/alerts.rb Normal file
View file

@ -0,0 +1,49 @@
require 'yaml'
module Jekyll
class AlertPage < Page
def initialize(site, base, lang, srcdir, src, dstdir, dst, date)
@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['date'] = date
self.data['layout'] = 'alert'
if dstdir == ''
self.data['redirect'] = src.split('.')[0]
else
self.data['category'] = 'alert'
if self.data.has_key?('alias')
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['alias']+'.html', date)
end
end
end
end
class AlertPageGenerator < Generator
def generate(site)
#generate each alert based on templates
Dir.foreach('_alerts') do |file|
next if file == '.' or file == '..'
lang = 'en'
src = file
dst = file
srcdir = '_alerts'
dstdir = lang + '/alert'
date = dst.split('-')
next if date.length < 4
date = date[0] + '-' + date[1] + '-' + date[2]
next if !/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.match(date)
site.pages << AlertPage.new(site, site.source, lang, '_alerts', src, dstdir, dst, date)
end
#TODO alerts are only generated for english language,
#but they could also be translated at some point. They would however
#need to fallback to english when no translation is available.
end
end
end

49
_plugins/catpage_for.rb Normal file
View file

@ -0,0 +1,49 @@
#catpage_for allows to loop in site.pages sorted by custom page
#variables and filtered by page.category.
#Example : {% catpage_for p in site.pages sort_by:date category:release %}
module Jekyll
module SortedForImpl
def render(context)
sorted_collection = collection_to_sort context
return if sorted_collection.empty?
sort_attr = @attributes['sort_by']
category_attr = @attributes['category']
#filter page by given category
s = []
for x in sorted_collection
if x.to_liquid.has_key?('category') && x.to_liquid['category'] == category_attr
s.push(x)
end
end
sorted_collection = s
#sort collection by given variable
sorted_collection = sorted_collection.sort_by { |i| i.to_liquid[sort_attr] }
#return modified array
original_name = @collection_name
result = nil
context.stack do
sorted_collection_name = "#{@collection_name}_sorted".sub('.', '_')
context[sorted_collection_name] = sorted_collection
@collection_name = sorted_collection_name
result = super
@collection_name = original_name
end
result
end
end
class SortedForTag < Liquid::For
include SortedForImpl
def collection_to_sort(context)
return context[@collection_name].dup
end
def end_tag
'endcatpage_for'
end
end
end
Liquid::Template.register_tag('catpage_for', Jekyll::SortedForTag)

View file

@ -66,6 +66,13 @@ module Jekyll
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>'
end end
#Add english alerts pages
Dir.foreach('_alerts') do |file|
next if file == '.' or file == '..'
sitemap.puts '<url>'
sitemap.puts ' <loc>http://bitcoin.org/en/alert/'+file.gsub('.html','')+'</loc>'
sitemap.puts '</url>'
end
#Add posts #Add posts
site.posts.each do |post| site.posts.each do |post|
sitemap.puts '<url>' sitemap.puts '<url>'

View file

@ -21,6 +21,9 @@ h3 .ieimg{
#footer{ #footer{
width:800px; width:800px;
} }
#footer div a{
margin-right:expression(this.parentNode.nodeName=='DIV'?'15px':'');
}
#content{ #content{
width: 690px; width: 690px;
overflow:hidden; overflow:hidden;

31
en/alerts.html Normal file
View file

@ -0,0 +1,31 @@
---
layout: base
lang: en
id: alerts
title: Network status and alerts - Bitcoin
---
<link rel="alternate" type="application/rss+xml" href="/en/rss/alerts.rss" title="Bitcoin network status and alerts">
<div class="versiontext">
<h1>Network status and alerts<a type="application/rss+xml" href="/en/rss/alerts.rss"><img src="/img/icon_rss.svg" alt="rss" class="rssicon"></a></h1>
{% assign active = false %}{% catpage_for p in site.pages reversed sort_by:date category:alert %}{% if p.active == true %}{% assign active = true %}{% endif %}{% endcatpage_for %}
{% if active == false %}
<div class="alertstatusinactive">There is no ongoing event on the Bitcoin network.</div>
{% else %}
<div class="alertstatusactive"">The following network event is ongoing.</div>
<ul class="alertsactive">
{% catpage_for p in site.pages reversed sort_by:date category:alert %}{% if p.active == true %}
<li>
{{ p.date | date:"%Y-%m-%d" }} - <a href="{{ p.url | replace:'.html','' }}">{{ p.title }}</a>
</li>
{% endif %}{% endcatpage_for %}
</ul>
{% endif %}
<ul class="alertsinactive">
{% catpage_for p in site.pages reversed sort_by:date category:alert %}{% if p.active == false %}
<li>
{{ p.date | date:"%Y-%m-%d" }} - <a href="{{ p.url | replace:'.html','' }}">{{ p.title }}</a>
</li>
{% endif %}{% endcatpage_for %}
</ul>
<p>See the complete <a href="https://en.bitcoin.it/wiki/Common_Vulnerabilities_and_Exposures">CVE list</a>.</p>
</div>

21
en/rss/alerts.rss Normal file
View file

@ -0,0 +1,21 @@
---
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Bitcoin network status and alerts</title>
<link>http://bitcoin.org/en/alerts</link>
<description>This RSS feed allows to follow events and alerts surrounding the Bitcoin network and software.</description>
<image>
<url>http://bitcoin.org/img/logo_rss.png</url>
<link>http://bitcoin.org/en/alerts</link>
</image>
{% catpage_for p in site.pages reversed sort_by:date category:alert %}
<item>
<title>{{ p.title }}</title>
<link>http://bitcoin.org{{ p.url | replace:'.html','' }}</link>
<pubDate>{{ p.date | date: "%a, %d %b %Y" }}</pubDate>
</item>
{% endcatpage_for %}
</channel>
</rss>

BIN
img/icon_rss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

140
img/icon_rss.svg Normal file
View file

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="22"
height="22"
id="RSSicon"
viewBox="0 0 44 44"
inkscape:version="0.48.4 r9939"
sodipodi:docname="Feed-icon.svg"
inkscape:export-filename="/home/zxz/Bureau/Feed-icon.png"
inkscape:export-xdpi="15.46875"
inkscape:export-ydpi="15.46875">
<metadata
id="metadata34">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="1026"
id="namedview32"
showgrid="false"
inkscape:zoom="14.75"
inkscape:cx="5.8127281"
inkscape:cy="20.305759"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="RSSicon" />
<defs
id="defs3">
<linearGradient
x1="30.059999"
y1="30.059999"
x2="225.94"
y2="225.94"
id="RSSg"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.17167638,0,0,0.17167638,0,0.05084741)">
<stop
offset="0.0"
stop-color="#E3702D"
id="stop6" />
<stop
offset="0.1071"
stop-color="#EA7D31"
id="stop8" />
<stop
offset="0.3503"
stop-color="#F69537"
id="stop10" />
<stop
offset="0.5"
stop-color="#FB9E3A"
id="stop12" />
<stop
offset="0.7016"
stop-color="#EA7C31"
id="stop14" />
<stop
offset="0.8866"
stop-color="#DE642B"
id="stop16" />
<stop
offset="1.0"
stop-color="#D95B29"
id="stop18" />
</linearGradient>
</defs>
<rect
width="43.94915"
height="43.94915"
rx="9.4422007"
ry="9.4422007"
x="0"
y="0.050847374"
id="rect20"
style="fill:#cc5d15" />
<rect
width="42.232391"
height="42.232391"
rx="8.5838194"
ry="8.5838194"
x="0.85838193"
y="0.90922946"
id="rect22"
style="fill:#f49c52" />
<rect
width="40.515625"
height="40.515625"
rx="8.0687895"
ry="8.0687895"
x="1.7167639"
y="1.7676115"
id="rect24"
style="fill:url(#RSSg)" />
<circle
cx="68"
cy="189"
r="24"
id="circle26"
sodipodi:cx="68"
sodipodi:cy="189"
sodipodi:rx="24"
sodipodi:ry="24"
style="fill:#ffffff"
transform="matrix(0.17167638,0,0,0.17167638,0,0.05084741)" />
<path
d="M 27.468221,36.617916 H 21.631223 A 14.077463,14.077463 0 0 0 7.5537606,22.540452 V 16.703457 A 19.91446,19.91446 0 0 1 27.468221,36.617916 z"
id="path28"
inkscape:connector-curvature="0"
style="fill:#ffffff" />
<path
d="M 31.588454,36.617916 A 24.034693,24.034693 0 0 0 7.5537606,12.583223 V 6.5745501 A 30.043366,30.043366 0 0 1 37.597127,36.617916 z"
id="path30"
inkscape:connector-curvature="0"
style="fill:#ffffff" />
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
img/logo_rss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB