let user modify css propertise from front end of rails app
i am creating a cms / portal that i want each user to change certain css properise ie colors, widths, backgrounds etc to customise there own version of my site.
What is the best way to do this ? i have looked into sass but not sure if this is possible from front end as the css would need to be recompiled each time etc ?
Any one done this or got any su开发者_StackOverflow社区ggestions please help.
thanks rick
You can use sass if you like, but it's possible to do this using plain CSS too. Use whichever you prefer. Sass doesn't need to be recompiled for each request, it can be either:
- Pre-compiled at deploy time
- Served from a controller and page-cached
If you want your users to edit only certain properties then you can use a standard MVC approach to serve your stylesheets with page caching:
- Create a stylesheet model with the columns you want to have editable.
- Provide your users a form to manage their stylesheet (there are some good jQuery plugins for color selectors, etc.)
- Serve the stylesheets from a controller (e.g. routed to
/users/1/stylesheet.css
) - Cache the stylesheet output using
caches_page
so it gets served statically on future requests.
Let the user edit an .scss
file.
Use codemirror for editing.
- SASS/SCSS: http://sass-lang.com/
- CodeMirror: http://codemirror.net/csstest.html
精彩评论