diff --git a/services/web/app/coffee/Features/Project/ProjectController.coffee b/services/web/app/coffee/Features/Project/ProjectController.coffee index 540e460953..5f242a93be 100644 --- a/services/web/app/coffee/Features/Project/ProjectController.coffee +++ b/services/web/app/coffee/Features/Project/ProjectController.coffee @@ -16,8 +16,6 @@ SecurityManager = require("../../managers/SecurityManager") fs = require "fs" InactiveProjectManager = require("../InactiveData/InactiveProjectManager") ProjectUpdateHandler = require("./ProjectUpdateHandler") -ReferencesSearchHandler = require("../ReferencesSearch/ReferencesSearchHandler") - module.exports = ProjectController = @@ -218,9 +216,6 @@ module.exports = ProjectController = if subscription? and subscription.freeTrial? and subscription.freeTrial.expiresAt? allowedFreeTrial = !!subscription.freeTrial.allowed || true - # HACK: don't do it for now - # ReferencesSearchHandler.indexProjectReferences project, -> # don't need to wait on this - logger.log project_id:project_id, "rendering editor page" res.render 'project/editor', title: project.name diff --git a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee b/services/web/app/coffee/Features/References/ReferencesController.coffee similarity index 73% rename from services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee rename to services/web/app/coffee/Features/References/ReferencesController.coffee index 96f06228c8..dd3603cc11 100644 --- a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee +++ b/services/web/app/coffee/Features/References/ReferencesController.coffee @@ -1,9 +1,9 @@ logger = require('logger-sharelatex') -ReferencesSearchHandler = require('./ReferencesSearchHandler') +ReferencesHandler = require('./ReferencesHandler') settings = require('settings-sharelatex') EditorRealTimeController = require("../Editor/EditorRealTimeController") -module.exports = ReferencesSearchController = +module.exports = ReferencesController = index: (req, res) -> @@ -14,21 +14,21 @@ module.exports = ReferencesSearchController = logger.err {projectId, docIds}, "docIds is not valid, should be either Array or String 'ALL'" return res.send 400 logger.log {projectId, docIds: docIds}, "index references for project" - ReferencesSearchHandler.index projectId, docIds, (err, data) -> + ReferencesHandler.index projectId, docIds, (err, data) -> if err logger.err {err, projectId}, "error indexing all references" return res.send 500 - ReferencesSearchController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) + ReferencesController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) indexAll: (req, res) -> projectId = req.params.Project_id shouldBroadcast = req.body.shouldBroadcast logger.log {projectId}, "index all references for project" - ReferencesSearchHandler.indexAll projectId, (err, data) -> + ReferencesHandler.indexAll projectId, (err, data) -> if err logger.err {err, projectId}, "error indexing all references" return res.send 500 - ReferencesSearchController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) + ReferencesController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) _handleIndexResponse: (req, res, projectId, shouldBroadcast, data) -> if shouldBroadcast diff --git a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchHandler.coffee b/services/web/app/coffee/Features/References/ReferencesHandler.coffee similarity index 86% rename from services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchHandler.coffee rename to services/web/app/coffee/Features/References/ReferencesHandler.coffee index 619d325389..0b2ddb1e26 100644 --- a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchHandler.coffee +++ b/services/web/app/coffee/Features/References/ReferencesHandler.coffee @@ -10,7 +10,7 @@ oneMinInMs = 60 * 1000 fiveMinsInMs = oneMinInMs * 5 -module.exports = ReferencesSearchHandler = +module.exports = ReferencesHandler = _buildDocUrl: (projectId, docId) -> "#{settings.apis.docstore.url}/project/#{projectId}/doc/#{docId}/raw" @@ -40,18 +40,18 @@ module.exports = ReferencesSearchHandler = logger.err {err, projectId}, "error finding project" return callback(err) logger.log {projectId}, "indexing all bib files in project" - docIds = ReferencesSearchHandler._findBibDocIds(project) - ReferencesSearchHandler._doIndexOperation(projectId, project, docIds, callback) + docIds = ReferencesHandler._findBibDocIds(project) + ReferencesHandler._doIndexOperation(projectId, project, docIds, callback) index: (projectId, docIds, callback=(err, data)->) -> Project.findPopulatedById projectId, (err, project) -> if err logger.err {err, projectId}, "error finding project" return callback(err) - ReferencesSearchHandler._doIndexOperation(projectId, project, docIds, callback) + ReferencesHandler._doIndexOperation(projectId, project, docIds, callback) _doIndexOperation: (projectId, project, docIds, callback) -> - ReferencesSearchHandler._isFullIndex project, (err, isFullIndex) -> + ReferencesHandler._isFullIndex project, (err, isFullIndex) -> if err logger.err {err, projectId}, "error checking whether to do full index" return callback(err) @@ -64,7 +64,7 @@ module.exports = ReferencesSearchHandler = logger.err {err, projectId, docIds}, "error flushing docs to mongo" return callback(err) bibDocUrls = docIds.map (docId) -> - ReferencesSearchHandler._buildDocUrl projectId, docId + ReferencesHandler._buildDocUrl projectId, docId logger.log {projectId, isFullIndex, docIds, bibDocUrls}, "sending request to references service" request.post { url: "#{settings.apis.references.url}/project/#{projectId}/index" diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 4fe9f2a247..6e50be69e5 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -37,7 +37,7 @@ RateLimiterMiddlewear = require('./Features/Security/RateLimiterMiddlewear') RealTimeProxyRouter = require('./Features/RealTimeProxy/RealTimeProxyRouter') InactiveProjectController = require("./Features/InactiveData/InactiveProjectController") ContactRouter = require("./Features/Contacts/ContactRouter") -ReferencesSearchController = require('./Features/ReferencesSearch/ReferencesSearchController') +ReferencesController = require('./Features/References/ReferencesController') logger = require("logger-sharelatex") _ = require("underscore") @@ -175,8 +175,8 @@ module.exports = class Router webRouter.get /learn(\/.*)?/, WikiController.getPage - webRouter.post "/project/:Project_id/references/index", SecurityManager.requestCanAccessProject, ReferencesSearchController.index - webRouter.post "/project/:Project_id/references/indexAll", SecurityManager.requestCanAccessProject, ReferencesSearchController.indexAll + webRouter.post "/project/:Project_id/references/index", SecurityManager.requestCanAccessProject, ReferencesController.index + webRouter.post "/project/:Project_id/references/indexAll", SecurityManager.requestCanAccessProject, ReferencesController.indexAll #Admin Stuff webRouter.get '/admin', SecurityManager.requestIsAdmin, AdminController.index diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 854646edfd..f086ae88f1 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -8,7 +8,7 @@ define [ "ide/permissions/PermissionsManager" "ide/pdf/PdfManager" "ide/binary-files/BinaryFilesManager" - "ide/references-search/ReferencesSearchManager" + "ide/references/ReferencesManager" "ide/settings/index" "ide/share/index" "ide/chat/index" @@ -38,7 +38,7 @@ define [ PermissionsManager PdfManager BinaryFilesManager - ReferencesSearchManager + ReferencesManager ) -> App.controller "IdeController", ($scope, $timeout, ide, localStorage) -> @@ -74,7 +74,7 @@ define [ ide.project_id = $scope.project_id = window.project_id ide.$scope = $scope - ide.referencesSearchManager = new ReferencesSearchManager(ide, $scope) + ide.referencesSearchManager = new ReferencesManager(ide, $scope) ide.connectionManager = new ConnectionManager(ide, $scope) ide.fileTreeManager = new FileTreeManager(ide, $scope) ide.editorManager = new EditorManager(ide, $scope) @@ -94,7 +94,7 @@ define [ We don't want to delete your data on ShareLaTeX, so this project still contains your history and collaborators. If the project has been renamed please look in your project list for a new project under the new name. """) - + DARK_THEMES = [ "ambiance", "chaos", "clouds_midnight", "cobalt", "idle_fingers", "merbivore", "merbivore_soft", "mono_industrial", "monokai", diff --git a/services/web/public/coffee/ide/references-search/ReferencesSearchManager.coffee b/services/web/public/coffee/ide/references/ReferencesManager.coffee similarity index 97% rename from services/web/public/coffee/ide/references-search/ReferencesSearchManager.coffee rename to services/web/public/coffee/ide/references/ReferencesManager.coffee index 726d3db89b..b0f49f54f8 100644 --- a/services/web/public/coffee/ide/references-search/ReferencesSearchManager.coffee +++ b/services/web/public/coffee/ide/references/ReferencesManager.coffee @@ -1,6 +1,6 @@ define [ ], () -> - class ReferencesSearchManager + class ReferencesManager constructor: (@ide, @$scope) -> @$scope.$root._references = @state = keys: [] diff --git a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee b/services/web/test/UnitTests/coffee/References/ReferencesControllerTests.coffee similarity index 78% rename from services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee rename to services/web/test/UnitTests/coffee/References/ReferencesControllerTests.coffee index 9b12648520..b73bf3ba1d 100644 --- a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/References/ReferencesControllerTests.coffee @@ -2,11 +2,11 @@ SandboxedModule = require('sandboxed-module') should = require('chai').should() sinon = require 'sinon' assert = require("chai").assert -modulePath = "../../../../app/js/Features/ReferencesSearch/ReferencesSearchController" +modulePath = "../../../../app/js/Features/References/ReferencesController" MockRequest = require "../helpers/MockRequest" MockResponse = require "../helpers/MockResponse" -describe "ReferencesSearchController", -> +describe "ReferencesController", -> beforeEach -> @projectId = '2222' @@ -18,7 +18,7 @@ describe "ReferencesSearchController", -> 'settings-sharelatex': @settings = { apis: {web: {url: 'http://some.url'}} }, - './ReferencesSearchHandler': @ReferencesSearchHandler = { + './ReferencesHandler': @ReferencesHandler = { index: sinon.stub() indexAll: sinon.stub() }, @@ -41,7 +41,7 @@ describe "ReferencesSearchController", -> beforeEach -> @req.body = {shouldBroadcast: false} - @ReferencesSearchHandler.indexAll.callsArgWith(1, null, @fakeResponseData) + @ReferencesHandler.indexAll.callsArgWith(1, null, @fakeResponseData) @call = (callback) => @controller.indexAll @req, @res callback() @@ -59,16 +59,16 @@ describe "ReferencesSearchController", -> @res.json.calledWith(@fakeResponseData).should.equal true done() - it 'should call ReferencesSearchHandler.indexAll', (done) -> + it 'should call ReferencesHandler.indexAll', (done) -> @call () => - @ReferencesSearchHandler.indexAll.callCount.should.equal 1 - @ReferencesSearchHandler.indexAll.calledWith(@projectId).should.equal true + @ReferencesHandler.indexAll.callCount.should.equal 1 + @ReferencesHandler.indexAll.calledWith(@projectId).should.equal true done() describe 'when shouldBroadcast is true', -> beforeEach -> - @ReferencesSearchHandler.index.callsArgWith(2, null, @fakeResponseData) + @ReferencesHandler.index.callsArgWith(2, null, @fakeResponseData) @req.body.shouldBroadcast = true it 'should call EditorRealTimeController.emitToRoom', (done) -> @@ -92,7 +92,7 @@ describe "ReferencesSearchController", -> describe 'when shouldBroadcast is false', -> beforeEach -> - @ReferencesSearchHandler.index.callsArgWith(2, null, @fakeResponseData) + @ReferencesHandler.index.callsArgWith(2, null, @fakeResponseData) @req.body.shouldBroadcast = false it 'should not call EditorRealTimeController.emitToRoom', (done) -> @@ -119,15 +119,15 @@ describe "ReferencesSearchController", -> describe 'with docIds as an array and shouldBroadcast as false', -> beforeEach -> - @ReferencesSearchHandler.index.callsArgWith(2, null, @fakeResponseData) + @ReferencesHandler.index.callsArgWith(2, null, @fakeResponseData) @call = (callback) => @controller.index @req, @res callback() - it 'should call ReferencesSearchHandler.index', (done) -> + it 'should call ReferencesHandler.index', (done) -> @call () => - @ReferencesSearchHandler.index.callCount.should.equal 1 - @ReferencesSearchHandler.index.calledWith(@projectId, @docIds).should.equal true + @ReferencesHandler.index.callCount.should.equal 1 + @ReferencesHandler.index.calledWith(@projectId, @docIds).should.equal true done() it 'should return data', (done) -> @@ -148,10 +148,10 @@ describe "ReferencesSearchController", -> @EditorRealTimeController.emitToRoom.callCount.should.equal 0 done() - describe 'when ReferencesSearchHandler.index produces an error', -> + describe 'when ReferencesHandler.index produces an error', -> beforeEach -> - @ReferencesSearchHandler.index.callsArgWith(2, new Error('woops'), null) + @ReferencesHandler.index.callsArgWith(2, new Error('woops'), null) it 'should produce an error response', (done) -> @call () => @@ -162,7 +162,7 @@ describe "ReferencesSearchController", -> describe 'when shouldBroadcast is true', -> beforeEach -> - @ReferencesSearchHandler.index.callsArgWith(2, null, @fakeResponseData) + @ReferencesHandler.index.callsArgWith(2, null, @fakeResponseData) @req.body.shouldBroadcast = true it 'should call EditorRealTimeController.emitToRoom', (done) -> @@ -194,9 +194,9 @@ describe "ReferencesSearchController", -> @res.send.calledWith(400).should.equal true done() - it 'should not call ReferencesSearchHandler.index', (done) -> + it 'should not call ReferencesHandler.index', (done) -> @call () => - @ReferencesSearchHandler.index.callCount.should.equal 0 + @ReferencesHandler.index.callCount.should.equal 0 done() describe 'with invalid docIds', -> @@ -210,7 +210,7 @@ describe "ReferencesSearchController", -> @res.send.calledWith(400).should.equal true done() - it 'should not call ReferencesSearchHandler.index', (done) -> + it 'should not call ReferencesHandler.index', (done) -> @call () => - @ReferencesSearchHandler.index.callCount.should.equal 0 + @ReferencesHandler.index.callCount.should.equal 0 done() diff --git a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchHandlerTests.coffee b/services/web/test/UnitTests/coffee/References/ReferencesHandlerTests.coffee similarity index 98% rename from services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchHandlerTests.coffee rename to services/web/test/UnitTests/coffee/References/ReferencesHandlerTests.coffee index bb1b2c22ea..86cf9111dc 100644 --- a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/References/ReferencesHandlerTests.coffee @@ -3,9 +3,9 @@ should = require('chai').should() expect = require('chai').expect sinon = require 'sinon' assert = require("chai").assert -modulePath = "../../../../app/js/Features/ReferencesSearch/ReferencesSearchHandler" +modulePath = "../../../../app/js/Features/References/ReferencesHandler" -describe 'ReferencesSearchHandler', -> +describe 'ReferencesHandler', -> beforeEach -> @projectId = '222'