2014-02-12 05:23:40 -05:00
|
|
|
logger = require('logger-sharelatex')
|
|
|
|
_ = require('underscore')
|
|
|
|
|
2014-04-03 06:43:04 -04:00
|
|
|
Path = require "path"
|
|
|
|
fs = require "fs"
|
2014-04-07 05:55:07 -04:00
|
|
|
|
2014-06-20 12:17:24 -04:00
|
|
|
ErrorController = require "../Errors/ErrorController"
|
|
|
|
|
2014-04-07 05:55:07 -04:00
|
|
|
homepageExists = fs.existsSync Path.resolve(__dirname + "/../../../views/external/home.jade")
|
2014-02-12 05:23:40 -05:00
|
|
|
|
2014-04-03 06:43:04 -04:00
|
|
|
module.exports = HomeController =
|
2014-02-12 05:23:40 -05:00
|
|
|
index : (req,res)->
|
|
|
|
if req.session.user
|
|
|
|
if req.query.scribtex_path?
|
|
|
|
res.redirect "/project?scribtex_path=#{req.query.scribtex_path}"
|
|
|
|
else
|
|
|
|
res.redirect '/project'
|
|
|
|
else
|
2014-04-03 06:43:04 -04:00
|
|
|
if homepageExists
|
|
|
|
res.render 'external/home',
|
|
|
|
title: 'ShareLaTeX.com'
|
|
|
|
else
|
|
|
|
res.redirect "/login"
|
|
|
|
|
2014-07-28 12:04:17 -04:00
|
|
|
home: (req, res)->
|
|
|
|
if homepageExists
|
|
|
|
res.render 'external/home',
|
|
|
|
title: 'ShareLaTeX.com'
|
|
|
|
else
|
|
|
|
res.redirect "/login"
|
|
|
|
|
|
|
|
|
2014-04-03 06:43:04 -04:00
|
|
|
externalPage: (page, title) ->
|
|
|
|
return (req, res, next = (error) ->) ->
|
2014-04-07 05:55:07 -04:00
|
|
|
path = Path.resolve(__dirname + "/../../../views/external/#{page}.jade")
|
2014-04-03 06:43:04 -04:00
|
|
|
fs.exists path, (exists) -> # No error in this callback - old method in Node.js!
|
|
|
|
if exists
|
|
|
|
res.render "external/#{page}.jade",
|
|
|
|
title: title
|
|
|
|
else
|
2014-06-20 12:17:24 -04:00
|
|
|
ErrorController.notFound(req, res, next)
|