Merge pull #874: New Plugin: Githubify Bitcoin Core Release Notes

This commit is contained in:
David A. Harding 2015-06-05 18:20:19 -04:00
commit f8de789019
No known key found for this signature in database
GPG key ID: 4B29C30FF29EC4B7
4 changed files with 79 additions and 0 deletions

73
_plugins/githubify.rb Normal file
View file

@ -0,0 +1,73 @@
# This file is licensed under the MIT License (MIT) available on
# http://opensource.org/licenses/MIT.
## githubify.rb automatically adds links to pull requests, issues, and
## commits using pattern matches
## Example (URL is the repository to link to):
## {% githubify https://github.com/bitcoin/bitcoin %}
## ...content...
## {% endgithubify %}
module Jekyll
require 'yaml'
class GitHubifyBlock < Liquid::Block
def initialize(tag_name, text, tokens)
super
@repository_url = text.strip()
end
def render(context)
output = super
## Convert #1234 into URL for the pull request
## If #1234 links to an issue, GitHub automatically redirects
#
## Require at least two digits to reduce false positive matches
output.gsub!(/#([0-9][0-9][0-9]*)/){ |s|
'<a href="' + @repository_url + '/pull/' + $1 + '">' + s + '</a>'
}
## Convert `123abcd` into URL for the commit
#
## Only operate on 7 to 10 chars to reduce false positive matches
output.gsub!(/`([0-9abcdef]{7,10})`/){ |s|
'<a href="' + @repository_url + '/commit/' + $1 + '">' + s + '</a>'
}
output
end
end
end
## Code to run if plugin is disabled
module Jekyll
require 'yaml'
class GitHubifyBlockDisabled < Liquid::Block
def initialize(tag_name, text, tokens)
super
end
def render(context)
output = super
output
end
end
end
#Do nothing if plugin is disabled
plugin_name = "githubify"
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index(plugin_name).nil?
print plugin_name + ' disabled' + "\n"
Liquid::Template.register_tag(plugin_name, Jekyll::GitHubifyBlockDisabled)
else
Liquid::Template.register_tag(plugin_name, Jekyll::GitHubifyBlock)
end

View file

@ -22,6 +22,7 @@ optional_magnetlink: "magnet:?xt=urn:btih:170c61fe09dafecfbb97cb4dccd32173383f4e
## 2. Place URLs inside angle brackets, like <http://bitcoin.org/bin>
---
{% githubify https://github.com/bitcoin/bitcoin %}
Bitcoin Core version 0.10.0 is now available from:
<https://bitcoin.org/bin/0.10.0/>
@ -798,3 +799,4 @@ Thanks to everyone who contributed to this release:
- Zak Wilcox
As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).
{% endgithubify %}

View file

@ -22,6 +22,7 @@ optional_magnetlink: "magnet:?xt=urn:btih:b6f8da60aaf2007cd6db631637951ae673e310
## 2. Place URLs inside angle brackets, like <http://bitcoin.org/bin>
---
{% githubify https://github.com/bitcoin/bitcoin %}
Bitcoin Core version 0.10.1 is now available from:
<https://bitcoin.org/bin/bitcoin-core-0.10.1/>
@ -161,3 +162,4 @@ Thanks to everyone who contributed to this release:
- Wladimir J. van der Laan
As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).
{% endgithubify %}

View file

@ -22,6 +22,7 @@ optional_magnetlink: "magnet:?xt=urn:btih:746a616aa8de97856c207e7a899c7ee315e8c4
## 2. Place URLs inside angle brackets, like <http://bitcoin.org/bin>
---
{% githubify https://github.com/bitcoin/bitcoin %}
Bitcoin Core version 0.10.2 is now available from:
<https://bitcoin.org/bin/bitcoin-core-0.10.2/>
@ -109,3 +110,4 @@ And all those who contributed additional code review and/or security research:
As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).
{% endgithubify %}