Explorar el Código

Merge branch 'master' of https://github.com/sharelatex/web-sharelatex

Henry Oswald hace 12 años
padre
commit
c91e95d593

+ 1 - 1
services/web/app/coffee/Features/Templates/TemplatesController.coffee

@@ -24,7 +24,7 @@ module.exports =
 		if zipUrl.slice(0,12).indexOf("templates") == -1
 		if zipUrl.slice(0,12).indexOf("templates") == -1
 			zipUrl = "#{settings.apis.web.url}#{zipUrl}"
 			zipUrl = "#{settings.apis.web.url}#{zipUrl}"
 		else
 		else
-			zipUrl = "#{settings.apis.templates_api.url}#{zipUrl}"
+			zipUrl = "#{settings.apis.templates.url}#{zipUrl}"
 		request(zipUrl).pipe(writeStream)
 		request(zipUrl).pipe(writeStream)
 		writeStream.on 'close', ->
 		writeStream.on 'close', ->
 			ProjectUploadManager.createProjectFromZipArchive req.session.user._id, req.session.templateData.templateName, dumpPath, (err, project)->
 			ProjectUploadManager.createProjectFromZipArchive req.session.user._id, req.session.templateData.templateName, dumpPath, (err, project)->

+ 1 - 1
services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee

@@ -21,5 +21,5 @@ module.exports =
 		checkForHexRegExp.test(tag_or_id)
 		checkForHexRegExp.test(tag_or_id)
 
 
 	insert_templates_user_id: (req, res, next)->
 	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()
 		next()

+ 1 - 1
services/web/app/coffee/Features/Templates/TemplatesPublisher.coffee

@@ -33,4 +33,4 @@ module.exports =
 
 
 
 
 buildUrl = (user_id, project_id)->
 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}"

+ 2 - 2
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"
 		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.pipe(res)
 		getReq.on "error", (error) ->
 		getReq.on "error", (error) ->
 			logger.error err: error, "templates proxy API error"
 			logger.error err: error, "templates proxy API error"
@@ -86,7 +86,7 @@ module.exports = TemplatesWebController =
 
 
 	_getDataFromTemplatesApi: (path, callback)->
 	_getDataFromTemplatesApi: (path, callback)->
 		opts = 
 		opts = 
-			url: "#{settings.apis.templates_api.url}#{path}"
+			url: "#{settings.apis.templates.url}#{path}"
 			json:true
 			json:true
 		request.get opts, (err, response, data)->
 		request.get opts, (err, response, data)->
 			callback err, data
 			callback err, data

+ 1 - 1
services/web/app/coffee/infrastructure/ExpressLocals.coffee

@@ -131,7 +131,7 @@ module.exports = (app)->
 
 
 	app.use (req, res, next) ->
 	app.use (req, res, next) ->
 		res.locals.nav = Settings.nav
 		res.locals.nav = Settings.nav
-		res.locals.templates = Settings.templates
+		res.locals.templates = Settings.templateLinks
 		next()
 		next()
 		
 		
 	app.use (req, res, next) ->
 	app.use (req, res, next) ->

+ 4 - 4
services/web/app/views/layout.jade

@@ -63,12 +63,12 @@ html(itemscope, itemtype='http://schema.org/Product')
 					indexes:!{JSON.stringify(settings.algolia.indexes)}
 					indexes:!{JSON.stringify(settings.algolia.indexes)}
 				}
 				}
 
 
-		- if (typeof(settings.apis) != "undefined" && typeof(settings.apis.templates_api) != "undefined")
+		- if (typeof(settings.templates) != "undefined")
 			script.
 			script.
 				window.sharelatex.templates = {
 				window.sharelatex.templates = {
-					user_id : '!{settings.apis.templates_api.user_id}',
-					cdnDomain : '!{settings.apis.templates_api.cdnDomain}',
-					indexName : '!{settings.apis.templates_api.indexName}'
+					user_id : '!{settings.templates.user_id}',
+					cdnDomain : '!{settings.templates.cdnDomain}',
+					indexName : '!{settings.templates.indexName}'
 				}
 				}
 				
 				
 	body
 	body

+ 20 - 8
services/web/app/views/templates/tag.jade

@@ -1,5 +1,12 @@
 extends ../layout
 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
 block content
 	.content.content-alt
 	.content.content-alt
 		.container
 		.container
