diff --git a/services/web/app/coffee/Features/Templates/TemplatesController.coffee b/services/web/app/coffee/Features/Templates/TemplatesController.coffee index 4f8268da10..8403645629 100644 --- a/services/web/app/coffee/Features/Templates/TemplatesController.coffee +++ b/services/web/app/coffee/Features/Templates/TemplatesController.coffee @@ -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)-> diff --git a/services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee b/services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee index 33e6715167..d86ac09517 100644 --- a/services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee +++ b/services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee @@ -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() diff --git a/services/web/app/coffee/Features/Templates/TemplatesPublisher.coffee b/services/web/app/coffee/Features/Templates/TemplatesPublisher.coffee index f0a76e7ac2..526f631aeb 100644 --- a/services/web/app/coffee/Features/Templates/TemplatesPublisher.coffee +++ b/services/web/app/coffee/Features/Templates/TemplatesPublisher.coffee @@ -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}" diff --git a/services/web/app/coffee/Features/Templates/TemplatesWebController.coffee b/services/web/app/coffee/Features/Templates/TemplatesWebController.coffee index aa6952a8a3..d1608511ea 100644 --- a/services/web/app/coffee/Features/Templates/TemplatesWebController.coffee +++ b/services/web/app/coffee/Features/Templates/TemplatesWebController.coffee @@ -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 \ No newline at end of file diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 62be91eaee..aaf17cc4dd 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -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) -> diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index f078c31cb0..21516686a4 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -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" diff --git a/services/web/app/views/templates/tag.jade b/services/web/app/views/templates/tag.jade index 4ee7e70b76..980794d04b 100644 --- a/services/web/app/views/templates/tag.jade +++ b/services/web/app/views/templates/tag.jade @@ -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} diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index bcfdea08fe..bc41039667 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -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. diff --git a/services/web/public/stylesheets/app/templates.less b/services/web/public/stylesheets/app/templates.less index eeb90592d1..a08f5b8d3c 100644 --- a/services/web/public/stylesheets/app/templates.less +++ b/services/web/public/stylesheets/app/templates.less @@ -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 { diff --git a/services/web/test/UnitTests/coffee/Templates/TemplatesControllerTests.coffee b/services/web/test/UnitTests/coffee/Templates/TemplatesControllerTests.coffee index f147f6a824..60c020cac2 100644 --- a/services/web/test/UnitTests/coffee/Templates/TemplatesControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Templates/TemplatesControllerTests.coffee @@ -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" diff --git a/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee b/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee index 497eae81ce..d7fe3845f3 100644 --- a/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee +++ b/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee @@ -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()