brettvanderwerff / Flaskerizer

Automatically create Flask apps from Bootstrap templates
GNU General Public License v2.0
126 stars 15 forks source link

Make Flaskerizer work with https://startbootstrap.com bootstrap templates #2

Closed brettvanderwerff closed 6 years ago

brettvanderwerff commented 6 years ago

I built Flaskerizer to work with https://bootstrapmade.com/ bootstrap templates, mostly because they have a very consistent structure to them with HTML files in the top level directory of the bootstrap template. However, there are other very popular bootstrap template sites like https://startbootstrap.com, which do not have the same structure and will not currently work with Flaskerizer.

For example this bootstrap template: https://startbootstrap.com/template-overviews/sb-admin-2/

from startbootstrap.com is a large site that has all the HTML files in a 'pages' folder within the top level directory of the bootstrap template. The parse_html method of the StructureDirectory class in Flaskerizer may need to be modified to search the entire bootstrap template directory for HTML files, rather than just searching the top level directory like it does right now. I can potentially see an issue with this right off the bat because there are two index.html templates in two different places in https://startbootstrap.com/template-overviews/sb-admin-2/, so this may take some creative thinking.

There are additional issues with the parse_html method handling the HTML files in https://startbootstrap.com/template-overviews/sb-admin-2/

in that links like this:

<link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

are not properly converted to this:

<link href="/static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

like they should be. This should not be too difficult of a fix though.

brettvanderwerff commented 6 years ago

I'm going to take this one.

brettvanderwerff commented 6 years ago

As much as I hate to say this I think that having the user unzip the template and point to the path of the folder with the HTML files that they want migrated to the flask templates folder are with a new config.py dictionary value. Similarly they would point to the path of the folder that contains stuff that they want migrated to the flask static folder with a second config dictionary value. This might be the right answer to get this working now in a way that is broad to many template sources. This prevents us from having to build something that parses the entire bootstrap template tree looking for HTML files and then having to throw an error when we find HTML files of the same name in two different directories (which is common with how startbootstrap.com structures templates unfortunately).

I may make a config value that takes a path that points to the javascript too (#31 ). Its seems like a lot for the user, but it will reduce errors and ambiguity and its a small price to pay for the level of automation that happens while flaskerizer is running in my opinion.