Sfoglia il codice sorgente

Merge branch 'master' of github.com:sharelatex/web-sharelatex

Henry Oswald 12 anni fa
parent
commit
4b11790a54

+ 16 - 0
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)

+ 4 - 0
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

+ 7 - 6
services/web/app/views/project/list.jade

@@ -58,14 +58,15 @@ block content
 
 
 	.content-with-navigation-sidebar
-		.row-fluid
-			.span12
-				.alert.alert-info
-					p Due to issues with our database project changed oon the 12th of April may have been rolled back 24 hours or lost. If you have expreneced this please <strong> a<href="mailto:team@sharelatex.com"> Get In Touch Here </a></strong> and we will restore any lost work from our backup system. 
-					p We are very sorry about this. More details on what happened will follow soon.
-
 		.box#projectListArea
 						
+			.row-fluid
+				.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 any or your projects are missing, or have been rolled-back to a previous version, then you can <strong> <a href="/restore">restore them from our latest back ups</a></strong>.
+						p We are very sorry about this. More details on what happened will follow as soon as possible.
+
 			.row-fluid
 				.span12
 					.page-header

+ 29 - 0
services/web/app/views/restore.jade

@@ -0,0 +1,29 @@
+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 latest version as Zip
+
+		include general/small-footer