mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 15:49:01 +02:00
Refactor template settings
This commit is contained in:
@@ -24,7 +24,7 @@ module.exports =
|
||||
if zipUrl.slice(0,12).indexOf("templates") == -1
|
||||
zipUrl = "#{settings.apis.web.url}#{zipUrl}"
|
||||
else
|
||||
zipUrl = "#{settings.apis.templates_api.url}#{zipUrl}"
|
||||
zipUrl = "#{settings.apis.templates.url}#{zipUrl}"
|
||||
request(zipUrl).pipe(writeStream)
|
||||
writeStream.on 'close', ->
|
||||
ProjectUploadManager.createProjectFromZipArchive req.session.user._id, req.session.templateData.templateName, dumpPath, (err, project)->
|
||||
|
||||
@@ -21,5 +21,5 @@ module.exports =
|
||||
checkForHexRegExp.test(tag_or_id)
|
||||
|
||||
insert_templates_user_id: (req, res, next)->
|
||||
req.params.user_id = settings.apis.templates_api.user_id
|
||||
req.params.user_id = settings.templates.user_id
|
||||
next()
|
||||
|
||||
@@ -33,4 +33,4 @@ module.exports =
|
||||
|
||||
|
||||
buildUrl = (user_id, project_id)->
|
||||
url = "#{settings.apis.templates_api.url}/templates/user/#{user_id}/project/#{project_id}"
|
||||
url = "#{settings.apis.templates.url}/templates/user/#{user_id}/project/#{project_id}"
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = TemplatesWebController =
|
||||
|
||||
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.url}#{url}")
|
||||
getReq.pipe(res)
|
||||
getReq.on "error", (error) ->
|
||||
logger.error err: error, "templates proxy API error"
|
||||
@@ -86,7 +86,7 @@ module.exports = TemplatesWebController =
|
||||
|
||||
_getDataFromTemplatesApi: (path, callback)->
|
||||
opts =
|
||||
url: "#{settings.apis.templates_api.url}#{path}"
|
||||
url: "#{settings.apis.templates.url}#{path}"
|
||||
json:true
|
||||
request.get opts, (err, response, data)->
|
||||
callback err, data
|
||||
@@ -131,7 +131,7 @@ module.exports = (app)->
|
||||
|
||||
app.use (req, res, next) ->
|
||||
res.locals.nav = Settings.nav
|
||||
res.locals.templates = Settings.templates
|
||||
res.locals.templates = Settings.templateLinks
|
||||
next()
|
||||
|
||||
app.use (req, res, next) ->
|
||||
|
||||
@@ -44,6 +44,7 @@ logger = require("logger-sharelatex")
|
||||
_ = require("underscore")
|
||||
|
||||
httpAuth = require('express').basicAuth (user, pass)->
|
||||
console.log "AUTH", user, pass, Settings.httpAuthUsers
|
||||
isValid = Settings.httpAuthUsers[user] == pass
|
||||
if !isValid
|
||||
logger.err user:user, pass:pass, "invalid login details"
|
||||
|
||||
@@ -10,10 +10,11 @@ block content
|
||||
| ›
|
||||
a(href=tag.tagPagePath) #{tag.name}
|
||||
.row
|
||||
-each template in templates
|
||||
a(href=template.templatePagePath || template.canonicalUrl)
|
||||
.col-md-3.template-thumbnail
|
||||
a(href=template.templatePagePath ? template.templatePagePath : template.canonicalUrl).thumbnail
|
||||
img(src=template.thumbnailUrl)
|
||||
div.caption
|
||||
h3 #{template.name}
|
||||
- _.groupBy(templates, function(e, i) { return Math.floor(index/4) });
|
||||
//- -each template in templates
|
||||
//- a(href=template.templatePagePath || template.canonicalUrl)
|
||||
//- .col-md-3.template-thumbnail
|
||||
//- a(href=template.templatePagePath ? template.templatePagePath : template.canonicalUrl).thumbnail
|
||||
//- img(src=template.thumbnailUrl)
|
||||
//- div.caption
|
||||
//- h3 #{template.name}
|
||||
|
||||
@@ -77,31 +77,24 @@ module.exports =
|
||||
docstore:
|
||||
url : "http://localhost:3016"
|
||||
pubUrl: "http://localhost:3016"
|
||||
versioning:
|
||||
snapshotwaitms:3000
|
||||
url: "http://localhost:4000"
|
||||
username: httpAuthUser
|
||||
password: httpAuthPass
|
||||
recurly:
|
||||
privateKey: ""
|
||||
apiKey: ""
|
||||
subdomain: ""
|
||||
chat:
|
||||
url: "http://localhost:3010"
|
||||
internal_url: "http://localhost:3010"
|
||||
templates:
|
||||
port: 3007
|
||||
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"
|
||||
cdnDomain: "https://d340ybc4pnuh67.cloudfront.net"
|
||||
indexName:"templates-development"
|
||||
blog:
|
||||
port: 3008
|
||||
filestore:
|
||||
url: "http://localhost:3009"
|
||||
clsi:
|
||||
url: "http://localhost:3013"
|
||||
templates_api:
|
||||
templates:
|
||||
url: "http://localhost:3007"
|
||||
recurly:
|
||||
privateKey: ""
|
||||
apiKey: ""
|
||||
subdomain: ""
|
||||
|
||||
templates:
|
||||
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"
|
||||
|
||||
# Where your instance of ShareLaTeX can be found publically. Used in emails
|
||||
# that are sent out, generated links, etc.
|
||||
|
||||
@@ -40,7 +40,7 @@ describe 'TemplatesController', ->
|
||||
dumpFolder:@dumpFolder
|
||||
siteUrl: "http://localhost:3000"
|
||||
apis:
|
||||
templates_api:
|
||||
templates:
|
||||
url: @templateApiUrl="http://templates.sharelatex.env"
|
||||
web:
|
||||
url: @webApiUrl="http://web-api.sharelatex.env"
|
||||
|
||||
@@ -15,7 +15,7 @@ describe 'Templates publish', ->
|
||||
get: sinon.stub()
|
||||
@settings =
|
||||
apis:
|
||||
templates_api:
|
||||
templates:
|
||||
url: "http://templates.sharelatex.env"
|
||||
@TemplatesPublisher = SandboxedModule.require modulePath, requires:
|
||||
"request": @request
|
||||
@@ -31,7 +31,7 @@ describe 'Templates publish', ->
|
||||
|
||||
it 'should post the project to the templates api', (done)->
|
||||
@TemplatesPublisher.publish @user_id, @project_id, =>
|
||||
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||
uri = "#{@settings.apis.templates.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||
@request.post.calledWith(uri).should.equal true
|
||||
done()
|
||||
|
||||
@@ -40,7 +40,7 @@ describe 'Templates publish', ->
|
||||
|
||||
it "should make a DELETE request to templates api", (done)->
|
||||
@TemplatesPublisher.unpublish @user_id, @project_id, =>
|
||||
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||
uri = "#{@settings.apis.templates.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||
@request.del.calledWith(uri).should.equal true
|
||||
done()
|
||||
|
||||
@@ -51,7 +51,7 @@ describe 'Templates publish', ->
|
||||
exists:true
|
||||
@request.get.callsArgWith(1, null, null, JSON.stringify(body))
|
||||
@TemplatesPublisher.getTemplateDetails @user_id, @project_id, (err, details)=>
|
||||
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}/details"
|
||||
uri = "#{@settings.apis.templates.url}/templates/user/#{@user_id}/project/#{@project_id}/details"
|
||||
@request.get.calledWith(uri).should.equal true
|
||||
assert.deepEqual details, body
|
||||
done()
|
||||
|
||||
Reference in New Issue
Block a user