In one of my project, my users will have a dedicated part of my website ({username}.example.org). In that subdomain, I plan to allow them to change the design easily. I took a look at some online website that already does that, like Tumblr, Posterous and Shopify.
Regarding the language of this application, I started it with Django, which I succeedly implemented a "template rendering based on the url name with default as fallback" (http://someuser.example.com will load the templates in templates/someuser/* or in templates/generic/* if not found in the first). But I can export it to PHP or Play!Framework if they are more adapted to my needs.
The template engine used is Jinja2, since it is as simple as Django template engine, easy to learn, and safe (no Python coode can (should normally!) be executed).
Here is the Pros/Cons of each solution I found. I would really appreciate your thoughts on that and which way you would do, why. Thanks.
Note: The users will have a good knowledge in HTML/CSS.
Changing vars (like title color, etc)
Pros:
Cons:
Only upload CSS
Pros:
Cons:
Allow user to edit templates (stored in the database)
Pros:
Cons:
Allow user to edit templates (stored in files)
Pros:
Cons:
Also, where I'm stuck is about how to handle static files (images, css, js) : I can't see how to define a VirtualHost in Apache (or NGinx) that would request the database to see which users belongs this url.
Thanks for your help, I appreciate!
Ok, I'll answer myself based on what I did and my research.
As Steve mentionned, you have to be very careful about letting users customise page layout.
The risk must be well evaluated!
In my case, letting users change the complete HTML/CSS/JS is possible, in a way, like Posterous or Tumblr does.
The risks are :
If those two conditions are well evaluated, the option "Allow user to edit templates (stored in the database)" is a good solution.
But if you are worried about too many hits the database could have, the last solution, aka "Allow user to edit templates (stored in files)", could be possible, if :
Well, I think I covered the whole problem. It's possible I miss some points, if it's the case, please add a comment or a new post and I will complete the answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With