mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Download template PDF and zip file with good file names
This commit is contained in:
parent
2aa421233c
commit
3348249dcd
3 changed files with 20 additions and 4 deletions
|
@ -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) ->
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -57,3 +57,9 @@
|
|||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.template-large-pdf-preview {
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue