xxwhirlpool
·
2026-04-25
iconshare.rb
1#!/usr/bin/env ruby
2
3def usage
4 puts "Usage: iconshare.rb [DIR]"
5end
6
7icondir = ARGV[0] || "./icons/*"
8
9if icondir.nil?
10 puts usage
11 exit
12end
13
14htmlfile = File.open("./gallery.html", "w+")
15
16css = <<-EOF
17 <style>
18 html {
19 background: #eff1f5;
20 display: flex;
21 flex-direction: column;
22 align-items: center;
23 }
24
25 .wrapper {
26 background: #303446;
27 padding-block: 1rem;
28 padding-inline: 1rem;
29 max-width: 420px;
30 }
31
32 .wrapper img {
33 margin-block-end: 4px;
34 padding-inline: 2px;
35 }
36 </style>
37EOF
38
39htmlfile.write(css)
40htmlfile.write("<main class=\"wrapper\">")
41
42files = Dir[icondir].each do |icon|
43 imghtml = "<img src=\"#{icon}\">"
44 htmlfile.write(imghtml)
45end
46
47htmlfile.write("</main")