require 'json'

require 'fileutils'

r = JSON.parse(File.read('list.json'))

$by_name = {}

def init_hash(h)

('a'..'z').to_a.each do |l|

h[l] = []

end

('0'..'9').to_a.each do |d|

h[d] = []

end

end

init_hash($by_name)

r.each do |s|

if s.nil? then

next

end

fs = s

s.downcase!

s.gsub! /(-)+/, '-'

who_prefix = ''

draft = 'draft-'

if s.start_with?(draft) then

s = s[draft.length,s.length]

end

ietf = 'draft-ietf-'

if s.start_with?(ietf) then

s = s[ietf.length,s.length]

who_prefix = 'ietf-'

end

irtf = 'draft-irtf-'

if s.start_with?(irtf) then

s = s[irtf.length,s.length]

who_prefix = 'irtf-'

end

sp = s.split('-', 2)

n = sp[1]

who = who_prefix + sp[0]

if n.nil? then

next

end

$by_name[n[0]].append({ :who => who, :n => n, :fs => fs })

end

index_gmi = ''

index_gmi << "# Hellomouse IETF draft list\n\n"

$by_name.keys.sort.each do |k|

index_gmi << "=> index-#{k}.gmi #{k}\n"

$by_name[k].sort! do |a, b|

a[:n] <=> b[:n]

end

FileUtils.touch("../index-#{k}.gmi")

f = File.open("../index-#{k}.gmi", 'w')

f.write "# Hellomouse IETF draft list - #{k}\n"

f.write "=> ./ Go back\n\n"

$by_name[k].each do |e|

f.write "=> data/#{e[:fs]} #{e[:who]} - #{e[:n]}\n"

end

f.close

end

FileUtils.touch('../index.gmi')

f = File.open('../index.gmi', 'w')

f.write index_gmi

f.close

Proxy Information
Original URL
gemini://hellomouse.net/user-pages/handicraftsman/ietf/scripts/mkindex.rb
Status Code
Success (20)
Meta
text/plain;charset=UTF-8
Capsule Response Time
545.947336 milliseconds
Gemini-to-HTML Time
0.95904 milliseconds

This content has been proxied by September (ba2dc).