简体   繁体   English

Rails应用程序中的用户定义主题:如何存储资产

[英]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. 每个主题都应包括所有必要的资源,例如html模板(使用Liquid),css文件,javascript和图像。 The result should be very similar to what Shopify allow to do to their customers. 结果应该与Shopify允许对客户的行为非常相似。

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 虽然使用自定义商店提供html / liquid文件似乎很容易,但我对如何引用和提供1)主题所需的图像,2)主题所需的CSS文件,3)CSS所需的图像感到困惑。文件
  • 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 用户可以通过Web界面编辑上传的模板

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. 数据库/文件系统的混合可能是最佳的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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