skeksis/lib/skeksis.rb

34 lines
774 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2023-08-05 01:49:40 +00:00
require "yaml"
require_relative "skeksis/version"
2023-08-02 02:53:54 +00:00
require_relative "skeksis/parser"
2023-08-03 17:42:28 +00:00
require_relative "skeksis/htmlize"
module Skeksis
2023-08-05 01:49:40 +00:00
#class Error < StandardError; end
class GemBridge
def initialize
@gemini_uri = YAML.load(File.read("config.yml"))['skeksis_config']['gemini_uri']
end
def query(path, env)
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
[htmlize(data, env)]
else # path is invalid
return nil
end
end
2023-08-03 17:42:28 +00:00
2023-08-05 01:49:40 +00:00
def htmlize(data, env)
Skeksis::Parser.parse(data, strip_blanks=true).htmlize(env['REQUEST_URI'], @gemini_uri)
end
2023-08-03 17:42:28 +00:00
end
end