aboutsummaryrefslogtreecommitdiff
path: root/_plugins
diff options
context:
space:
mode:
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/authors.rb38
-rw-r--r--_plugins/tag-color.rb13
-rw-r--r--_plugins/toc.rb6
3 files changed, 42 insertions, 15 deletions
diff --git a/_plugins/authors.rb b/_plugins/authors.rb
new file mode 100644
index 0000000..a2e0a53
--- /dev/null
+++ b/_plugins/authors.rb
@@ -0,0 +1,38 @@
+require 'set'
+
+module Jekyll
+ class FormatAuthors < Liquid::Tag
+ def initialize(tag_name, input, tokens)
+ super
+ @args = input.split(" ").map { |arg| arg.strip() }
+ end
+
+ def transform_authors(author_meta, git_authors)
+ authors = Set[]
+ for substitute in author_meta do
+ for name in substitute['git'] do
+ if git_authors.include?(name)
+ authors.add(substitute['name'])
+ end
+ end
+ end
+ return authors.to_a()
+ end
+
+ def join_names(authors)
+ return "nobody?" if authors.length == 0
+ return "#{authors[0]}" if authors.length == 1
+ return "#{authors[0..-2].join(", ")} and #{authors[-1]}"
+ end
+
+ def render(context)
+ author_meta = context[@args[0]]
+ git_authors = context[@args[1]]
+ authors = transform_authors(author_meta, git_authors)
+ return join_names(authors)
+ end
+ end
+end
+
+Liquid::Template.register_tag('fmt_authors', Jekyll::FormatAuthors)
+
diff --git a/_plugins/tag-color.rb b/_plugins/tag-color.rb
deleted file mode 100644
index 9f119fb..0000000
--- a/_plugins/tag-color.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module TagColor
- def to_tag_color(str)
- sum = 0
- str.chars.each do |i|
- sum += ?i.ord
- sum %= 360
- end
- sum
- end
-end
-
-Liquid::Template.register_filter(TagColor)
-
diff --git a/_plugins/toc.rb b/_plugins/toc.rb
index 3c4f836..80acc82 100644
--- a/_plugins/toc.rb
+++ b/_plugins/toc.rb
@@ -9,7 +9,9 @@ module Jekyll
# enumerate over all h1-4 headings
@els = doc.css("h1, h2, h3, h4")
- return '<div class="chapterChildren">%s</div>' % [ output_toc ]
+ toc = output_toc()
+ return '' if toc.empty?
+ return '<aside id="toc" class="plainlink">%s</aside>' % [ toc ]
end
def output_toc
@@ -29,7 +31,7 @@ module Jekyll
if level >= level_next
output += '<li>'
else
- output += '<li class="stub"><details open>'
+ output += '<li class="stub"><details>'
output += '<summary>'
end