30 lines
604 B
Ruby
30 lines
604 B
Ruby
require 'skeksis'
|
|
|
|
SERVE_DIR="/Users/madeline/Code/gemini-bridge-rack/gemini"
|
|
|
|
class SkeksisApp
|
|
def call(env)
|
|
status = 200
|
|
#headers = { "Content-Type" => "text/html" }
|
|
headers = {}
|
|
body = resolve_path(SERVE_DIR + env['PATH_INFO'])
|
|
|
|
[status, headers, body]
|
|
end
|
|
|
|
def resolve_path(path)
|
|
if Dir.exist?(path)
|
|
return Dir.each_child(path).map {|i| "#{i}\n"}
|
|
elsif File.exist?(path)
|
|
file = File.open(path, 'r')
|
|
data = file.readlines
|
|
Skeksis::Parser.parse(data)
|
|
data
|
|
else # path is invalid
|
|
return nil
|
|
end
|
|
end
|
|
end
|
|
|
|
run SkeksisApp.new
|