@@ -9,11 +16,16 @@ block content
 						a(href="/templates") #{translate("templates")}
 						a(href="/templates") #{translate("templates")}
 						|  ›
 						|  ›
 						a(href=tag.tagPagePath)  #{tag.name}
 						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}

+ 8 - 15
services/web/config/settings.defaults.coffee

@@ -77,31 +77,24 @@ module.exports =
 		docstore:
 		docstore:
 			url : "http://localhost:3016"
 			url : "http://localhost:3016"
 			pubUrl: "http://localhost:3016"
 			pubUrl: "http://localhost:3016"
-		versioning:
-			snapshotwaitms:3000
-			url: "http://localhost:4000"
-			username: httpAuthUser
-			password: httpAuthPass
-		recurly:
-			privateKey: ""
-			apiKey: ""
-			subdomain: ""
 		chat:
 		chat:
 			url: "http://localhost:3010"
 			url: "http://localhost:3010"
 			internal_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:
 		blog:
 			port: 3008
 			port: 3008
 		filestore:
 		filestore:
 			url: "http://localhost:3009"
 			url: "http://localhost:3009"
 		clsi:
 		clsi:
 			url: "http://localhost:3013"
 			url: "http://localhost:3013"
-		templates_api:
+		templates:
 			url: "http://localhost:3007"
 			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
 	# Where your instance of ShareLaTeX can be found publically. Used in emails
 	# that are sent out, generated links, etc.
 	# that are sent out, generated links, etc.

+ 3 - 0
services/web/public/stylesheets/app/templates.less

@@ -12,6 +12,9 @@
 	.thumbnail {
 	.thumbnail {
 		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);	
 		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);	
 	    -webkit-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 {
 	a {

+ 1 - 1
services/web/test/UnitTests/coffee/Templates/TemplatesControllerTests.coffee

@@ -40,7 +40,7 @@ describe 'TemplatesController', ->
 					dumpFolder:@dumpFolder
 					dumpFolder:@dumpFolder
 				siteUrl: "http://localhost:3000"
 				siteUrl: "http://localhost:3000"
 				apis:
 				apis:
-					templates_api:
+					templates:
 						url: @templateApiUrl="http://templates.sharelatex.env"
 						url: @templateApiUrl="http://templates.sharelatex.env"
 					web:
 					web:
 						url: @webApiUrl="http://web-api.sharelatex.env"
 						url: @webApiUrl="http://web-api.sharelatex.env"

+ 4 - 4
services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee

@@ -15,7 +15,7 @@ describe 'Templates publish', ->
 			get: sinon.stub()
 			get: sinon.stub()
 		@settings = 
 		@settings = 
 			apis:
 			apis:
-				templates_api:
+				templates:
 					url: "http://templates.sharelatex.env"
 					url: "http://templates.sharelatex.env"
 		@TemplatesPublisher = SandboxedModule.require modulePath, requires:
 		@TemplatesPublisher = SandboxedModule.require modulePath, requires:
 			"request": @request
 			"request": @request
@@ -31,7 +31,7 @@ describe 'Templates publish', ->
 
 
 		it 'should post the project to the templates api', (done)->
 		it 'should post the project to the templates api', (done)->
 			@TemplatesPublisher.publish @user_id, @project_id, =>
 			@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
 				@request.post.calledWith(uri).should.equal true
 				done()
 				done()
 
 
@@ -40,7 +40,7 @@ describe 'Templates publish', ->
 
 
 		it "should make a DELETE request to templates api", (done)->
 		it "should make a DELETE request to templates api", (done)->
 			@TemplatesPublisher.unpublish @user_id, @project_id, =>
 			@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
 				@request.del.calledWith(uri).should.equal true
 				done()
 				done()
 
 
@@ -51,7 +51,7 @@ describe 'Templates publish', ->
 				exists:true
 				exists:true
 			@request.get.callsArgWith(1, null, null, JSON.stringify(body))
 			@request.get.callsArgWith(1, null, null, JSON.stringify(body))
 			@TemplatesPublisher.getTemplateDetails @user_id, @project_id, (err, details)=>
 			@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
 				@request.get.calledWith(uri).should.equal true
 				assert.deepEqual details, body
 				assert.deepEqual details, body
 				done()
 				done()