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)->
|
proxyToTemplatesApi: (req, res)->
|
||||||
url = req.url
|
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 = request.get("#{settings.apis.templates_api.url}#{url}")
|
||||||
getReq.pipe(res)
|
getReq.pipe(res)
|
||||||
getReq.on "error", (error) ->
|
getReq.on "error", (error) ->
|
||||||
|
|
|
@ -20,8 +20,8 @@ block content
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.entry
|
.entry
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12.template-large-pdf-preview
|
||||||
a(href=template.pdfUrl)
|
a(href="#{template.pdfUrl}?inline=true&name=#{template.name}")
|
||||||
img(src="#{template.previewUrl}")
|
img(src="#{template.previewUrl}")
|
||||||
|
|
||||||
.col-md-6
|
.col-md-6
|
||||||
|
@ -33,7 +33,7 @@ block content
|
||||||
|
|
|
|
||||||
|
|
||||||
a.btn.btn-default(
|
a.btn.btn-default(
|
||||||
href=template.zipUrl,
|
href="#{template.zipUrl}?name=#{template.name}",
|
||||||
rel='nofollow',
|
rel='nofollow',
|
||||||
ng-click='downloadZip()',
|
ng-click='downloadZip()',
|
||||||
tooltip-placement="bottom",
|
tooltip-placement="bottom",
|
||||||
|
|
|
@ -56,4 +56,10 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-large-pdf-preview {
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue