mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:13:46 -05:00
university site renders via prozy ok
This commit is contained in:
parent
8789a4bde1
commit
c2c29bb282
6 changed files with 63 additions and 1 deletions
|
@ -12,6 +12,8 @@ module.exports = BlogController =
|
|||
url = req.url?.toLowerCase()
|
||||
blogUrl = "#{settings.apis.blog.url}#{url}"
|
||||
|
||||
extensionsToProxy = [".png", ".xml", ".jpeg", ".json", ".zip", ".eps"]
|
||||
|
||||
shouldProxy = _.find extensionsToProxy, (extension)->
|
||||
url.indexOf(extension) != -1
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
extensionsToProxy = [".png", ".xml", ".jpeg", ".json", ".zip", ".eps", ".gif", ".jpg"]
|
||||
_ = require("underscore")
|
||||
|
||||
module.exports =
|
||||
shouldProxy: (url)->
|
||||
shouldProxy = _.find extensionsToProxy, (extension)->
|
||||
url.indexOf(extension) != -1
|
||||
return shouldProxy
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
HomeController = require('./HomeController')
|
||||
UniversityController = require("./UniversityController")
|
||||
|
||||
|
||||
module.exports =
|
||||
apply: (app) ->
|
||||
|
@ -12,4 +14,7 @@ module.exports =
|
|||
app.get '/planned_maintenance', HomeController.externalPage("planned_maintenance", "Planned Maintenance")
|
||||
app.get '/style', HomeController.externalPage("style_guide", "Style Guide")
|
||||
|
||||
app.get '/dropbox', HomeController.externalPage("dropbox", "Dropbox and ShareLaTeX")
|
||||
app.get '/dropbox', HomeController.externalPage("dropbox", "Dropbox and ShareLaTeX")
|
||||
|
||||
app.get '/university', UniversityController.getIndexPage
|
||||
app.get '/university/*', UniversityController.getPage
|
|
@ -0,0 +1,34 @@
|
|||
request = require("request")
|
||||
settings = require("settings-sharelatex")
|
||||
logger = require("logger-sharelatex")
|
||||
_ = require("underscore")
|
||||
ErrorController = require "../Errors/ErrorController"
|
||||
StaticPageHelpers = require("./StaticPageHelpers")
|
||||
|
||||
module.exports = UniversityController =
|
||||
|
||||
getPage: (req, res, next)->
|
||||
url = req.url?.toLowerCase()
|
||||
universityUrl = "#{settings.apis.university.url}#{url}"
|
||||
console.log universityUrl
|
||||
if StaticPageHelpers.shouldProxy(url)
|
||||
return UniversityController._directProxy universityUrl, res
|
||||
|
||||
logger.log url:url, "proxying request to university api"
|
||||
request.get universityUrl, (err, r, data)->
|
||||
if r?.statusCode == 404
|
||||
return ErrorController.notFound(req, res, next)
|
||||
data = data.trim()
|
||||
try
|
||||
data = JSON.parse(data)
|
||||
catch err
|
||||
logger.err err:err, data:data, "error parsing data from data"
|
||||
res.render "university/university_holder", data
|
||||
|
||||
|
||||
getIndexPage: (req, res)->
|
||||
req.url = "/university/index.html"
|
||||
UniversityController.getPage req, res
|
||||
|
||||
_directProxy: (originUrl, res)->
|
||||
request.get(originUrl).pipe res
|
6
services/web/app/views/university/university_holder.jade
Normal file
6
services/web/app/views/university/university_holder.jade
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends ../layout
|
||||
|
||||
block content
|
||||
.content.content-alt
|
||||
.blog
|
||||
| !{content}
|
|
@ -82,6 +82,8 @@ module.exports =
|
|||
internal_url: "http://localhost:3010"
|
||||
blog:
|
||||
port: 3008
|
||||
university:
|
||||
url: "http://localhost:3011"
|
||||
filestore:
|
||||
url: "http://localhost:3009"
|
||||
clsi:
|
||||
|
@ -92,6 +94,7 @@ module.exports =
|
|||
privateKey: ""
|
||||
apiKey: ""
|
||||
subdomain: ""
|
||||
|
||||
|
||||
templates:
|
||||
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"
|
||||
|
|
Loading…
Reference in a new issue