diff --git a/services/web/app/coffee/Features/Restore/RestoreController.coffee b/services/web/app/coffee/Features/Restore/RestoreController.coffee new file mode 100644 index 0000000000..9ff9f3ee4b --- /dev/null +++ b/services/web/app/coffee/Features/Restore/RestoreController.coffee @@ -0,0 +1,16 @@ +Settings = require "settings-sharelatex" +mongojs = require "mongojs" +db = mongojs.connect(Settings.mongo.restoreUrl, ["projects", "users"]) +ObjectId = mongojs.ObjectId +VersioningApiHandler = require "../Versioning/VersioningApiHandler" + +module.exports = RestoreController = + restore: (req, res, next = (error) ->) -> + user_id = req.session.user._id + db.projects.find { owner_ref: ObjectId(user_id) }, { _id: 1, name: 1 }, (error, projects) -> + return next(error) if error? + res.render 'restore', projects: projects, title: "Restore projects" + + getZip: (req, res, next = (error) ->) -> + project_id = req.params.Project_id + VersioningApiHandler.proxyToVersioningApi(req, res) \ No newline at end of file diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index ad61b4ce94..0a158afd3c 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -33,6 +33,7 @@ ProjectDownloadsController = require "./Features/Downloads/ProjectDownloadsContr FileStoreController = require("./Features/FileStore/FileStoreController") TrackChangesController = require("./Features/TrackChanges/TrackChangesController") DropboxUserController = require("./Features/Dropbox/DropboxUserController") +RestoreController = require("./Features/Restore/RestoreController") logger = require("logger-sharelatex") _ = require("underscore") @@ -82,6 +83,9 @@ module.exports = class Router app.del '/user/newsletter/unsubscribe', AuthenticationController.requireLogin(), UserController.unsubscribe app.del '/user', AuthenticationController.requireLogin(), UserController.deleteUser + app.get "/restore", AuthenticationController.requireLogin(), RestoreController.restore + app.get "/project/:Project_id/zip", SecurityManager.requestCanAccessProject, RestoreController.getZip + app.get '/dropbox/beginAuth', DropboxUserController.redirectUserToDropboxAuth app.get '/dropbox/completeRegistration', DropboxUserController.completeDropboxRegistration app.get '/dropbox/unlink', DropboxUserController.unlinkDropbox diff --git a/services/web/app/views/project/list.jade b/services/web/app/views/project/list.jade index 6bbc24e500..9c88abbba9 100644 --- a/services/web/app/views/project/list.jade +++ b/services/web/app/views/project/list.jade @@ -64,7 +64,7 @@ block content .span12 .alert.alert-info p Due to unforeseen issues with our database, some projects which were changed or created on the 12th of April may have been rolled back 24 hours to Saturday morning (6am UTC on 12th April). - p If you have experienced this please Get In Touch (with the project URL if possible) and we will restore any lost work from our backup system. + p If any or your projects are missing, or have been rolled-back to a previous version, then you can restore them from our latest back ups. p We are very sorry about this. More details on what happened will follow as soon as possible. .row-fluid diff --git a/services/web/app/views/restore.jade b/services/web/app/views/restore.jade new file mode 100644 index 0000000000..497a9fc8c3 --- /dev/null +++ b/services/web/app/views/restore.jade @@ -0,0 +1,31 @@ +extends layout + +block content + .content + .row + .span10.offset1 + .box + .row-fluid + .span12 + .page-header + h1 Recover projects + + .row-fluid + .span12 + .well + p If any of your projects are missing, or are not showing the most recent updates, you + | can recover from our latest back ups here. If you have any problems, please get in + | touch (team@sharelatex.com). + + .row-fluid + table.table + -each project in projects + tr + - project_id = project._id.toString() + td(width="50%") #{project.name} + td(width="25%") + a.btn(href="/project/#{project_id}/zip") Download as Zip + td(width="25%") + a.btn.btn-primary(href="/project/new/template?zipUrl=/project/#{project_id}/zip&templateName=#{project.name}_(Restored)") Restore to ShareLaTeX + + include general/small-footer