While I started playing with some new project I had, I've found myself wondering, what if web2py had a simple theme support.
Say, I've installed instantpress, and could easly go to the admin panel, upload a zip file, containing the basic files needed to replace the look and feel of the website - and I have a new look to my website. Just like I can do in wordpress. I think this can lead to more adoption of web2py apps, outside the developers community.
Another helpful aspect of this, is allowing development of open-source project, with proprioty themes. Widening the varaity of options a developer can have to earn from his work on a project.
I'm thinking of something that works with this kind of logic:
In the model, I write
response.theme = 'SexyTheme'
Now, in this example, I just finished running index function in the default.py controller. I either returned a dict
When render function is running, it first looks for index.html in
(app folder)/views/themes/SexyTheme/index.html
Failed to find it, it tries:
(app folder)/views/index.html
Failed to find this one, it goes to
(app folder)/views/themes/SexyTheme/generic.html
Failed again - goes to
(app folder)/views/index.html
Note that if no theme is installed, the outcome is just web2py regular behavier, and it'll fail the first 2
If response.render is called, it's the look pretty similar, just looking for the file response.render called in the same directories.
Another behavior change will be in the "extend" and "include" template functions, that will also start by looking for
(app folder)/views/themes/SexyTheme/layout.html
And only then go to
(app folder)/views/layout.html
A theme zip file, should basicly contain views folder, and static folder, and INI file, containing the app that it belongs to, and theme name (I'm not sure the INI file is a must, but it seems like a good idea).
I think I can acctually code something like this in a week or 2, but I wanted to know if everybody like the idea and the suggested design.
So.... Any comments?