Full URL navigation support
This commit is contained in:
@@ -24,15 +24,25 @@ module Skeksis
|
||||
|
||||
class GemBridge
|
||||
def initialize
|
||||
@gemini_uri = YAML.load(File.read("config.yml"))['skeksis_config']['gemini_uri']
|
||||
config = YAML.load(File.read("config.yml"))
|
||||
@gemini_uri = config['skeksis_config']['gemini_uri']
|
||||
@serve_dir = config['skeksis_config']['serve_dir']
|
||||
end
|
||||
|
||||
def query(path, env)
|
||||
if Dir.exist?(path)
|
||||
#return Dir.each_child(path).map {|i| "#{i}\n"}
|
||||
return create_dir_listing(path, env)
|
||||
elsif File.exist?(path)
|
||||
file = File.open(path, 'r')
|
||||
# Chomps the first / and builds path
|
||||
full_path = Pathname.new(@serve_dir) + path[1..-1]
|
||||
puts full_path.to_s
|
||||
if Dir.exist?(full_path)
|
||||
index_file = full_path + "index.gmi"
|
||||
if File.exist?(index_file)
|
||||
data = File.open(index_file, 'r').readlines
|
||||
[htmlize(data, env)]
|
||||
else
|
||||
create_dir_listing(full_path, env)
|
||||
end
|
||||
elsif File.exist?(full_path)
|
||||
file = File.open(full_path, 'r')
|
||||
data = file.readlines
|
||||
[htmlize(data, env)]
|
||||
else # path is invalid
|
||||
|
||||
Reference in New Issue
Block a user