2014-02-14 11:39:05 -05:00
|
|
|
settings = require("settings-sharelatex")
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
|
|
|
|
getConvertedFolderKey: (key)->
|
|
|
|
key = "#{key}-converted-cache/"
|
|
|
|
|
|
|
|
addCachingToKey: (key, opts)->
|
|
|
|
key = @getConvertedFolderKey(key)
|
|
|
|
if opts.format? and !opts.style?
|
|
|
|
key = "#{key}format-#{opts.format}"
|
|
|
|
if opts.style? and !opts.format?
|
|
|
|
key = "#{key}style-#{opts.style}"
|
|
|
|
if opts.style? and opts.format?
|
|
|
|
key = "#{key}format-#{opts.format}-style-#{opts.style}"
|
|
|
|
return key
|
|
|
|
|
|
|
|
|
|
|
|
userFileKey: (req, res, next)->
|
|
|
|
{project_id, file_id} = req.params
|
|
|
|
req.key = "#{project_id}/#{file_id}"
|
2014-03-04 10:01:13 -05:00
|
|
|
req.bucket = settings.filestore.stores.user_files
|
2014-02-14 11:39:05 -05:00
|
|
|
next()
|
|
|
|
|
|
|
|
templateFileKey: (req, res, next)->
|
|
|
|
{template_id, format, version} = req.params
|
2014-03-05 12:39:27 -05:00
|
|
|
req.key = "#{template_id}/v/#{version}/#{format}"
|
2014-03-04 10:01:13 -05:00
|
|
|
req.bucket = settings.filestore.stores.template_files
|
2014-02-14 11:39:05 -05:00
|
|
|
req.version = version
|
|
|
|
opts = req.query
|
|
|
|
next()
|
|
|
|
|
2014-03-04 10:01:13 -05:00
|
|
|
|