Skip to first unread message

guruyaya

unread,
Nov 20, 2013, 2:40:55 PM11/20/13
to web2py-d...@googlegroups.com
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?

Marin Pranjić

unread,
Nov 20, 2013, 2:52:06 PM11/20/13
to web2py-d...@googlegroups.com
I think this is developer's responsibility. Logic that you described it easy to implement.
Many apps are not meant to be "themeable". I don't think web2py as a framework should support it.

Marin




--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Massimo DiPierro

unread,
Nov 20, 2013, 2:56:03 PM11/20/13
to web2py-d...@googlegroups.com
One problem is that file lookup is expensive. We can already apply themes as plugins. The problem is nobody makes them.

Massimo DiPierro

unread,
Nov 20, 2013, 2:56:49 PM11/20/13
to web2py-d...@googlegroups.com
Files look up are expensive. I think we should avoid it. What about 


On Nov 20, 2013, at 1:40 PM, guruyaya wrote:

guruyaya

unread,
Nov 20, 2013, 3:38:08 PM11/20/13
to web2py-d...@googlegroups.com
OK. I'll try another idea.
A Theme will consist of the whole views folder. That means, I can just tell web2py, that the views folder is now called views/themes/SexyTheme, and it should run from there.

Massimo DiPierro

unread,
Nov 20, 2013, 3:43:36 PM11/20/13
to web2py-d...@googlegroups.com
If you call it 

views/plugin_themes_SexyTheme

That it is a plugin.

Niphlod

unread,
Nov 20, 2013, 4:27:16 PM11/20/13
to web2py-d...@googlegroups.com
Let's face it, there's no such thing as an accomplishable theme switch from the (remote) times of zengarden.

I mean, if your app is a blog with the exact same markup, then yes, it could be totally doable.
If instead it's more complicated than that, all layers should be synced from the ground up.

Semantic css was a cool dream, that with the adoption of several hundreds of lines of css frameworks disappeared into thin air, together along with mobile-friendly (later mobile-ready) **layouts**.

I think web2py should - eventually - encourage several scaffolding apps with their own widgets override (we have a too "restrictive" set of 1 as it is) more than several plugin themes.

Reply all
Reply to author
Forward
0 new messages