Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create local and network component resolvers #208

Merged
merged 1 commit into from Sep 19, 2017
Merged

Create local and network component resolvers #208

merged 1 commit into from Sep 19, 2017

Conversation

@fofr
Copy link
Contributor

@fofr fofr commented Sep 19, 2017

We need the option to use local components when using Slimmer in the static component guide (which lives in Static). This avoids network requests, excessive network stubbing and i18n chain hacks.

Because static components have a .raw.html.erb filename, we can’t use the default Rails component resolver. eg govuk_component/title can’t find the _title partial – we need to load title.raw.html.erb.

  • Split ComponentResolver into LocalComponentResolver and NetworkComponentResolver
  • Create new module for LocalGovukComponents which govuk_publishing_components can use when included on static
  • LocalGovukComponents don’t need a test version

Alternative to: alphagov/static#1144

The LocalGovukComponents will be loaded in the govuk_publishing_components gem when used on static: https://github.com/alphagov/govuk_publishing_components/blob/master/app/controllers/govuk_publishing_components/application_controller.rb#L4

@fofr fofr force-pushed the local-slimmer branch from a1cf981 to 5545f81 Sep 19, 2017
@fofr fofr requested review from h-lame and tijmenb Sep 19, 2017
h-lame
h-lame approved these changes Sep 19, 2017
Copy link

@h-lame h-lame left a comment

This feels like the right thing to do to help solve the issues brought up by including slimmer in static via govuk publishing components. There may still be other places we need to introduce a "local" version of something, but this seems to solve the problems we've already spotted in static.

And, it is a better solution than my attempts to fix the tests in static by clumsily stubbing out parts of slimmer. 👍

@fofr
Copy link
Contributor Author

@fofr fofr commented Sep 19, 2017

@nickcolley I've confirmed this branch works with Static i18n. On static the locale file is in the standard place that Rails looks for it, so localisation works as normal.

We need the option to use local components when using Slimmer in
static. This avoids network requests, excessive network stubbing and
i18n chain hacks.

Because static components have a `.raw.html.erb` filename, we can’t use
the default Rails component resolver. eg `govuk_component/title` can’t
find the `_title` partial – we need to load `title.raw.html.erb`.

* Split ComponentResolver into LocalComponentResolver and
NetworkComponentResolver
* Create new module for LocalGovukComponents which
govuk_publishing_components can use when included on static
* LocalGovukComponents don’t need a test version
@fofr fofr force-pushed the local-slimmer branch from 5545f81 to aaece2c Sep 19, 2017
@fofr fofr merged commit 1a6ff57 into master Sep 19, 2017
1 check passed
@fofr fofr deleted the local-slimmer branch Sep 19, 2017
fofr added a commit that referenced this issue Sep 19, 2017
* Allow components in static to be loaded locally rather than over the
network (#208)
* Replace deprecated `after_filter` in slimmer_template (#209)
@fofr fofr mentioned this pull request Sep 19, 2017
fofr added a commit that referenced this issue Sep 19, 2017
* Allow components in static to be loaded locally rather than over the
network (#208)
* Replace deprecated `after_filter` in slimmer_template (#209)
* Drops support for Rails 4
fofr added a commit that referenced this issue Sep 19, 2017
* Allow components in static to be loaded locally rather than over the
network (#208)
* Replace deprecated `after_filter` in slimmer_template (#209)
fofr added a commit to alphagov/govuk_publishing_components that referenced this issue Sep 19, 2017
See alphagov/slimmer#208

* Update slimmer to >= 11.1.0
* Use LocalGovukComponents when on static, avoiding i18n chains and
calls over the network to itself
* Stub components that the dummy app would otherwise get from Slimmer
(slimmer’s local resolver has no concept of a test mode as files ought
to be available)
fofr added a commit to alphagov/govuk_publishing_components that referenced this issue Sep 19, 2017
See alphagov/slimmer#208

* Update slimmer to >= 11.1.0
* Use LocalGovukComponents when on static, avoiding i18n chains and
calls over the network to itself
* Stub components that the dummy app would otherwise get from Slimmer
(slimmer’s local resolver has no concept of a test mode as files ought
to be available)
* Re-include the appropriate module when running static tests as
initialiser config can't recreate ApplicationController
fofr added a commit to alphagov/govuk_publishing_components that referenced this issue Sep 19, 2017
See alphagov/slimmer#208

* Update slimmer to >= 11.1.0
* Use LocalGovukComponents when on static, avoiding i18n chains and
calls over the network to itself
* Stub components that the dummy app would otherwise get from Slimmer
(slimmer’s local resolver has no concept of a test mode as files ought
to be available)
* Re-include the appropriate module when running static tests as
initialiser config can't recreate ApplicationController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants