简体   繁体   中英

User-defined themes in a rails app: how to store the assets

I am building an application that should allow user to upload their themes to display the data in a custom way. Each theme should include all the necessary assets such as html template (using Liquid), css files, javascripts and images. The result should be very similar to what Shopify allow to do to their customers.

I am struggling to find the best way for the users to submit their themes and for the application to serve them back. Specifically, what are the best practices:

  • To serve them back to the visitors. While serving the html/liquid files seems to be easy enough using a custom store, I am confused on how to reference and serve 1) images required by the themes, 2) css files required by the themes, 3) images required by the css file
  • To consequentely store the different asset types (eg, database vs uploaded file and folder structure for the uploaded files)
  • Possibility for the users to edit the uploaded templates through a web interface

Thanks in advance.

The asset pipeline is primarily designed for serving fixed assets that are pre-compiled at deploy time. There is quite a lot of overhead in doing this, and I don't think it's suitable for serving dynamically editable content.

To attack this problem I would make a list of matrix of all the asset types on the system (user and static) and what the options are for each.

Next to each write possible storage options, eg filesystem raw, filesystem pipeline, database. Then work out the pros and cons for each approach, and the approximate complexity of each.

I don't think using the pipeline for this would be a best-practice unless you are really, really concerned about front-end performance; it would be a lot of work to get it going.

A mix of database/filesystem would probably be optimal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM