-
Notifications
You must be signed in to change notification settings - Fork 36
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
Static site conversion #655
Comments
To expand on this, we should probably take a look at changing our current method of flavor-specific overrides. Our current system of being able to override things on a file-by-file basis creates very little separation between our public API and our private internals. In order to customize something, a copy of a file is made before being tweaked. That means that an updated version of Mapseed isn't guaranteed (or even particularly likely) to be compatible with old overrides. In my opinion, we should improve the override system so that:
|
That is a fair point. An API that we could use would be great, although I wonder how difficult it would be to abstract something like that effectively? To take a specific example, think about the feature in the Still, maybe we can come up with a list of functionality that would make sense to abstract based on the kind of flavor-specific overrides that we've encountered so far. Maybe a nice starting place would be a robust system of events that signal state changes? And I totally agree with your second bullet above-- no more completely overwritten views! I take the blame for that--I didn't understand how to use the flavor mechanism properly in the past when I extended pboakland's views. |
Can we resolve this by just having each mapseed deployment be it's own repo instead a flavor within a megarepo like we're currently doing? Soon enough we'll have 20 flavors within the platform repo, which is getting to be a burden, maybe we can solve that problem and not do so many flavor specific overrides? |
Splitting up the flavors into their own repositories seems like a good thing too--I know you guys have been discussing that. If I'm understanding the scope of this correctly, I think we can make improvements like what @zmbc notes above in addition to splitting flavors up into their own repositories. One change would be on the level of code abstraction and the other on the level of code organization, but both seem like good steps forward. |
in re to your comment @zmbc:
And to clarify on what was mentioned by goldpbear, flavors are no longer overriding entire base views (ie the entire file). Here is the PR where this was fixed: https://github.com/mapseed/platform/pull/631/files and here is the line of code where we are using Backbone to extend a view at the function-level: https://github.com/mapseed/platform/blob/master/src/flavors/pboakland/static/js/views/place-detail-view.js#L7 I think this concept of "overriding" should be it's own issue, and implemented after our static site migration is complete. I made an issue for it here: #656, which addresses the need to create a spec for the API. So I think we should continue with our current implementation where flavors extend the base through the filesystem, which will get us through the static site migration. But I'm open to other ideas! Happy to discuss this at Wayard as well. |
Agreed. @Lukeswart wow, not sure how I missed that. That's awesome! We should also do something similar for templates, if we don't already. On the more practical side of this issue, I've had a branch proxy-less for a little while now. I think I've successfully removed dependency on the proxy from the client-side app, but I've been struggling to remove it from the server, as I'm pretty unfamiliar with that code. Another step that I've not even started yet is to remove the |
@zmbc @Lukeswart -- I've been working on the static site conversion for the last few days. One issue has come up that I'm unsure about: how should we manage static assets that are split between the base project and a given flavor directory? For example, images and marker icons. Currently Django does all the heavy lifting here, such that we can use a relative url like But how should the static site manage this? Should we copy all static assets from the base project to flavors during our build process? If we do, should we Is there another approach? |
@goldpbear Answers inline, or feel free to ping me anytime:
I think the general solution here is that we'll create our own CDN somewhere like
We should definitely avoid complicating our build process in this manner.
This is on the right track - we'll have a CDN/bucket for our static assets (
Maybe I'm missing something - or this might be case-specific - but I think we should be explicit about the locations of our assets. The build process should not interfere with these locations. If the path is relative, then it will be located in our flavor's bucket, ie: This will require some refactoring, because I believe our And of course, keep me posted! I'm happy to help, when I get some time :-P |
@Lukeswart -- cool, thanks for the feedback. Some followup questions:
As far as I can tell there isn't so much a flavor app as there is a careful use of the staticfiles app. The staticfiles app is configured to look first in flavor subdirectories, then in the base project. By default it will use the first matching static file it finds. I believe this is how the flavor "override" behavior actually works. So when we lose this functionality, I'm imagining we'll need to replace it in our build process. Assuming we want to keep the same flavor directory structure and still be able to reference all static files in the same way as we do now (using relative urls, with flavor-specific assets overriding base project assets), how about this approach:
Is that too convoluted? If I'm understanding correctly the alternative will be to refactor all configs and all templates to convert relative urls to one of two absolute urls: the main mapseed assets store, or the given flavor assets store? Also, how will any of this work in local development? |
I've been thinking about this some more. I'm wondering if maintaining a separate Instead, why not just replicate what Django's static files app is already doing in production: create a single I think this approach is similar to what @Lukeswart cautioned against above, but I think it has some advantages:
Some potential drawbacks:
What do you think? |
We also need to think about this from the perspective of someone using Mapseed, not just us hosting the current flavors. If Mapseed builds sites that reference our S3 buckets,
It's possible that we really don't like having static file duplication (although, as Trevor said, I don't think storage space is really that big of a deal for us), but if we decide to do anything about it, that should be some hack/modification to Mapseed, not part of the Mapseed core. |
@goldpbear
In the context of this issue, I think you're definitely right. We can consider the benefits of having an assets bucket at a later point, but it's out of scope. I probably shouldn't have brought that up. @zmbc thanks for your thoughts on this too - we'll keep those in mind.
This sounds like a good idea :-) But at what point in our build step should we copy over the base static assets into the flavor's I think I was too optimistic when I thought we could handle the flavor's assets outside of our build step. I do believe we'll come up with a more elegant solution when we refactor our flavor modules, outlined in #656, but that's out of scope for now. |
@Lukeswart I don't think that requiring a build step to copy files is all that bad. Depends, obviously, on how long the build step takes 😃. But I know Jekyll requires a rebuild to update static assets, and I think the same is probably true of most static site generators. |
I'm thinking we could set up a watch task on the static files subdirectory (in both the base project and the current flavor), then only copy/modify static assets that change during development. We'd have to cover the case where a brand new asset is added, an existing asset is modified, and an asset is deleted. |
Yes, for development we will want to have an overall watch task for everything (static files, webpack, etc). |
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
🎉 🎉 🎉 |
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
- This commit sets up a static site build process designed to eliminate the need for the front-end Django server. The build handles localization, Handlebars precompilation, and static asset management - The following dev dependecies are introduced: - recursive-copy - js-yaml - node-gettext - gettext-parser - object-walk - handlebars - wax-on Addresses: #655
Updates/additions/thoughts to this issue welcome!
Converting Mapseed from a dynamically rendered site dependent on Django to a static site would have performance and deployment benefits, and is an important step on the road to being able to offer Mapseed as a service.
To migrate to a static site, we'd need to accomplish the following:
base.html
with content in flavorindex.html
files (Do flavor-specific extensions within build process #703)views.py
client-side (Proxy-less #687)views.py
in theroutes.js
file instead, and implement handlers for those routes as separate modules (ieshareabouts-api-client.js
)user_token
logic from Django'sviews.py
to the client...are there other to-dos on the way to a static site that we're missing here?
The text was updated successfully, but these errors were encountered: