Skip to content

Commit

Permalink
Allow to set styles for alert banner
Browse files Browse the repository at this point in the history
  • Loading branch information
saivann committed Jul 6, 2015
1 parent 0216bf3 commit 2d36e36
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ More information will follow.
* `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
* `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 ).
## Wallets
Expand Down
1 change: 1 addition & 0 deletions _alerts/2015-07-04-spv-mining.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
alias: "spv-mining"
active: true
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
update: 2015-07-04 16:00 UTC</em></p>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<body>
<div id="detectmobile" class="detectmobile"></div>
{% if site.ALERT %}
<div class="banner-message alert">
<div class="banner-message {{ site.ALERTCLASS }}">
<a href="{{ site.ALERTURL }}"><span>{{ site.ALERT }}</span></a>
</div>
{% endif %}
Expand Down
9 changes: 9 additions & 0 deletions _less/screen.less
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,18 @@ table td,table th{
.banner-message a:hover{
text-decoration:underline;
}
.banner-message a{
background-color:#c5251f;
}
.banner-message.alert a{
background-color:#c5251f;
}
.banner-message.warning a{
background-color:#E58716;
}
.banner-message.success a{
background-color:#329239;
}
.banner-message.info a{
background-color:#0d579b;
}
Expand Down
6 changes: 5 additions & 1 deletion _plugins/alerts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ def initialize(site, base, lang, srcdir, src, dstdir, dst, date)
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['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
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
if self.data.has_key?('alias')
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['alias']+'.html', date)
Expand All @@ -55,6 +58,7 @@ class AlertPageGenerator < Generator
def generate(site)
#Generate each alert based on templates
site.config['STATUS'] = 0
site.config['ALERTCLASS'] = 'alert'
#Do nothing if plugin is disabled
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('alerts').nil?
print 'Alerts disabled' + "\n"
Expand Down

0 comments on commit 2d36e36

Please sign in to comment.