diff options
author | 2018-04-14 20:51:58 +0200 | |
---|---|---|
committer | 2018-04-14 23:04:08 +0200 | |
commit | a5b5890de8757931f645cfcf8c48d3d71d3e817b (patch) | |
tree | affe9a2c163f7f25999bc61a9342d08ac878256e /_plugins | |
parent | developers: Note repo/gentoo.git commit access (diff) | |
download | www-a5b5890de8757931f645cfcf8c48d3d71d3e817b.tar.gz www-a5b5890de8757931f645cfcf8c48d3d71d3e817b.tar.bz2 www-a5b5890de8757931f645cfcf8c48d3d71d3e817b.zip |
unavailable-developers: Use bg colors to indicate length of away
Use background colors to indicate how long the developer is away.
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/devaway.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/_plugins/devaway.rb b/_plugins/devaway.rb index 9ba5018..b7ebec7 100644 --- a/_plugins/devaway.rb +++ b/_plugins/devaway.rb @@ -1,14 +1,27 @@ +require 'date' + module Gentoo class DevawayGenerator < Jekyll::Generator DEVAWAY_XML = '_data/devaway.xml' + # ... @ yyyy/mm/dd HH:MMZ + DATE_REGEXP = /@ (\d+)\/(\d+)\/(\d+) (\d+):(\d)+Z$/ def generate(site) data = Nokogiri::XML(File.open(DEVAWAY_XML)) site.data['devaway'] ||= {} + now = Time.now data.xpath('/devaway/dev').each do |dev| - site.data['devaway'][dev['nick']] = dev.xpath('./reason/text()').first.content + reason = dev.xpath('./reason/text()').first.content + date = Time.utc(*(DATE_REGEXP.match(reason).captures.map(&:to_i))) + away_sec = now - date + + site.data['devaway'][dev['nick']] = { + 'reason' => dev.xpath('./reason/text()').first.content, + 'date' => date, + 'away_days' => away_sec / 24 / 3600, + } end end end |