开发者

Rails Giving Each User Their Own Customizable Stylesheet

开发者 https://www.devze.com 2023-01-21 13:54 出处:网络
This is a fairly straightforward question. I have Users in my Rails3 Application. I want to give each user the ability to customize their stylesheet through a form so they can essentia开发者_JAVA百科

This is a fairly straightforward question.

I have Users in my Rails3 Application. I want to give each user the ability to customize their stylesheet through a form so they can essentia开发者_JAVA百科lly have their own themes.

I was wondering how I can go about getting this to happen and what is the best way that you have seen it done?

Would I need to use LessCss and if so, can I pass variables from a controller to the lesscss sylesheet?


Despite that sounding like a terrible idea I guess an easy way to do it would be to add a CSS table and map it to the user with a record for each CSS file. When a new user is created you create new records for each file using the default CSS.

To edit you could present the user with the CSS text on a page with some sample mini-page where they could see the changes happen live. You would then need to load the CSS dynamically which could be a huge hit on your database so you'd want to add some memory to the call to retrieve the CSS.

Again though, this is a horrible idea in my opinion. What happens when the user messes up and then can't use the site because they put in some bad value? They can't change it back because they can't see anything so what do they do? They never come back.

You'd be better off just allowing them to pick from a set of allowed themes. But hey, it's your website, you do with it as you please.

0

精彩评论

暂无评论...
验证码 换一张
取 消