mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'master' of github.com:sharelatex/web-sharelatex
This commit is contained in:
commit
fdacf13782
5 changed files with 72 additions and 5 deletions
|
@ -5,6 +5,12 @@ _ = require("underscore")
|
||||||
ErrorController = require "../Errors/ErrorController"
|
ErrorController = require "../Errors/ErrorController"
|
||||||
StaticPageHelpers = require("./StaticPageHelpers")
|
StaticPageHelpers = require("./StaticPageHelpers")
|
||||||
sanitize = require('sanitizer')
|
sanitize = require('sanitizer')
|
||||||
|
Settings = require("settings-sharelatex")
|
||||||
|
contentful = require('contentful')
|
||||||
|
marked = require("marked")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = UniversityController =
|
module.exports = UniversityController =
|
||||||
|
|
||||||
|
@ -17,7 +23,7 @@ module.exports = UniversityController =
|
||||||
logger.log url:url, "proxying request to university api"
|
logger.log url:url, "proxying request to university api"
|
||||||
request.get universityUrl, (err, r, data)->
|
request.get universityUrl, (err, r, data)->
|
||||||
if r?.statusCode == 404
|
if r?.statusCode == 404
|
||||||
return ErrorController.notFound(req, res, next)
|
return UniversityController.getContentfulPage(req, res, next)
|
||||||
if err?
|
if err?
|
||||||
return res.send 500
|
return res.send 500
|
||||||
data = data.trim()
|
data = data.trim()
|
||||||
|
@ -37,4 +43,28 @@ module.exports = UniversityController =
|
||||||
upstream = request.get(originUrl)
|
upstream = request.get(originUrl)
|
||||||
upstream.on "error", (error) ->
|
upstream.on "error", (error) ->
|
||||||
logger.error err: error, "university proxy error"
|
logger.error err: error, "university proxy error"
|
||||||
upstream.pipe res
|
upstream.pipe res
|
||||||
|
|
||||||
|
getContentfulPage: (req, res, next)->
|
||||||
|
console.log Settings.contentful
|
||||||
|
if !Settings.contentful?.uni?.space? and !Settings.contentful?.uni?.accessToken?
|
||||||
|
return ErrorController.notFound(req, res, next)
|
||||||
|
|
||||||
|
client = contentful.createClient({
|
||||||
|
space: Settings.contentful?.uni?.space
|
||||||
|
accessToken: Settings.contentful?.uni?.accessToken
|
||||||
|
})
|
||||||
|
|
||||||
|
url = req.url?.toLowerCase().replace("/university/","")
|
||||||
|
client.getEntries({content_type: 'caseStudy', 'fields.slug':url})
|
||||||
|
.catch (e)->
|
||||||
|
return res.send 500
|
||||||
|
.then (entry)->
|
||||||
|
if !entry? or !entry.items? or entry.items.length == 0
|
||||||
|
return ErrorController.notFound(req, res, next)
|
||||||
|
viewData = entry.items[0].fields
|
||||||
|
viewData.html = marked(viewData.content)
|
||||||
|
res.render "university/case_study", viewData:viewData
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ module.exports = UserController =
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, user_id:user_id, "error getting user for email update"
|
logger.err err:err, user_id:user_id, "error getting user for email update"
|
||||||
return res.send 500
|
return res.send 500
|
||||||
|
req.session.user.email = user.email
|
||||||
UserHandler.populateGroupLicenceInvite user, (err)-> #need to refresh this in the background
|
UserHandler.populateGroupLicenceInvite user, (err)-> #need to refresh this in the background
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, "error populateGroupLicenceInvite"
|
logger.err err:err, "error populateGroupLicenceInvite"
|
||||||
|
@ -127,6 +128,5 @@ module.exports = UserController =
|
||||||
type:'error'
|
type:'error'
|
||||||
text:'Your old password is wrong'
|
text:'Your old password is wrong'
|
||||||
|
|
||||||
changeEmailAddress: (req, res)->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
19
services/web/app/views/university/case_study.jade
Normal file
19
services/web/app/views/university/case_study.jade
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
extends ../layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
.masthead
|
||||||
|
.container
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
h1 !{viewData.title}
|
||||||
|
.row.row-spaced
|
||||||
|
|
||||||
|
.pattern-container
|
||||||
|
.content
|
||||||
|
.container
|
||||||
|
.row
|
||||||
|
.col-md-10.col-md-offset-1
|
||||||
|
.card
|
||||||
|
.row
|
||||||
|
| !{viewData.html}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
"body-parser": "^1.13.1",
|
"body-parser": "^1.13.1",
|
||||||
"bufferedstream": "1.6.0",
|
"bufferedstream": "1.6.0",
|
||||||
"connect-redis": "2.3.0",
|
"connect-redis": "2.3.0",
|
||||||
|
"contentful": "^3.3.14",
|
||||||
"cookie": "^0.2.3",
|
"cookie": "^0.2.3",
|
||||||
"cookie-parser": "1.3.5",
|
"cookie-parser": "1.3.5",
|
||||||
"csurf": "^1.8.3",
|
"csurf": "^1.8.3",
|
||||||
|
@ -31,7 +32,7 @@
|
||||||
"ldapjs": "^1.0.0",
|
"ldapjs": "^1.0.0",
|
||||||
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.3.1",
|
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.3.1",
|
||||||
"lynx": "0.1.1",
|
"lynx": "0.1.1",
|
||||||
"marked": "^0.3.3",
|
"marked": "^0.3.5",
|
||||||
"method-override": "^2.3.3",
|
"method-override": "^2.3.3",
|
||||||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.3.0",
|
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.3.0",
|
||||||
"mimelib": "0.2.14",
|
"mimelib": "0.2.14",
|
||||||
|
|
|
@ -57,7 +57,9 @@ describe "UserController", ->
|
||||||
"../Subscription/SubscriptionDomainHandler":@SubscriptionDomainHandler
|
"../Subscription/SubscriptionDomainHandler":@SubscriptionDomainHandler
|
||||||
"./UserHandler":@UserHandler
|
"./UserHandler":@UserHandler
|
||||||
"settings-sharelatex": @settings
|
"settings-sharelatex": @settings
|
||||||
"logger-sharelatex": {log:->}
|
"logger-sharelatex":
|
||||||
|
log:->
|
||||||
|
err:->
|
||||||
"../../infrastructure/Metrics": inc:->
|
"../../infrastructure/Metrics": inc:->
|
||||||
|
|
||||||
@req =
|
@req =
|
||||||
|
@ -65,6 +67,7 @@ describe "UserController", ->
|
||||||
destroy:->
|
destroy:->
|
||||||
user :
|
user :
|
||||||
_id : @user_id
|
_id : @user_id
|
||||||
|
email:"old@something.com"
|
||||||
body:{}
|
body:{}
|
||||||
@res =
|
@res =
|
||||||
send: sinon.stub()
|
send: sinon.stub()
|
||||||
|
@ -154,6 +157,20 @@ describe "UserController", ->
|
||||||
done()
|
done()
|
||||||
@UserController.updateUserSettings @req, @res
|
@UserController.updateUserSettings @req, @res
|
||||||
|
|
||||||
|
it "should update the email on the session", (done)->
|
||||||
|
@req.body.email = @newEmail.toUpperCase()
|
||||||
|
@UserUpdater.changeEmailAddress.callsArgWith(2)
|
||||||
|
callcount = 0
|
||||||
|
@User.findById = (id, cb)=>
|
||||||
|
if ++callcount == 2
|
||||||
|
@user.email = @newEmail
|
||||||
|
cb(null, @user)
|
||||||
|
@res.sendStatus = (code)=>
|
||||||
|
code.should.equal 200
|
||||||
|
@req.session.user.email.should.equal @newEmail
|
||||||
|
done()
|
||||||
|
@UserController.updateUserSettings @req, @res
|
||||||
|
|
||||||
it "should call populateGroupLicenceInvite", (done)->
|
it "should call populateGroupLicenceInvite", (done)->
|
||||||
@req.body.email = @newEmail.toUpperCase()
|
@req.body.email = @newEmail.toUpperCase()
|
||||||
@UserUpdater.changeEmailAddress.callsArgWith(2)
|
@UserUpdater.changeEmailAddress.callsArgWith(2)
|
||||||
|
|
Loading…
Reference in a new issue