Allow to set styles for alert banner

This commit is contained in:
Saivann 2015-07-05 21:11:23 -04:00
parent 0216bf3f64
commit 2d36e36464
5 changed files with 18 additions and 3 deletions

View file

@ -560,7 +560,8 @@ More information will follow.
* `title: ...` will be used as the title in the layout. * `title: ...` will be used as the title in the layout.
* `alias: ...` (optional) a short alias for Bitcoin Core alerts. Ex. "dos" will produce /dos.html * `alias: ...` (optional) a short alias for Bitcoin Core alerts. Ex. "dos" will produce /dos.html
* `active: ...` (true or false) define if the alert should appear as ongoing in the network status page. * `active: ...` (true or false) define if the alert should appear as ongoing in the network status page.
* `banner: ...` (optional) a short text that will be displayed in a red alert banner and link to the alert page. * `banner: ...` (optional) a short text that will be displayed in an alert banner and link to the alert page.
* `bannerclass: ...` (optional) a CSS class that sets the color of the banner. Possible values: alert (default red), warning (orange), success (green), info (blue).
* `last updated: ...` should be kept up to date and be in RFC 2822 format ( date -uR ). * `last updated: ...` should be kept up to date and be in RFC 2822 format ( date -uR ).
## Wallets ## Wallets

View file

@ -3,6 +3,7 @@ title: "Some Miners Generating Invalid Blocks"
alias: "spv-mining" alias: "spv-mining"
active: true active: true
banner: "WARNING: many wallets currently vulnerable to double-spending of confirmed transactions (click here to read)" banner: "WARNING: many wallets currently vulnerable to double-spending of confirmed transactions (click here to read)"
bannerclass: "alert"
--- ---
<p><em>This document is being updated as new information arrives. Last <p><em>This document is being updated as new information arrives. Last
update: 2015-07-04 16:00 UTC</em></p> update: 2015-07-04 16:00 UTC</em></p>

View file

@ -23,7 +23,7 @@
<body> <body>
<div id="detectmobile" class="detectmobile"></div> <div id="detectmobile" class="detectmobile"></div>
{% if site.ALERT %} {% if site.ALERT %}
<div class="banner-message alert"> <div class="banner-message {{ site.ALERTCLASS }}">
<a href="{{ site.ALERTURL }}"><span>{{ site.ALERT }}</span></a> <a href="{{ site.ALERTURL }}"><span>{{ site.ALERT }}</span></a>
</div> </div>
{% endif %} {% endif %}

View file

@ -153,9 +153,18 @@ table td,table th{
.banner-message a:hover{ .banner-message a:hover{
text-decoration:underline; text-decoration:underline;
} }
.banner-message a{
background-color:#c5251f;
}
.banner-message.alert a{ .banner-message.alert a{
background-color:#c5251f; background-color:#c5251f;
} }
.banner-message.warning a{
background-color:#E58716;
}
.banner-message.success a{
background-color:#329239;
}
.banner-message.info a{ .banner-message.info a{
background-color:#0d579b; background-color:#0d579b;
} }

View file

@ -39,9 +39,12 @@ module Jekyll
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
site.config['ALERT']=self.data['banner'] site.config['ALERT']=self.data['banner']
site.config['ALERTURL']='/'+dstdir+'/'+dst.gsub('.html','') site.config['ALERTURL']='/'+dstdir+'/'+dst.gsub('.html','')
if self.data.has_key?('bannerclass') and !self.data['bannerclass'].nil? and self.data['bannerclass'].length>0
site.config['ALERTCLASS'] = self.data['bannerclass']
end
end end
if self.data.has_key?('active') and !self.data['active'].nil? and self.data['active'] == true if self.data.has_key?('active') and !self.data['active'].nil? and self.data['active'] == true
site.config['STATUS']=1 site.config['STATUS'] = 1
end end
if self.data.has_key?('alias') if self.data.has_key?('alias')
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['alias']+'.html', date) site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['alias']+'.html', date)
@ -55,6 +58,7 @@ module Jekyll
def generate(site) def generate(site)
#Generate each alert based on templates #Generate each alert based on templates
site.config['STATUS'] = 0 site.config['STATUS'] = 0
site.config['ALERTCLASS'] = 'alert'
#Do nothing if plugin is disabled #Do nothing if plugin is disabled
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('alerts').nil? if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('alerts').nil?
print 'Alerts disabled' + "\n" print 'Alerts disabled' + "\n"