mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
made project page load faaaaaaster
This commit is contained in:
parent
88ba45b9dc
commit
c0780f5a67
1 changed files with 81 additions and 73 deletions
|
@ -75,51 +75,46 @@ module.exports =
|
|||
timer.done()
|
||||
|
||||
|
||||
|
||||
loadEditor: (req, res)->
|
||||
timer = new metrics.Timer("load-editor")
|
||||
if !Settings.editorIsOpen
|
||||
res.render("general/closed", {title:"updating site"})
|
||||
else
|
||||
if req.session.user?
|
||||
user_id = req.session.user._id
|
||||
else
|
||||
user_id = 'openUser'
|
||||
return res.render("general/closed", {title:"updating site"})
|
||||
|
||||
user_id = if req.session.user? then req.session.user._id else 'openUser'
|
||||
project_id = req.params.Project_id
|
||||
Project.findPopulatedById project_id, (err, project)->
|
||||
User.findById user_id, (err, user)->
|
||||
|
||||
async.parallel {
|
||||
project: (cb)->
|
||||
Project.findPopulatedById project_id, cb
|
||||
user: (cb)->
|
||||
User.findById user_id, cb
|
||||
subscription: (cb)->
|
||||
SubscriptionLocator.getUsersSubscription user_id, cb
|
||||
}, (err, results)->
|
||||
if err?
|
||||
return res.send 500
|
||||
project = results.project
|
||||
user = results.user
|
||||
subscription = results.subscription
|
||||
|
||||
if user_id == 'openUser'
|
||||
anonymous = true
|
||||
user =
|
||||
id : user_id
|
||||
ace:
|
||||
mode:'none'
|
||||
theme:'textmate'
|
||||
fontSize: '12'
|
||||
autoComplete: true
|
||||
spellCheckLanguage: ""
|
||||
pdfViewer: ""
|
||||
subscription:
|
||||
freeTrial:
|
||||
allowed: true
|
||||
featureSwitches:
|
||||
dropbox: false
|
||||
trackChanges: false
|
||||
user = defaultSettingsForAnonymousUser(user_id)
|
||||
else
|
||||
anonymous = false
|
||||
SubscriptionLocator.getUsersSubscription user?._id, (err, subscription)->
|
||||
|
||||
SecurityManager.userCanAccessProject user, project, (canAccess, privilegeLevel)->
|
||||
allowedFreeTrial = true
|
||||
if !canAccess
|
||||
return res.send 401
|
||||
|
||||
if subscription? and subscription.freeTrial? and subscription.freeTrial.expiresAt?
|
||||
allowedFreeTrial = !!subscription.freeTrial.allowed
|
||||
if canAccess
|
||||
timer.done()
|
||||
allowedFreeTrial = !!subscription.freeTrial.allowed || true
|
||||
|
||||
res.render 'project/editor',
|
||||
title: project.name
|
||||
priority_title: true
|
||||
bodyClasses: ["editor"]
|
||||
project : project
|
||||
#owner : project.owner_ref
|
||||
userObject : JSON.stringify({
|
||||
id : user.id
|
||||
email : user.email
|
||||
|
@ -149,11 +144,24 @@ module.exports =
|
|||
chatUrl: Settings.apis.chat.url
|
||||
anonymous: anonymous
|
||||
languages: Settings.languages
|
||||
else
|
||||
res.send 401
|
||||
|
||||
timer.done()
|
||||
|
||||
|
||||
defaultSettingsForAnonymousUser = ->
|
||||
id : user_id
|
||||
ace:
|
||||
mode:'none'
|
||||
theme:'textmate'
|
||||
fontSize: '12'
|
||||
autoComplete: true
|
||||
spellCheckLanguage: ""
|
||||
pdfViewer: ""
|
||||
subscription:
|
||||
freeTrial:
|
||||
allowed: true
|
||||
featureSwitches:
|
||||
dropbox: false
|
||||
trackChanges: false
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue