mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 14:59:19 +00:00
be able to get build templates from web as well as templates
This commit is contained in:
parent
dbe2dd3078
commit
c23f9aa056
2 changed files with 27 additions and 3 deletions
|
@ -19,7 +19,10 @@ module.exports =
|
|||
dumpPath = "#{settings.path.dumpFolder}/#{uuid.v4()}"
|
||||
writeStream = fs.createWriteStream(dumpPath)
|
||||
zipUrl = req.session.templateData.zipUrl
|
||||
zipUrl = "#{settings.apis.templates_api.url}#{zipUrl}"
|
||||
if zipUrl.slice(0,12).indexOf("templates") == -1
|
||||
zipUrl = "#{settings.apis.web.url}#{zipUrl}"
|
||||
else
|
||||
zipUrl = "#{settings.apis.templates_api.url}#{zipUrl}"
|
||||
request(zipUrl).pipe(writeStream)
|
||||
writeStream.on 'close', ->
|
||||
ProjectUploadManager.createProjectFromZipArchive req.session.user._id, req.session.templateData.templateName, dumpPath, (err, project)->
|
||||
|
|
|
@ -39,16 +39,20 @@ describe 'TemplatesController', ->
|
|||
apis:
|
||||
templates_api:
|
||||
url: @templateApiUrl="http://templates.sharelatex.env"
|
||||
web:
|
||||
url: @webApiUrl="http://web-api.sharelatex.env"
|
||||
"node-uuid":v4:=>@uuid
|
||||
"request": @request
|
||||
"fs":@fs
|
||||
@zipUrl = "www.sharelatex.com/templates/cv/best.zip"
|
||||
@zipUrl = "%2Ftemplates%2F52fb86a81ae1e566597a25f6%2Fv%2F4%2Fzip&templateName=Moderncv%20Banking&compiler=pdflatex"
|
||||
@templateName = "project name here"
|
||||
@user_id = "1234"
|
||||
@req =
|
||||
session:
|
||||
user: _id:@user_id
|
||||
templateData: zipUrl: @zipUrl, templateName: @templateName
|
||||
templateData:
|
||||
zipUrl: @zipUrl
|
||||
templateName: @templateName
|
||||
@redirect = {}
|
||||
|
||||
describe 'reciving a request to create project from templates.sharelatex.com', ->
|
||||
|
@ -62,6 +66,23 @@ describe 'TemplatesController', ->
|
|||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
|
||||
it "should go to the web api if the url does not contain templates", (done)->
|
||||
@req.session.templateData.zipUrl = @zipUrl = "/project/52fd24abf080d80a22000fbd/download/zip&templateName=Example_Project&compiler=xelatex"
|
||||
redirect = =>
|
||||
@request.calledWith("#{@webApiUrl}#{@zipUrl}").should.equal true
|
||||
done()
|
||||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
it "should go to the web api if the url has template futher down the string", (done)->
|
||||
@req.session.templateData.zipUrl = @zipUrl = "/project/52fd24abf080d80a22000fbd/download/zip&templateName=templates&compiler=xelatex"
|
||||
redirect = =>
|
||||
@request.calledWith("#{@webApiUrl}#{@zipUrl}").should.equal true
|
||||
done()
|
||||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
describe 'publishProject', (done)->
|
||||
beforeEach ->
|
||||
@user_id = "sdijdlsakjlkajdklaj"
|
||||
|
|
Loading…
Reference in a new issue