diff --git a/services/web/app/coffee/Features/Docstore/DocstoreManager.coffee b/services/web/app/coffee/Features/Docstore/DocstoreManager.coffee index a755c47422..772d927d78 100644 --- a/services/web/app/coffee/Features/Docstore/DocstoreManager.coffee +++ b/services/web/app/coffee/Features/Docstore/DocstoreManager.coffee @@ -30,7 +30,7 @@ module.exports = DocstoreManager = logger.error err: error, project_id: project_id, "error getting all docs from docstore" callback(error) - getDoc: (project_id, doc_id, options = {}, callback = (error, lines, rev) ->) -> + getDoc: (project_id, doc_id, options = {}, callback = (error, lines, rev, version) ->) -> if typeof(options) == "function" callback = options options = {} @@ -45,19 +45,20 @@ module.exports = DocstoreManager = return callback(error) if error? if 200 <= res.statusCode < 300 logger.log doc_id: doc_id, project_id: project_id, version: doc.version, rev: doc.rev, "got doc from docstore api" - callback(null, doc.lines, doc.rev) + callback(null, doc.lines, doc.rev, doc.version) else error = new Error("docstore api responded with non-success code: #{res.statusCode}") logger.error err: error, project_id: project_id, doc_id: doc_id, "error getting doc from docstore" callback(error) - updateDoc: (project_id, doc_id, lines, callback = (error, modified, rev) ->) -> + updateDoc: (project_id, doc_id, lines, version, callback = (error, modified, rev) ->) -> logger.log project_id: project_id, doc_id: doc_id, "updating doc in docstore api" url = "#{settings.apis.docstore.url}/project/#{project_id}/doc/#{doc_id}" request.post { url: url json: lines: lines + version: version }, (error, res, result) -> return callback(error) if error? if 200 <= res.statusCode < 300 diff --git a/services/web/app/coffee/Features/Documents/DocumentController.coffee b/services/web/app/coffee/Features/Documents/DocumentController.coffee index ba74fc47da..560f232ba1 100644 --- a/services/web/app/coffee/Features/Documents/DocumentController.coffee +++ b/services/web/app/coffee/Features/Documents/DocumentController.coffee @@ -7,7 +7,7 @@ module.exports = doc_id = req.params.doc_id plain = req?.query?.plain == 'true' logger.log doc_id:doc_id, project_id:project_id, "receiving get document request from api (docupdater)" - ProjectEntityHandler.getDoc project_id, doc_id, (error, lines, rev) -> + ProjectEntityHandler.getDoc project_id, doc_id, (error, lines, rev, version) -> if error? logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument" return next(error) @@ -18,14 +18,15 @@ module.exports = res.type "json" res.send JSON.stringify { lines: lines + version: version } setDocument: (req, res, next = (error) ->) -> project_id = req.params.Project_id doc_id = req.params.doc_id - lines = req.body.lines + {lines, version} = req.body logger.log doc_id:doc_id, project_id:project_id, "receiving set document request from api (docupdater)" - ProjectEntityHandler.updateDocLines project_id, doc_id, lines, (error) -> + ProjectEntityHandler.updateDocLines project_id, doc_id, lines, version, (error) -> if error? logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument" return next(error) diff --git a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee index ca783a2cbf..21932cefc9 100644 --- a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee @@ -126,7 +126,7 @@ module.exports = ProjectEntityHandler = doc = new Doc name: docName # Put doc in docstore first, so that if it errors, we don't have a doc_id in the project # which hasn't been created in docstore. - DocstoreManager.updateDoc project_id.toString(), doc._id.toString(), docLines, (err, modified, rev) -> + DocstoreManager.updateDoc project_id.toString(), doc._id.toString(), docLines, 0, (err, modified, rev) -> return callback(err) if err? ProjectEntityHandler._putElement project, folder_id, doc, "doc", (err, result)=> @@ -292,7 +292,7 @@ module.exports = ProjectEntityHandler = return callback(err) callback(err, folder, parentFolder_id) - updateDocLines : (project_id, doc_id, lines, callback = (error) ->)-> + updateDocLines : (project_id, doc_id, lines, version, callback = (error) ->)-> ProjectGetter.getProjectWithoutDocLines project_id, (err, project)-> return callback(err) if err? return callback(new Errors.NotFoundError("project not found")) if !project? @@ -307,7 +307,7 @@ module.exports = ProjectEntityHandler = return callback(error) logger.log project_id: project_id, doc_id: doc_id, "telling docstore manager to update doc" - DocstoreManager.updateDoc project_id, doc_id, lines, (err, modified, rev) -> + DocstoreManager.updateDoc project_id, doc_id, lines, version, (err, modified, rev) -> if err? logger.error err: err, doc_id: doc_id, project_id:project_id, lines: lines, "error sending doc to docstore" return callback(err) diff --git a/services/web/app/coffee/infrastructure/Server.coffee b/services/web/app/coffee/infrastructure/Server.coffee index 6ee9390b93..43683bdd4e 100644 --- a/services/web/app/coffee/infrastructure/Server.coffee +++ b/services/web/app/coffee/infrastructure/Server.coffee @@ -90,6 +90,7 @@ webRouter.use session secure: Settings.secureCookie store: sessionStore key: Settings.cookieName + rolling: true # passport webRouter.use passport.initialize() diff --git a/services/web/app/views/layout/navbar.jade b/services/web/app/views/layout/navbar.jade index e0a89fdea7..3cd6587592 100644 --- a/services/web/app/views/layout/navbar.jade +++ b/services/web/app/views/layout/navbar.jade @@ -35,6 +35,9 @@ nav.navbar.navbar-default each child in item.dropdown if child.divider li.divider + else if child.user_email + li + div.subdued #{getUserEmail()} else li if child.url diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index 1e858253e4..e3b842a0d2 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -347,6 +347,10 @@ module.exports = settings = text: "Account" only_when_logged_in: true dropdown: [{ + user_email: true + },{ + divider: true + }, { text: "Account Settings" url: "/user/settings" }, { diff --git a/services/web/public/img/spellcheck-underline.png b/services/web/public/img/spellcheck-underline.png index 07d7c5ce0e..0b3b38904a 100644 Binary files a/services/web/public/img/spellcheck-underline.png and b/services/web/public/img/spellcheck-underline.png differ diff --git a/services/web/public/img/spellcheck-underline@2x.png b/services/web/public/img/spellcheck-underline@2x.png new file mode 100644 index 0000000000..4212e3b66c Binary files /dev/null and b/services/web/public/img/spellcheck-underline@2x.png differ diff --git a/services/web/public/stylesheets/app/editor.less b/services/web/public/stylesheets/app/editor.less index 885ed20f89..250269a7a2 100644 --- a/services/web/public/stylesheets/app/editor.less +++ b/services/web/public/stylesheets/app/editor.less @@ -138,6 +138,10 @@ .spelling-highlight { position: absolute; background-image: url(/img/spellcheck-underline.png); + @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { + background-image: url(/img/spellcheck-underline@2x.png); + background-size: 5px 4px; + } background-repeat: repeat-x; background-position: bottom left; } diff --git a/services/web/public/stylesheets/components/dropdowns.less b/services/web/public/stylesheets/components/dropdowns.less index 2b718026a1..7adbfe49d7 100755 --- a/services/web/public/stylesheets/components/dropdowns.less +++ b/services/web/public/stylesheets/components/dropdowns.less @@ -58,8 +58,8 @@ .nav-divider(@dropdown-divider-bg); } - // Links within the dropdown menu - > li > a { + // Links and other items within the dropdown menu + > li > a,div { display: block; padding: 3px 20px; clear: both; @@ -67,8 +67,11 @@ line-height: @line-height-base; color: @dropdown-link-color; white-space: nowrap; // prevent links from randomly breaking onto new lines + &.subdued { + color: #7a7a7a + } .subdued { - color: #7a7a7a + color: #7a7a7a } } } diff --git a/services/web/test/UnitTests/coffee/Docstore/DocstoreManagerTests.coffee b/services/web/test/UnitTests/coffee/Docstore/DocstoreManagerTests.coffee index f32d48fdc1..e288c46aea 100644 --- a/services/web/test/UnitTests/coffee/Docstore/DocstoreManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Docstore/DocstoreManagerTests.coffee @@ -56,12 +56,13 @@ describe "DocstoreManager", -> beforeEach -> @lines = ["mock", "doc", "lines"] @rev = 5 + @version = 42 @modified = true describe "with a successful response code", -> beforeEach -> @request.post = sinon.stub().callsArgWith(1, null, statusCode: 204, { modified: @modified, rev: @rev }) - @DocstoreManager.updateDoc @project_id, @doc_id, @lines, @callback + @DocstoreManager.updateDoc @project_id, @doc_id, @lines, @version, @callback it "should update the doc in the docstore api", -> @request.post @@ -69,6 +70,7 @@ describe "DocstoreManager", -> url: "#{@settings.apis.docstore.url}/project/#{@project_id}/doc/#{@doc_id}" json: lines: @lines + version: @version }) .should.equal true @@ -78,7 +80,7 @@ describe "DocstoreManager", -> describe "with a failed response code", -> beforeEach -> @request.post = sinon.stub().callsArgWith(1, null, statusCode: 500, "") - @DocstoreManager.updateDoc @project_id, @doc_id, @lines, @callback + @DocstoreManager.updateDoc @project_id, @doc_id, @lines, @version, @callback it "should call the callback with an error", -> @callback.calledWith(new Error("docstore api responded with non-success code: 500")).should.equal true @@ -97,6 +99,7 @@ describe "DocstoreManager", -> @doc = lines: @lines = ["mock", "doc", "lines"] rev: @rev = 5 + version: @version = 42 describe "with a successful response code", -> beforeEach -> @@ -112,7 +115,7 @@ describe "DocstoreManager", -> .should.equal true it "should call the callback with the lines, version and rev", -> - @callback.calledWith(null, @lines, @rev).should.equal true + @callback.calledWith(null, @lines, @rev, @version).should.equal true describe "with a failed response code", -> beforeEach -> @@ -145,7 +148,7 @@ describe "DocstoreManager", -> .should.equal true it "should call the callback with the lines, version and rev", -> - @callback.calledWith(null, @lines, @rev).should.equal true + @callback.calledWith(null, @lines, @rev, @version).should.equal true describe "getAllDocs", -> describe "with a successful response code", -> diff --git a/services/web/test/UnitTests/coffee/Documents/DocumentControllerTests.coffee b/services/web/test/UnitTests/coffee/Documents/DocumentControllerTests.coffee index 1a7e2fb500..a554319baa 100644 --- a/services/web/test/UnitTests/coffee/Documents/DocumentControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Documents/DocumentControllerTests.coffee @@ -33,7 +33,7 @@ describe "DocumentController", -> describe "when the document exists", -> beforeEach -> - @ProjectEntityHandler.getDoc = sinon.stub().callsArgWith(2, null, @doc_lines, @rev) + @ProjectEntityHandler.getDoc = sinon.stub().callsArgWith(2, null, @doc_lines, @rev, @version) @DocumentController.getDocument(@req, @res, @next) it "should get the document from Mongo", -> @@ -45,6 +45,7 @@ describe "DocumentController", -> @res.type.should.equal "json" @res.body.should.equal JSON.stringify lines: @doc_lines + version: @version describe "when the document doesn't exist", -> beforeEach -> @@ -63,14 +64,15 @@ describe "DocumentController", -> describe "when the document exists", -> beforeEach -> - @ProjectEntityHandler.updateDocLines = sinon.stub().callsArg(3) + @ProjectEntityHandler.updateDocLines = sinon.stub().yields() @req.body = lines: @doc_lines + version: @version @DocumentController.setDocument(@req, @res, @next) it "should update the document in Mongo", -> @ProjectEntityHandler.updateDocLines - .calledWith(@project_id, @doc_id, @doc_lines) + .calledWith(@project_id, @doc_id, @doc_lines, @version) .should.equal true it "should return a successful response", -> @@ -78,7 +80,7 @@ describe "DocumentController", -> describe "when the document doesn't exist", -> beforeEach -> - @ProjectEntityHandler.updateDocLines = sinon.stub().callsArgWith(3, new Errors.NotFoundError("document does not exist")) + @ProjectEntityHandler.updateDocLines = sinon.stub().yields(new Errors.NotFoundError("document does not exist")) @req.body = lines: @doc_lines @DocumentController.setDocument(@req, @res, @next) diff --git a/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee index e946850828..5a0c860ab2 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee @@ -402,7 +402,7 @@ describe 'ProjectEntityHandler', -> @ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:@path}}) @callback = sinon.stub() @tpdsUpdateSender.addDoc = sinon.stub().callsArg(1) - @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, true, 0) + @DocstoreManager.updateDoc = sinon.stub().yields(null, true, 0) @ProjectEntityHandler.addDoc project_id, folder_id, @name, @lines, @callback @@ -589,6 +589,7 @@ describe 'ProjectEntityHandler', -> @doc = { _id: doc_id } + @version = 42 @ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, @project) @projectLocator.findElement = sinon.stub().callsArgWith(1, null, @doc, {fileSystem: @path}) @tpdsUpdateSender.addDoc = sinon.stub().callsArg(1) @@ -597,8 +598,8 @@ describe 'ProjectEntityHandler', -> describe "when the doc has been modified", -> beforeEach -> - @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, true, @rev = 5) - @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback + @DocstoreManager.updateDoc = sinon.stub().yields(null, true, @rev = 5) + @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback it "should get the project without doc lines", -> @ProjectGetter.getProjectWithoutDocLines @@ -616,7 +617,7 @@ describe 'ProjectEntityHandler', -> it "should update the doc in the docstore", -> @DocstoreManager.updateDoc - .calledWith(project_id, doc_id, @lines) + .calledWith(project_id, doc_id, @lines, @version) .should.equal true it "should mark the project as updated", -> @@ -640,8 +641,8 @@ describe 'ProjectEntityHandler', -> describe "when the doc has not been modified", -> beforeEach -> - @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, false, @rev = 5) - @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback + @DocstoreManager.updateDoc = sinon.stub().yields(null, false, @rev = 5) + @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback it "should not mark the project as updated", -> @projectUpdater.markAsUpdated.called.should.equal false @@ -655,7 +656,7 @@ describe 'ProjectEntityHandler', -> describe "when the project is not found", -> beforeEach -> @ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, null) - @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback + @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback it "should return a not found error", -> @callback.calledWith(new Errors.NotFoundError()).should.equal true @@ -663,7 +664,7 @@ describe 'ProjectEntityHandler', -> describe "when the doc is not found", -> beforeEach -> @projectLocator.findElement = sinon.stub().callsArgWith(1, null, null, null) - @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback + @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback it "should log out the error", -> @logger.error