2014-06-30 16:08:54 +00:00
|
|
|
settings = require("settings-sharelatex")
|
2014-07-01 14:44:12 +00:00
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
|
2014-06-30 16:08:54 +00:00
|
|
|
|
2014-02-12 10:23:40 +00:00
|
|
|
module.exports =
|
|
|
|
saveTemplateDataInSession: (req, res, next)->
|
|
|
|
if req.query.templateName
|
|
|
|
req.session.templateData = req.query
|
|
|
|
next()
|
|
|
|
|
2014-06-30 16:08:54 +00: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 10:23:40 +00:00
|
|
|
|
2014-06-30 16:08:54 +00:00
|
|
|
insert_templates_user_id: (req, res, next)->
|
2014-08-20 13:47:27 +00:00
|
|
|
req.params.user_id = settings.templates.user_id
|
2014-07-01 14:44:12 +00:00
|
|
|
next()
|