2023-08-02 02:53:54 +00:00
|
|
|
require 'skeksis'
|
|
|
|
|
|
|
|
SERVE_DIR="/Users/madeline/Code/gemini-bridge-rack/gemini"
|
2023-07-29 20:04:45 +00:00
|
|
|
|
|
|
|
class SkeksisApp
|
|
|
|
def call(env)
|
|
|
|
status = 200
|
2023-08-03 17:42:28 +00:00
|
|
|
headers = { "content-type" => "text/html" }
|
|
|
|
#headers = {}
|
2023-07-29 20:04:45 +00:00
|
|
|
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')
|
2023-08-02 02:53:54 +00:00
|
|
|
data = file.readlines
|
2023-08-03 17:42:28 +00:00
|
|
|
[Skeksis.htmlize(data)]
|
2023-07-29 20:04:45 +00:00
|
|
|
else # path is invalid
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
run SkeksisApp.new
|