Sha256: dd40349768b4f325e0a12dd8636e977576fe2860be8a2405fee559228790e60e

Contents?: true

Size: 955 Bytes

Versions: 2

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module Staticky
  module ServerPlugin
    def self.load_dependencies(app)
      app.plugin :common_logger, Staticky.server_logger, method: :debug
      app.plugin :render, engine: "html"
      app.plugin :public
      app.plugin :exception_page

      app.plugin :not_found do
        raise Staticky::Server::NotFound if Staticky.env.test?

        Staticky.build_path.join("404.html").read
      end

      app.plugin :error_handler do |error|
        raise error if Staticky.env.test?
        next exception_page(error) if Staticky.env.development?

        Staticky.build_path.join("500.html").read
      end
    end

    module RequestMethods
      def staticky
        unless Staticky.env.development? && Staticky.config.live_reloading
          return
        end

        ServerPlugins::LiveReloading.setup_live_reload(scope)
      end
    end

    Roda::RodaPlugins.register_plugin(:staticky_server, self)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staticky-0.3.1 lib/staticky/server_plugin.rb
staticky-0.3.0 lib/staticky/server_plugin.rb