colorful rat Ratfactor.com > Dave's Repos

faceclick

A lightweight Emoji picker popup library with labels and keyword search.
git clone http://ratfactor.com/repos/faceclick/faceclick.git

faceclick/data/makesheet.rb

Download raw file: data/makesheet.rb

1 #!/usr/bin/env ruby 2 require 'json' 3 4 # JSON file needs Emojibase-formatted entries, see https://emojibase.dev 5 # Also see customizer.rb in this directory. 6 7 if ARGV.length < 2 8 puts " 9 Usage: 10 make-contact-sheet.rb <json input file> <html_output file> 11 12 Examples: 13 make-contact-sheet.rb emojibase.pretty.json full-sheet.html 14 make-contact-sheet.rb custom.json custom-sheet.html 15 " 16 exit 1 17 end 18 19 fjson = ARGV[0] 20 fhtml = ARGV[1] 21 22 json = File.read(fjson) 23 list = JSON.parse(json) 24 25 html = File.open(fhtml,'w'); 26 html.puts '<html><head><meta charset="utf-8"></head>' 27 html.puts '<body>' 28 html.puts "<h1>#{list.length} emoji</h1>" 29 30 # Print stats for the custom set 31 stats_txt = `ruby getstats.rb #{fjson}` 32 html.puts "<pre>#{stats_txt}</pre>" 33 34 # Now print the emoji by group 35 group = nil 36 group_style='style="background:#FAA;font-weight:bold;"' 37 list.each do |e| 38 if e['group'] != group 39 group = e['group'] 40 html.puts "<br><span #{group_style}}>Group #{group}:</span> " 41 end 42 html.puts "<span title=\"#{e['label']}\">#{e['emoji']}</span>" 43 end 44 45 html.puts "</body></html>" 46 html.close 47 48 puts "Wrote #{list.length} emoji to #{fhtml}."