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'))
......
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