capitalize all required parts

This commit is contained in:
Francis 2021-05-04 16:22:20 +02:00
parent 3bda9bc5b2
commit 4b06c40575
No known key found for this signature in database
GPG key ID: 071BEA4C2B10077C
2 changed files with 7 additions and 2 deletions

View file

@ -18,6 +18,7 @@ module ArchiveHelper
Set.new(items Set.new(items
.find_all('/blog/*/*') .find_all('/blog/*/*')
.flat_map { |i| i[:tags] || [] }) .flat_map { |i| i[:tags] || [] })
.map{ |y| y.split.map(&:capitalize).join(' ') }
.to_a .to_a
.sort .sort
.uniq.map { |y| [y, items["/blog/#{y.gsub(' ', '_')}.html"]]} .uniq.map { |y| [y, items["/blog/#{y.gsub(' ', '_')}.html"]]}
@ -35,7 +36,7 @@ module ArchiveHelper
def posts_with_tag(tag) def posts_with_tag(tag)
items items
.find_all('/blog/*/*') .find_all('/blog/*/*')
.filter{|i| (i[:tags] || []).include? tag } .filter{|i| (i[:tags] || []).map{ |t| t.split.map(&:capitalize).join(' ') }.include? tag }
end end
def posts_in_year_or_with_tag(item) def posts_in_year_or_with_tag(item)

View file

@ -17,6 +17,7 @@ module EventsHelper
Set.new(items Set.new(items
.find_all('/events/*/*') .find_all('/events/*/*')
.flat_map { |i| i[:tags] || [] }) .flat_map { |i| i[:tags] || [] })
.map{ |y| y.split.map(&:capitalize).join(' ') }
.to_a .to_a
.sort .sort
.uniq.map { |y| [y, items["/events/#{y.gsub(' ', '_')}.html"]]} .uniq.map { |y| [y, items["/events/#{y.gsub(' ', '_')}.html"]]}
@ -24,7 +25,10 @@ module EventsHelper
def all_events_by_tag(tag = nil, soon = nil) def all_events_by_tag(tag = nil, soon = nil)
@items.find_all('/events/*/*.md') @items.find_all('/events/*/*.md')
.filter{|i| (i[:tags] || []).include? tag } .filter { |i|
(i[:tags] || [])
.map{ |t| t.split.map(&:capitalize).join(' ') }
.include? tag }
.select { |x| x[:soon] == soon } .select { |x| x[:soon] == soon }
.sort_by { |x| x[:time] } .sort_by { |x| x[:time] }
end end