summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-03 16:56:41 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-03 16:56:41 -0500
commitb2cca15560f3f1a8f8394f9ecfcc40db067308dd (patch)
tree5ca1da7df8fe831314a3c9ad8c93911dfcae369d /bin
parentead337ddfd043e9ec86bbae0c5e660fde0cd6ba9 (diff)
Fix allowing git dates outside of [published,updated]
Diffstat (limited to 'bin')
-rw-r--r--bin/util.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/bin/util.rb b/bin/util.rb
index 7b4805f..6ea3967 100644
--- a/bin/util.rb
+++ b/bin/util.rb
@@ -148,12 +148,21 @@ class Page
end
def rights
- years = `git log --date=format:'%Y' --format='%cd' -- .config/login.sh`.split('\n').map{|s|s.to_i}
- years.unshift(published.year) unless published.nil?
- years.unshift(updated.year) unless updated.nil?
- years = Set[*years]
- # TODO: simplify year spans
- @rights ||= "<p>The content of this page is Copyright © #{years.sort.join(', ')} #{author.html}.</p>\n" +
+ if published.nil? || updated.nil?
+ years = ''
+ else
+ first = published.year
+ last = updated.year
+
+ years = `git log --date=format:'%Y' --format='%cd' -- .config/login.sh`.split('\n').map{|s|s.to_i}
+ years.unshift(first)
+ years.unshift(last)
+
+ # Remove dups and git years outside of [first,last]
+ # TODO: simplify year spans
+ years = Set[*years.select{|i|i > first && i < last}].sort.join(', ')
+ end
+ @rights ||= "<p>The content of this page is Copyright © #{years} #{author.html}.</p>\n" +
"<p>This page is licensed under the #{license.html} license.</p>"
end