Download template PDF and zip file with good file names

This commit is contained in:
James Allen 2014-08-12 12:02:09 +01:00
parent 2aa421233c
commit 3348249dcd
3 changed files with 20 additions and 4 deletions

View file

@ -36,7 +36,17 @@ module.exports = TemplatesWebController =
proxyToTemplatesApi: (req, res)->
url = req.url
logger.log url:url, "proxying request to templates api"
name = req.query.name or "Template"
if req.query.inline?
disposition = "inline"
else
disposition = "attachment"
console.log "HEADER", "#{disposition}; filename=#{name};"
res.header({"content-disposition": "#{disposition}; filename=#{name}.#{req.params.file_type};"})
logger.log url:url, template_name: name, disposition: disposition, "proxying request to templates api"
getReq = request.get("#{settings.apis.templates_api.url}#{url}")
getReq.pipe(res)
getReq.on "error", (error) ->

View file

@ -20,8 +20,8 @@ block content
.col-md-6
.entry
.row
.col-md-12
a(href=template.pdfUrl)
.col-md-12.template-large-pdf-preview
a(href="#{template.pdfUrl}?inline=true&name=#{template.name}")
img(src="#{template.previewUrl}")
.col-md-6
@ -33,7 +33,7 @@ block content
|  
a.btn.btn-default(
href=template.zipUrl,
href="#{template.zipUrl}?name=#{template.name}",
rel='nofollow',
ng-click='downloadZip()',
tooltip-placement="bottom",

View file

@ -57,3 +57,9 @@
height: auto;
}
}
.template-large-pdf-preview {
img {
max-width: 100%;
}
}