Add rudimentary theming, checks for .directory-listing-ok file
This commit is contained in:
		@@ -9,9 +9,21 @@ require_relative "skeksis/htmlize"
 | 
			
		||||
module Skeksis
 | 
			
		||||
  #class Error < StandardError; end
 | 
			
		||||
  Header = <<~HTML
 | 
			
		||||
  <html>
 | 
			
		||||
  <!DOCTYPE html>
 | 
			
		||||
  <html lang="en">
 | 
			
		||||
  <head>
 | 
			
		||||
  <title>Gembridge</title>
 | 
			
		||||
  <style>
 | 
			
		||||
  h1,h2,h3,h4,h5,h6 {
 | 
			
		||||
  color: #2e3440;
 | 
			
		||||
  }
 | 
			
		||||
  a {
 | 
			
		||||
    color: #434c5e;
 | 
			
		||||
  }
 | 
			
		||||
  a:visited {
 | 
			
		||||
    color: #4c566a;
 | 
			
		||||
  }
 | 
			
		||||
  </style>
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
  <h1>Directory Listing</h1>
 | 
			
		||||
@@ -56,13 +68,28 @@ module Skeksis
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def load_style
 | 
			
		||||
      "<script type=\"text/css\">" +
 | 
			
		||||
      File.open("style/nord.css", 'r').readlines.join("\n") +
 | 
			
		||||
      "</script>"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def create_dir_listing(path, env)
 | 
			
		||||
      http = URI.parse(env['REQUEST_URI'])
 | 
			
		||||
 | 
			
		||||
      unless Dir.each_child(path).include?('.directory-listing-ok')
 | 
			
		||||
        return nil
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
      listing = Dir.each_child(path).map do |i|
 | 
			
		||||
        if i == ".directory-listing-ok"
 | 
			
		||||
          next
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        path = Pathname.new(env['PATH_INFO']).join(i)
 | 
			
		||||
        uri = URI::HTTP.build(host: http.host, port: http.port, path: path.to_s)
 | 
			
		||||
        "<a href=\"#{uri.to_s}\">#{i}</a><br/>"
 | 
			
		||||
        "<a href=\"#{uri.to_s}\">#{i}</a><br>"
 | 
			
		||||
      end.join("\n")
 | 
			
		||||
      [Header + listing + Footer]
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,8 @@
 | 
			
		||||
module Skeksis
 | 
			
		||||
  class IR
 | 
			
		||||
    Header = <<~HTML
 | 
			
		||||
    <html>
 | 
			
		||||
    <!DOCTYPE html>
 | 
			
		||||
    <html lang="en">
 | 
			
		||||
    <head>
 | 
			
		||||
    <title>Gembridge</title>
 | 
			
		||||
    </head>
 | 
			
		||||
@@ -34,7 +35,7 @@ module Skeksis
 | 
			
		||||
 | 
			
		||||
        case entry[:type]
 | 
			
		||||
        when :blank
 | 
			
		||||
          "<br/>"
 | 
			
		||||
          "<br>"
 | 
			
		||||
        when :header
 | 
			
		||||
          level = entry[:level]
 | 
			
		||||
          "<h#{level}>#{text}</h#{level}>"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user