2014-06-30 12:08:54 -04:00
|
|
|
settings = require("settings-sharelatex")
|
|
|
|
|
2014-02-12 05:23:40 -05:00
|
|
|
module.exports =
|
|
|
|
saveTemplateDataInSession: (req, res, next)->
|
|
|
|
if req.query.templateName
|
|
|
|
req.session.templateData = req.query
|
|
|
|
next()
|
|
|
|
|
2014-06-30 12:08:54 -04:00
|
|
|
id_or_tag_parse: (req, res, next)->
|
|
|
|
tag_or_template_id = req.params.tag_or_template_id
|
|
|
|
if _isObjectId(tag_or_template_id)
|
|
|
|
req.params.template_id = tag_or_template_id
|
|
|
|
else
|
|
|
|
req.params.tag_name = tag_or_template_id
|
|
|
|
next()
|
|
|
|
|
|
|
|
_isObjectId: _isObjectId = (tag_or_id)->
|
|
|
|
checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$")
|
|
|
|
checkForHexRegExp.test(tag_or_id)
|
2014-02-12 05:23:40 -05:00
|
|
|
|
2014-06-30 12:08:54 -04:00
|
|
|
insert_templates_user_id: (req, res, next)->
|
2014-07-01 09:25:32 -04:00
|
|
|
req.params.user_id = settings.apis.templates_api.user_id
|
2014-06-30 12:08:54 -04:00
|
|
|
next()
|