Module: Roda::RodaPlugins::BridgetownServer::InstanceMethods
- Defined in:
- lib/roda/plugins/bridgetown_server.rb
Instance Method Summary collapse
-
#deconstruct_keys ⇒ Object
This is useful if you're passing the Roda app instance around and want to get at
request
/response
easily as local variables. - #initialize_bridgetown_context ⇒ Object
-
#initialize_bridgetown_root ⇒ Object
rubocop:todo Metrics/AbcSize.
Instance Method Details
#deconstruct_keys ⇒ Object
This is useful if you're passing the Roda app instance around and want to
get at request
/ response
easily as local variables
142 143 144 |
# File 'lib/roda/plugins/bridgetown_server.rb', line 142 def deconstruct_keys(*) { request:, response: } end |
#initialize_bridgetown_context ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/roda/plugins/bridgetown_server.rb', line 110 def initialize_bridgetown_context if self.class.opts[:bridgetown_site] # The site had previously been initialized via the bridgetown_ssr plugin Bridgetown::Current.sites[self.class.opts[:bridgetown_site].label] = self.class.opts[:bridgetown_site] @context ||= SiteContext.new({ site: self.class.opts[:bridgetown_site] }) end Bridgetown::Current.preloaded_configuration ||= self.class.opts[:bridgetown_preloaded_config] end |
#initialize_bridgetown_root ⇒ Object
rubocop:todo Metrics/AbcSize
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/roda/plugins/bridgetown_server.rb', line 121 def initialize_bridgetown_root # rubocop:todo Metrics/AbcSize request.root do hook_result = instance_exec(&self.class.opts[:root_hook]) if self.class.opts[:root_hook] next hook_result if hook_result status, headers, body = self.class.opts[:ssg_server].serving( request, File.join(self.class.opts[:ssg_root], "index.html") ) response_headers = response.headers response_headers.replace(headers) request.halt [status, response_headers, body] rescue StandardError => e Bridgetown.logger.debug("Root handler error: #{e.}") response.status = 500 "<p>ERROR: cannot find <code>index.html</code> in the output folder.</p>" end end |