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
Pluggable cities assets #687
Conversation
85d7ee2
to
e4be982
Compare
Codecov Report
@@ Coverage Diff @@
## master #687 +/- ##
==========================================
+ Coverage 24.16% 24.17% +<.01%
==========================================
Files 134 135 +1
Lines 2884 2887 +3
Branches 491 490 -1
==========================================
+ Hits 697 698 +1
- Misses 1813 1816 +3
+ Partials 374 373 -1
Continue to review full report at Codecov.
|
…ing whitelabel assets
e4be982
to
f241604
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible!
Perhaps add the city_config
variable to config_dev.toml.example
too, with explanations?
I' m asking @vikoivun to comment on this one too, because he will be the one responsible for deployment anyway :) Everything should work as before, but better that he knows what is happening. |
Added |
Looks like everybody is happy with this one, so I'm merging. |
So this was a fun one, lots of trial and error, in the beginning, to figure out the nicest way to do this. So what have I done?
What does it do?
The code enables other cities to create their own assets and themes for kerrokantasi. It removes as much as possible of the Helsinki base assets from the codebase and instead moves all Helsinki related things to /cities/assets. Since I did not want to create any disruption for the Helsinki devs, the Helsinki themes/assets got to live on in the same repository. However, the main point would be that themes/assets would/could be separated into a separate project and then be activated by installing them and changing only a single config parameter,
city_config
.To keep the application working as it did before, things will default to the Helsinki styles and assets and everything should work as it did before the change. However, it is now easy to load the whitelabel styles by settings
city_config = "whitelabel"
or to change to a different cities theme/assets, for instancecity_config = "kerrokantasi-ui-turku"
(https://github.com/City-of-Turku/kerrokantasi-ui-turku).How was it done?
Mainly by setting correct aliases in the WebPack. This allowed me to load assets from different places in the code base. This also allowed for cross-importing things from kerrokantasi-ui into a theme/assets package. When all of that was done, it was mainly figuring out where things should go and moving things around and pointing to the correct files in the code.
Docs
Documentation regarding the creation of themes/asset packages can be found in the README so I won't bother explaining them here.
Notes
This does not remove all Helsinki related things from the main codebase yet. There are still some hardcoded strings that are left, and for instance, authentication is still very much Helsinki specific. This is mainly the first step into making the project more city agnostic so that others can use the same codebase and just be able to change the styling and strings that they want to.
As can be noted in the readme under "Installing city specific assets" and then "Development steps", there are still some caveats to this when creating external packages that would be nice to fix, but due to time constraints these were unfortunately not figured out.