Module: Roda::RodaPlugins::BridgetownServer
- Defined in:
- lib/roda/plugins/bridgetown_server.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, RequestMethods Classes: SiteContext
Class Method Summary collapse
-
.load_dependencies(app) ⇒ Object
rubocop:disable Metrics.
Class Method Details
.load_dependencies(app) ⇒ Object
rubocop:disable Metrics
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/roda/plugins/bridgetown_server.rb', line 8 def self.load_dependencies(app) # rubocop:disable Metrics unless Bridgetown::Current.preloaded_configuration raise "You must supply a preloaded configuration before loading the Bridgetown Roda " \ "plugin" end app.extend ClassMethods # we need to do this here because Roda hasn't done it yet app.plugin :initializers app.plugin :common_logger, Bridgetown::Rack::Logger.new($stdout), method: :info app.plugin :json app.plugin :json_parser app.plugin :ssg, root: Bridgetown::Current.preloaded_configuration.destination app.plugin :not_found do output_folder = Bridgetown::Current.preloaded_configuration.destination File.read(File.join(output_folder, "404.html")) rescue Errno::ENOENT "<h1>404 Not Found</h1>" end app.plugin :exception_page app.plugin :error_handler do |e| Bridgetown::Errors.print_build_error( e, logger: Bridgetown::LogAdapter.new(self.class.opts[:common_logger]), server: true ) next exception_page(e) if ENV.fetch("RACK_ENV", nil) == "development" output_folder = self.class.opts[:bridgetown_preloaded_config].destination File.read(File.join(output_folder, "500.html")) rescue Errno::ENOENT "<h1>500 Internal Server Error</h1>" end # TODO: there may be a better way to do this, see `exception_page_css` instance method ExceptionPage.class_eval do # rubocop:disable Metrics/BlockLength def self.css " html * { padding:0; margin:0; }\n body * { padding:10px 20px; }\n body * * { padding:0; }\n body { font-family: -apple-system, sans-serif; font-size: 90%; }\n body>div { border-bottom:1px solid #ddd; }\n code { font-family: ui-monospace, monospace; }\n h1 { font-weight: bold; margin-block-end: .8em; }\n h2 { margin-block-end:.8em; }\n h2 span { font-size:80%; color:#f7f7db; font-weight:normal; }\n h3 { margin:1em 0 .5em 0; }\n h4 { margin:0 0 .5em 0; font-weight: normal; }\n table {\n border:1px solid #ccc; border-collapse: collapse; background:white; }\n tbody td, tbody th { vertical-align:top; padding:2px 3px; }\n thead th {\n padding:1px 6px 1px 3px; background:#fefefe; text-align:left;\n font-weight:normal; font-size:11px; border:1px solid #ddd; }\n tbody th { text-align:right; opacity: 0.7; padding-right:.5em; }\n table.vars { margin:5px 0 2px 40px; }\n table.vars td, table.req td { font-family: ui-monospace, monospace; }\n table td.code { width:100%;}\n table td.code div { overflow:hidden; }\n table.source th { color:#666; }\n table.source td {\n font-family: ui-monospace, monospace; white-space:pre; border-bottom:1px solid #eee; }\n ul.traceback { list-style-type:none; }\n ul.traceback li.frame { margin-bottom:1em; }\n div.context { margin: 10px 0; }\n div.context ol {\n padding-left:30px; margin:0 10px; list-style-position: inside; }\n div.context ol li {\n font-family: ui-monospace, monospace; white-space:pre; color:#666; cursor:pointer; }\n div.context ol.context-line li { color:black; background-color:#f7f7db; }\n div.context ol.context-line li span { float: right; }\n div.commands { margin-left: 40px; }\n div.commands a { color:black; text-decoration:none; }\n #summary { background: #1D453C; color: white; }\n #summary h2 { font-weight: normal; color: white; }\n #summary ul#quicklinks { list-style-type: none; margin-bottom: 2em; }\n #summary ul#quicklinks li { float: left; padding: 0 1em; }\n #summary ul#quicklinks>li+li { border-left: 1px #666 solid; }\n #summary a { color: #f47c3c; }\n #explanation { background:#eee; }\n #traceback { background: white; }\n #requestinfo { background:#f6f6f6; padding-left:120px; }\n #summary table { border:none; background:transparent; }\n #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }\n #requestinfo h3 { margin-bottom:-1em; }\n .error { background: #ffc; }\n .specific { color:#cc3300; font-weight:bold; }\n CSS\n end\n end\nend\n" |