Skip to content

Commit

Permalink
Another refactor to support latest updates in Bridgetown v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed May 6, 2024
1 parent 296dab6 commit cee64b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.0] - 2024-05-06

- Another refactor to support latest updates in Bridgetown v2

## [0.3.0] - 2024-04-07

- Refactor how Bridgetown's view layer is integrated with Rodauth, improve performance
Expand Down
2 changes: 1 addition & 1 deletion lib/authtown/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Authtown
VERSION = "0.3.0"
VERSION = "0.4.0"
end
20 changes: 4 additions & 16 deletions lib/authtown/view_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,11 @@ def view(*args, view_class: Bridgetown::ERBView, **kwargs) # rubocop:disable Met
"#{kwargs.dig(:locals, :rodauth).prefix.delete_prefix("/")}/#{kwargs[:template]}"
end

# TODO: this should really be some sort of exposed method from the routes plugin
response["X-Bridgetown-SSR"] = "1"
routes_manifest.routes.each do |route|
file, localized_slugs = route
next unless localized_slugs.first == kwargs[:template]

Bridgetown::Routes::Manifest.generate_manifest(bridgetown_site).each do |route|
file, localized_file_slugs = route

file_slug = localized_file_slugs.first

next unless file_slug == kwargs[:template]

Bridgetown::Routes::CodeBlocks.eval_route_file file, file_slug, self
route_block = Bridgetown::Routes::CodeBlocks.route_block(file_slug)
response.instance_variable_set(
:@_route_file_code, route_block.instance_variable_get(:@_route_file_code)
) # could be nil
@_route_locals = kwargs[:locals]
return instance_exec(request, &route_block)
return run_file_route(file, slug: localized_slugs.first)
end

Bridgetown.logger.warn("Rodauth template not found: #{kwargs[:template]}")
Expand Down

0 comments on commit cee64b0

Please sign in to comment.