Commit 7ec94fab authored by Robert Knight's avatar Robert Knight

Separate out sidebar, annotation layer/bootstrap, and shared code into separate directories

Separate out the code for:

 - The sidebar application (now in src/sidebar)
 - The annotation layer and client bootstrap (now in src/annotator)
 - Code shared between the two (now in src/shared)
parent 376decb0
......@@ -94,15 +94,15 @@ var appBundleBaseConfig = {
};
var appBundles = [{
// The sidebar application for displaying and editing annotations
// The sidebar application for displaying and editing annotations.
name: 'app',
transforms: ['coffee'],
entry: './src/scripts/app',
entry: './src/sidebar/app',
},{
// The Annotator library which provides annotation controls on
// the page and sets up the sidebar
// The annotation layer which handles displaying highlights, presenting
// annotation tools on the page and instantiating the sidebar application.
name: 'injector',
entry: './src/scripts/annotator/main',
entry: './src/annotator/main',
transforms: ['coffee'],
}];
......@@ -305,11 +305,11 @@ function runKarma(baseConfig, opts, done) {
}
gulp.task('test', function (callback) {
runKarma('./src/scripts/karma.config.js', {singleRun:true}, callback);
runKarma('./src/karma.config.js', {singleRun:true}, callback);
});
gulp.task('test-watch', function (callback) {
runKarma('./src/scripts/karma.config.js', {}, callback);
runKarma('./src/karma.config.js', {}, callback);
});
gulp.task('upload-sourcemaps', ['build-js'], function () {
......
......@@ -117,9 +117,9 @@
]
},
"browser": {
"annotator": "./src/scripts/vendor/annotator.js",
"annotator": "./src/annotator/vendor/annotator.js",
"hammerjs": "./node_modules/hammerjs/hammer.js",
"katex": "./src/scripts/vendor/katex.js"
"katex": "./src/sidebar/vendor/katex.js"
},
"browserify-shim": {
"annotator": {
......
......@@ -9,7 +9,7 @@
module.exports = {
bundles: {
jquery: ['jquery'],
polyfills: [require.resolve('../../src/scripts/polyfills')],
polyfills: [require.resolve('../../src/shared/polyfills')],
angular: [
'angular',
'angular-jwt',
......
......@@ -2,8 +2,8 @@
var html = require('../html');
var toResult = require('../../../test/promise-util').toResult;
var unroll = require('../../../test/util').unroll;
var toResult = require('../../../shared/test/promise-util').toResult;
var unroll = require('../../../shared/test/util').unroll;
var fixture = require('./html-anchoring-fixture.html');
/** Return all text node children of `container`. */
......
'use strict';
var annotationIDs = require('../util/annotation-ids');
var settings = require('../settings');
var annotationIDs = require('./util/annotation-ids');
var settings = require('../shared/settings');
var docs = 'https://h.readthedocs.io/en/latest/embedding.html';
......
'use strict';
require('../polyfills');
require('../shared/polyfills');
var Annotator = require('annotator');
// Polyfills
// document.evaluate() implementation,
// required by IE 10, 11
//
// This sets `window.wgxpath`
if (!window.document.evaluate) {
require('./vendor/wgxpath.install');
}
var g = Annotator.Util.getGlobal();
if (g.wgxpath) {
g.wgxpath.install();
......@@ -22,13 +30,13 @@ Annotator.Plugin.Toolbar = require('./plugin/toolbar');
// Document type plugins
Annotator.Plugin.PDF = require('./plugin/pdf');
require('../vendor/annotator.document'); // Does not export the plugin :(
require('./vendor/annotator.document'); // Does not export the plugin :(
// Cross-frame communication
Annotator.Plugin.CrossFrame = require('./plugin/cross-frame');
Annotator.Plugin.CrossFrame.AnnotationSync = require('./annotation-sync');
Annotator.Plugin.CrossFrame.Bridge = require('../bridge');
Annotator.Plugin.CrossFrame.Discovery = require('../discovery');
Annotator.Plugin.CrossFrame.Bridge = require('../shared/bridge');
Annotator.Plugin.CrossFrame.Discovery = require('../shared/discovery');
var appLinkEl =
document.querySelector('link[type="application/annotator+html"]');
......
'use strict';
var observable = require('../util/observable');
var observable = require('./util/observable');
/** Returns the selected `DOMRange` in `document`. */
function selectedRange(document) {
......
'use strict';
var adder = require('../adder');
var unroll = require('../../test/util').unroll;
var unroll = require('../../shared/test/util').unroll;
function rect(left, top, width, height) {
return {left: left, top: top, width: width, height: height};
......
......@@ -2,7 +2,7 @@ Annotator = require('annotator')
proxyquire = require('proxyquire')
adder = require('../adder')
Observable = require('../../util/observable').Observable
Observable = require('../util/observable').Observable
$ = Annotator.$
Annotator['@noCallThru'] = true;
......
......@@ -11,7 +11,7 @@ describe 'Host', ->
fakeCrossFrame = null
createHost = (options={}, element=null) ->
options = Object.assign({app: '/base/test/empty.html'}, options)
options = Object.assign({app: '/base/annotator/test/empty.html'}, options)
if !element
element = document.createElement('div')
return new Host(element, options)
......@@ -87,7 +87,7 @@ describe 'Host', ->
host.publish('panelReady')
it 'passes options to the sidebar iframe', ->
appURL = new URL('/base/test/empty.html', window.location.href)
appURL = new URL('/base/annotator/test/empty.html', window.location.href)
host = createHost({annotations: '1234'})
configStr = encodeURIComponent(JSON.stringify({annotations: '1234'}))
assert.equal(host.frame[0].children[0].src, appURL + '?config=' + configStr)
......@@ -5,7 +5,7 @@
var Annotator = require('annotator');
var unroll = require('../../../test/util').unroll;
var unroll = require('../../../shared/test/util').unroll;
var Guest = require('../../guest');
function quoteSelector(quote) {
......
'use strict';
var unroll = require('../../test/util').unroll;
var unroll = require('../../shared/test/util').unroll;
var observable = require('../../util/observable');
var observable = require('../util/observable');
var selections = require('../selections');
function FakeDocument() {
......
......@@ -20,13 +20,13 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
// Polyfills for PhantomJS
'./polyfills.js',
'./shared/polyfills.js',
// Test setup
'./test/bootstrap.js',
'./sidebar/test/bootstrap.js',
// Empty HTML file to assist with some tests
{ pattern: './test/empty.html', watched: false },
{ pattern: './annotator/test/empty.html', watched: false },
// Karma watching is disabled for these files because they are
// bundled with karma-browserify which handles watching itself via
......@@ -47,8 +47,8 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./polyfills.js': ['browserify'],
'./test/bootstrap.js': ['browserify'],
'./shared/polyfills.js': ['browserify'],
'./sidebar/test/bootstrap.js': ['browserify'],
'**/*-test.js': ['browserify'],
'**/*-test.coffee': ['browserify'],
'**/*-it.js': ['browserify'],
......@@ -57,7 +57,7 @@ module.exports = function(config) {
browserify: {
debug: true,
extensions: ['.coffee'],
noParse: [require.resolve('./vendor/katex')],
noParse: [require.resolve('./sidebar/vendor/katex')],
configure: function (bundle) {
bundle.plugin('proxyquire-universal');
},
......
......@@ -24,11 +24,3 @@ try {
} catch (err) {
require('js-polyfills/url');
}
// document.evaluate() implementation,
// required by IE 10, 11
//
// This sets `window.wgxpath`
if (!window.document.evaluate) {
require('./vendor/wgxpath.install');
}
......@@ -2,14 +2,14 @@
var queryString = require('query-string');
require('./polyfills');
require('../shared/polyfills');
var raven;
// Initialize Raven. This is required at the top of this file
// so that it happens early in the app's startup flow
var configParam = queryString.parse(window.location.search).config || 'null';
var settings = require('./settings')(document);
var settings = require('../shared/settings')(document);
Object.assign(settings, JSON.parse(configParam));
if (settings.raven) {
raven = require('./raven');
......@@ -162,7 +162,7 @@ module.exports = angular.module('h', [
.service('annotationMapper', require('./annotation-mapper'))
.service('annotationUI', require('./annotation-ui'))
.service('auth', require('./auth').service)
.service('bridge', require('./bridge'))
.service('bridge', require('../shared/bridge'))
.service('drafts', require('./drafts'))
.service('features', require('./features'))
.service('flash', require('./flash'))
......@@ -185,7 +185,7 @@ module.exports = angular.module('h', [
.factory('store', require('./store'))
.value('Discovery', require('./discovery'))
.value('Discovery', require('../shared/discovery'))
.value('ExcerptOverflowMonitor', require('./directive/excerpt-overflow-monitor'))
.value('VirtualThreadList', require('./virtual-thread-list'))
.value('raven', require('./raven'))
......
......@@ -6,7 +6,7 @@ var proxyquire = require('proxyquire');
var events = require('../../events');
var fixtures = require('../../test/annotation-fixtures');
var testUtil = require('../../test/util');
var testUtil = require('../../../shared/test/util');
var util = require('./util');
var inject = angular.mock.inject;
......
......@@ -2,7 +2,7 @@
var angular = require('angular');
var unroll = require('../../test/util').unroll;
var unroll = require('../../../shared/test/util').unroll;
var util = require('./util');
function testComponent() {
......
......@@ -4,7 +4,7 @@ var angular = require('angular');
var proxyquire = require('proxyquire');
var util = require('./util');
var noCallThru = require('../../test/util').noCallThru;
var noCallThru = require('../../../shared/test/util').noCallThru;
describe('markdown', function () {
function isHidden(element) {
......
......@@ -5,7 +5,7 @@ var immutable = require('seamless-immutable');
var annotationUIFactory = require('../annotation-ui');
var annotationFixtures = require('./annotation-fixtures');
var metadata = require('../annotation-metadata');
var unroll = require('./util').unroll;
var unroll = require('../../shared/test/util').unroll;
var uiConstants = require('../ui-constants');
var defaultAnnotation = annotationFixtures.defaultAnnotation;
......
......@@ -4,7 +4,7 @@ var angular = require('angular');
var proxyquire = require('proxyquire');
var events = require('../events');
var util = require('./util');
var util = require('../../shared/test/util');
describe('AppController', function () {
var $controller = null;
......
......@@ -3,7 +3,7 @@
var angular = require('angular');
var immutable = require('seamless-immutable');
var unroll = require('../util').unroll;
var unroll = require('../../../shared/test/util').unroll;
var fixtures = immutable({
annotations: [{
......
'use strict';
var commands = require('../markdown-commands');
var unroll = require('./util').unroll;
var unroll = require('../../shared/test/util').unroll;
/**
* Convert a string containing '<sel>' and '</sel>' markers
......
'use strict';
var proxyquire = require('proxyquire');
var noCallThru = require('./util').noCallThru;
var noCallThru = require('../../shared/test/util').noCallThru;
function fakeExceptionData(scriptURL) {
return {
......
'use strict';
var retryUtil = require('../retry-util');
var toResult = require('./promise-util').toResult;
var toResult = require('../../shared/test/promise-util').toResult;
describe('retry-util', function () {
describe('.retryPromiseOperation', function () {
......
......@@ -7,7 +7,7 @@ var immutable = require('seamless-immutable');
var annotationFixtures = require('./annotation-fixtures');
var events = require('../events');
var uiConstants = require('../ui-constants');
var util = require('./util');
var util = require('../../shared/test/util');
var unroll = util.unroll;
......
......@@ -3,7 +3,7 @@
var angular = require('angular');
var proxyquire = require('proxyquire');
var util = require('./util');
var util = require('../../shared/test/util');
describe('store', function () {
var $httpBackend = null;
......
......@@ -5,7 +5,7 @@ var inherits = require('inherits');
var proxyquire = require('proxyquire');
var events = require('../events');
var unroll = require('./util').unroll;
var unroll = require('../../shared/test/util').unroll;
var fixtures = {
createNotification: {
......
......@@ -3,7 +3,7 @@
var fixtures = require('./annotation-fixtures');
var uiConstants = require('../ui-constants');
var tabs = require('../tabs');
var unroll = require('./util').unroll;
var unroll = require('../../shared/test/util').unroll;
describe('tabs', function () {
describe('shouldSeparateOrphans', function () {
......
......@@ -8,7 +8,7 @@ var VirtualThreadList = proxyquire('../virtual-thread-list', {
return fn;
},
});
var util = require('./util');
var util = require('../../shared/test/util');
var unroll = util.unroll;
describe('VirtualThreadList', function () {
......
......@@ -6,7 +6,7 @@ var proxyquire = require('proxyquire');
var EventEmitter = require('tiny-emitter');
var events = require('../events');
var noCallThru = require('./util').noCallThru;
var noCallThru = require('../../shared/test/util').noCallThru;
var searchClients;
function FakeSearchClient(searchFn, opts) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment