Merge branch 'james_tmp'

This commit is contained in:
James Allen 2014-08-22 12:51:35 +01:00
commit 456d194dbb
11 changed files with 43 additions and 34 deletions

View file

@ -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)->

View file

@ -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()

View file

@ -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}"

View file

@ -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

View file

@ -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) ->

View file

@ -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"

View file

@ -1,5 +1,12 @@
extends ../layout
mixin template(template)
.template-thumbnail
a(href=template.templatePagePath ? template.templatePagePath : template.canonicalUrl).thumbnail
img(src=template.thumbnailUrl)
div.caption
h3 #{template.name}
block content
.content.content-alt
.container
@ -9,11 +16,16 @@ block content
a(href="/templates") #{translate("templates")}
|
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}
- for (var row = 0; row <= Math.floor(templates.length / 4); row++)
.row
- for (var column = 0; column < 4; column++)
- if (templates[row*4 + column])
.col-md-3
+template(templates[row*4 + column])
//- -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}

View file

@ -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.

View file

@ -12,6 +12,9 @@
.thumbnail {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);
img {
width: 100%;
}
}
a {

View file

@ -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"

View file

@ -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()