From 6e511af33ad01c3f36bd8e33d650d20f94574fb2 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:27:27 +0300 Subject: [PATCH 01/81] Improve make script. --- make.js | 130 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/make.js b/make.js index 24e93db..a5c301d 100644 --- a/make.js +++ b/make.js @@ -1,67 +1,74 @@ -var b = require('substance-bundler'); -var fs = require('fs') -var config = require('config') +const b = require('substance-bundler') +const fs = require('fs') +const config = require('config') b.task('clean', function() { b.rm('./dist') }) - // copy assets b.task('assets', function() { - b.copy('node_modules/font-awesome', './dist/font-awesome') - b.copy('node_modules/leaflet.markercluster/dist', './dist/markercluster') + b.copy('node_modules/font-awesome', './dist/libs/font-awesome') + b.copy('node_modules/leaflet.markercluster/dist', './dist/libs/markercluster') b.copy('node_modules/leaflet/dist/images', './dist/publisher/images') b.copy('node_modules/leaflet-control-geocoder/dist/images', './dist/publisher/images') }) - -// this optional task makes it easier to work on Substance core -b.task('substance', function() { - b.make('substance', 'build') - b.copy('node_modules/substance/dist', './dist/substance') - b.minify('./dist/substance/substance.js', './dist/substance/substance.min.js') +// dev +b.task('publisher', buildApp('publisher')) +b.task('scholar', buildApp('scholar')) +// production +b.task('publisher-min', buildApp('publisher', true)) +b.task('scholar-min', buildApp('scholar', true)) +// build apps +b.task('client', ['publisher', 'scholar']) +b.task('client-min', ['scholar-min', 'publisher-min']) +// build libraries +b.task('deps', () => { + _buildDeps() }) - -b.task('archivist', function() { - b.make('archivist', 'build') - b.copy('node_modules/archivist/dist', './dist/archivist') - b.minify('./dist/archivist/archivist.js', './dist/archivist/archivist.min.js') +b.task('deps-min', () => { + _buildDeps(true) +}) +// build server js +b.task('server', () => { + buildServerJS() }) -function buildArchivistDev() { - return function() { - b.make('archivist', 'dev') - b.copy('node_modules/archivist/dist', './dist/archivist') - } -} +// build all +b.task('default', ['dev']) +b.task('dev', ['clean', 'assets', 'deps', 'server', 'client']) +b.task('production', ['clean', 'assets', 'deps-min', 'server', 'client-min']) function buildApp(app, production) { return function() { if(production) { - b.copy('client/'+app+'/index.production.html', './dist/'+app+'/index.html') + b.copy('client/'+ app +'/index.production.html', './dist/'+ app +'/index.html') } else { - b.copy('client/'+app+'/index.html', './dist/'+app+'/') + b.copy('client/'+ app +'/index.html', './dist/'+ app +'/') } - b.copy('client/'+app+'/assets', './dist/'+app+'/assets/') - b.css('./client/' + app + '/app.css', 'dist/' + app + '/' + app + '.css', {variables: true}) + b.copy('client/'+ app +'/assets', './dist/'+ app +'/assets/') + b.css('client/' + app + '/app.css', 'dist/' + app + '/' + app + '.css') + b.js('client/' + app + '/app.js', { - // need buble if we want to minify later - buble: true, - external: ['substance', 'archivist'], - commonjs: { + targets: [{ + dest: './dist/' + app + '/app.js', + format: 'umd', moduleName: 'app' + }], + commonjs: { include: [ 'node_modules/moment/moment.js', 'node_modules/plyr/src/js/plyr.js', 'node_modules/leaflet/dist/leaflet-src.js', 'node_modules/leaflet.markercluster/dist/leaflet.markercluster-src.js', 'node_modules/leaflet-control-geocoder/dist/Control.Geocoder.js' - ] + ] }, - targets: [{ - dest: './dist/' + app + '/app.js', - format: 'umd', - moduleName: app - }] + external: ['substance', 'archivist'], + globals: { + 'substance': 'substance', + 'archivist': 'archivist' + } }) + b.custom('injecting config', { src: './dist/' + app + '/app.js', dest: './dist/' + app + '/' + app + '.js', @@ -71,47 +78,38 @@ function buildApp(app, production) { fs.writeFileSync(this.outputs[0], result, 'utf8') } }) - b.minify('./dist/' + app + '/' + app + '.js', './dist/' + app + '/' + app + '.min.js') - b.copy('./dist/' + app + '/app.js.map', './dist/' + app + '/' + app + '.js.map') + if(production) { + b.minify('./dist/' + app + '/' + app + '.js', './dist/' + app + '/' + app + '.min.js') + } else { + b.copy('./dist/' + app + '/app.js.map', './dist/' + app + '/' + app + '.js.map') + } b.rm('./dist/' + app + '/app.js') b.rm('./dist/' + app + '/app.js.map') } } -function _ostJS() { +function buildServerJS() { b.js('./index.es.js', { - buble: true, external: ['substance', 'archivist'], + globals: { + 'substance': 'substance', + 'archivist': 'archivist' + }, targets: [{ dest: 'dist/ost.cjs.js', - format: 'cjs', - sourceMapRoot: __dirname, - sourceMapPrefix: 'ost' + format: 'cjs' }] }) } -b.task('deps', ['substance', 'assets', 'archivist']) -b.task('ost', _ostJS()) - -// dev -b.task('archivist-dev', buildArchivistDev()) -b.task('publisher', buildApp('publisher')) -b.task('scholar', buildApp('scholar')) -// production -b.task('publisher-min', buildApp('publisher', true)) -b.task('scholar-min', buildApp('scholar', true)) - -b.task('client', ['publisher', 'scholar']) -b.task('client-min', ['scholar-min', 'publisher-min']) +/* HELPERS */ -// build all -b.task('default', ['deps', 'client', 'ost']) -b.task('dev', ['substance', 'assets', 'archivist-dev', 'client', 'ost']) -b.task('production', ['deps', 'client-min', 'ost']) +function _buildDeps(min) { + b.make('substance', 'lib') + b.copy('node_modules/substance/dist', './dist/libs/substance') + if(min) b.minify('./dist/libs/substance/substance.js', './dist/libs/substance/substance.min.js') -// starts a server when CLI argument '-s' is set -b.setServerPort(5001) -b.serve({ - static: true, route: '/', folder: 'dist' -}); \ No newline at end of file + b.make('archivist', 'lib') + b.copy('node_modules/archivist/dist', './dist/libs/archivist') + if(min) b.minify('./dist/libs/archivist/archivist.js', './dist/libs/archivist/archivist.min.js') +} \ No newline at end of file From af81b034e57d8284bcee652496506cbee3eb1176 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:27:45 +0300 Subject: [PATCH 02/81] Change bundler version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5451f0..5642745 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "devDependencies": { "eslint": "^3.5.0", "font-awesome": "^4.7.0", - "substance-bundler": "^0.15.2", + "substance-bundler": "^0.18.3", "tap-spec": "^4.1.1", "tape": "^4.6.0", "uglify-js": "^2.7.3", From dc8f5c9a75a44ded0575b097faad5fd1927feab6 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:28:42 +0300 Subject: [PATCH 03/81] Drop libraries into libs directory. --- client/publisher/index.html | 15 +++++++-------- server.js | 5 +---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/client/publisher/index.html b/client/publisher/index.html index 63333e0..9855c37 100644 --- a/client/publisher/index.html +++ b/client/publisher/index.html @@ -2,19 +2,18 @@ Archivist Publisher - - + + diff --git a/server.js b/server.js index 9fdb19e..1809944 100644 --- a/server.js +++ b/server.js @@ -31,10 +31,7 @@ configurator.setDefaultLanguage('russian'); /* Serve app */ -app.use('/archivist', express.static(path.join(__dirname, '/dist/archivist'))); -app.use('/font-awesome', express.static(path.join(__dirname, '/dist/font-awesome'))); -app.use('/markercluster', express.static(path.join(__dirname, '/dist/markercluster'))); -app.use('/substance', express.static(path.join(__dirname, '/dist/substance'))); +app.use('/libs', express.static(path.join(__dirname, '/dist/libs'))); if(config.publisherEndpoint) app.use(config.publisherEndpoint, express.static(path.join(__dirname, '/dist/publisher'))); if(config.scholarEndpoint) app.use(config.scholarEndpoint, express.static(path.join(__dirname, '/dist/scholar'))); app.use('/documents/:id', express.static(path.join(__dirname, '/dist/scholar'))); From 34f3c64cffc82c6162d294c4f90d2545772b5ad2 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:29:41 +0300 Subject: [PATCH 04/81] Highlights. --- packages/definition/DefinitionReference.js | 8 ++++++++ packages/person/PersonReference.js | 8 ++++++++ packages/prison/PrisonReference.js | 8 ++++++++ packages/toponym/ToponymReference.js | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/packages/definition/DefinitionReference.js b/packages/definition/DefinitionReference.js index ca9b588..69d4a7d 100644 --- a/packages/definition/DefinitionReference.js +++ b/packages/definition/DefinitionReference.js @@ -18,6 +18,14 @@ class DefinitionReference extends PropertyAnnotation { isResourceMultipleReference() { return false } + + setHighlighted(highlighted, scope) { + if (this.highlighted !== highlighted) { + this.highlightedScope = scope + this.highlighted = highlighted + this.emit('highlighted', highlighted) + } + } } DefinitionReference.define({ diff --git a/packages/person/PersonReference.js b/packages/person/PersonReference.js index fe641ba..5cb5426 100644 --- a/packages/person/PersonReference.js +++ b/packages/person/PersonReference.js @@ -18,6 +18,14 @@ class PersonReference extends PropertyAnnotation { isResourceMultipleReference() { return false } + + setHighlighted(highlighted, scope) { + if (this.highlighted !== highlighted) { + this.highlightedScope = scope + this.highlighted = highlighted + this.emit('highlighted', highlighted) + } + } } PersonReference.define({ diff --git a/packages/prison/PrisonReference.js b/packages/prison/PrisonReference.js index 45c6ab8..99f601d 100644 --- a/packages/prison/PrisonReference.js +++ b/packages/prison/PrisonReference.js @@ -18,6 +18,14 @@ class PrisonReference extends PropertyAnnotation { isResourceMultipleReference() { return false } + + setHighlighted(highlighted, scope) { + if (this.highlighted !== highlighted) { + this.highlightedScope = scope + this.highlighted = highlighted + this.emit('highlighted', highlighted) + } + } } PrisonReference.define({ diff --git a/packages/toponym/ToponymReference.js b/packages/toponym/ToponymReference.js index adab827..bf90c44 100644 --- a/packages/toponym/ToponymReference.js +++ b/packages/toponym/ToponymReference.js @@ -18,6 +18,14 @@ class ToponymReference extends PropertyAnnotation { isResourceMultipleReference() { return false } + + setHighlighted(highlighted, scope) { + if (this.highlighted !== highlighted) { + this.highlightedScope = scope + this.highlighted = highlighted + this.emit('highlighted', highlighted) + } + } } ToponymReference.define({ From 41de33c51306a85c32e54108556a4fe94731fe88 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:30:11 +0300 Subject: [PATCH 05/81] Upgrade Interview package. --- packages/interview/Interview.js | 8 +++----- packages/interview/package.js | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/interview/Interview.js b/packages/interview/Interview.js index 5ef75ec..5481813 100644 --- a/packages/interview/Interview.js +++ b/packages/interview/Interview.js @@ -6,12 +6,10 @@ import { map } from 'lodash-es' */ class Interview extends Document { - constructor(...args) { - super(...args) - this._initialize() - } - + _initialize() { + super._initialize() + this.create({ type: 'container', id: 'body', diff --git a/packages/interview/package.js b/packages/interview/package.js index ab2c216..4c666a0 100644 --- a/packages/interview/package.js +++ b/packages/interview/package.js @@ -16,7 +16,7 @@ export default { configure: function(config) { config.defineSchema({ name: 'archivist-interview', - ArticleClass: Interview, + DocumentClass: Interview, defaultTextType: 'paragraph' }) config.addNode(MetaNode) From 19d047ea8e3da080c79dfe8d3387d081be27e845 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:34:39 +0300 Subject: [PATCH 06/81] Upgrade towards substance beta-6. --- .../definition-manager/DefinitionsPage.js | 4 +++- packages/explorer/SearchBar.js | 7 +++++-- .../forms/geocoded-field/GeocodedField.js | 4 +++- packages/info-context/InfoContext.js | 8 +++++--- packages/ost-publisher/OstPublisherLayout.js | 3 ++- packages/subject-manager/SubjectsPage.js | 20 +++++++++++++------ 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/packages/definition-manager/DefinitionsPage.js b/packages/definition-manager/DefinitionsPage.js index 7ef3dcc..92e295c 100644 --- a/packages/definition-manager/DefinitionsPage.js +++ b/packages/definition-manager/DefinitionsPage.js @@ -1,4 +1,4 @@ -import { FontAwesomeIcon as Icon, Input } from 'substance' +import { FontAwesomeIcon as Icon } from 'substance' import { AbstractEntityPage } from 'archivist' const definitionTypes = [ @@ -10,6 +10,8 @@ const definitionTypes = [ class DefinitionsPage extends AbstractEntityPage { renderFilters($$) { + const Input = this.getComponent('input') + let filters = [] let search = $$('div').addClass('se-search').append( $$(Icon, {icon: 'fa-search'}) diff --git a/packages/explorer/SearchBar.js b/packages/explorer/SearchBar.js index 07d380f..db975b8 100644 --- a/packages/explorer/SearchBar.js +++ b/packages/explorer/SearchBar.js @@ -1,8 +1,11 @@ -import { Button, Component, Input } from 'substance' +import { Component } from 'substance' class SearchBar extends Component { render($$) { + const Button = this.getComponent('button') + const Input = this.getComponent('input') + let el = $$('div').addClass('sc-searchbar') let inputSearch = $$(Input, {placeholder: this.getLabel('searchbar-placeholder'), value: this.props.value}) @@ -10,7 +13,7 @@ class SearchBar extends Component { .addClass('se-search-input') .on('keypress', this._onSearchKeyPress) - let submitBtn = $$(Button, {style: 'outline', label: 'searchbar-submit', icon: 'searchbar-search'}) + let submitBtn = $$(Button, {theme: 'round', label: 'searchbar-submit', icon: 'searchbar-search'}) .addClass('se-search-submit') .on('click', this._onSearch) diff --git a/packages/forms/geocoded-field/GeocodedField.js b/packages/forms/geocoded-field/GeocodedField.js index a89d53e..1695846 100644 --- a/packages/forms/geocoded-field/GeocodedField.js +++ b/packages/forms/geocoded-field/GeocodedField.js @@ -1,4 +1,6 @@ -import { Component, FontAwesomeIcon as Icon, Input } from 'substance' +import { Component, FontAwesomeIcon as Icon, InputPackage } from 'substance' + +const { Input } = InputPackage class GeocodedField extends Component { diff --git a/packages/info-context/InfoContext.js b/packages/info-context/InfoContext.js index d7a55e5..a53ef87 100644 --- a/packages/info-context/InfoContext.js +++ b/packages/info-context/InfoContext.js @@ -1,4 +1,4 @@ -import { Button, Component, ScrollPane } from 'substance' +import { Component, ScrollPane } from 'substance' class InfoContext extends Component { getInitialState() { @@ -45,20 +45,22 @@ class InfoContext extends Component { } renderAbstract($$, abstract) { + const Button = this.getComponent('button') + let el = $$('div').addClass('se-meta-abstract') if(this.state.teaserAbstract) { let teaser = abstract.split('\n').shift() el.append( teaser, - $$(Button, {style: 'outline', label: 'expand-abstract'}).addClass('se-abstract-toggle') + $$(Button, {theme: 'round', label: 'expand-abstract'}).addClass('se-abstract-toggle') .on('click', this._toggleAbstract) ) } else { el.append( $$('div').addClass('se-abstract-full') .setInnerHTML('

' + abstract.split('\n').join('

') + '

'), - $$(Button, {style: 'outline', label: 'collapse-abstract'}).addClass('se-abstract-toggle') + $$(Button, {theme: 'round', label: 'collapse-abstract'}).addClass('se-abstract-toggle') .on('click', this._toggleAbstract) ) } diff --git a/packages/ost-publisher/OstPublisherLayout.js b/packages/ost-publisher/OstPublisherLayout.js index fc51eb9..dfd009c 100644 --- a/packages/ost-publisher/OstPublisherLayout.js +++ b/packages/ost-publisher/OstPublisherLayout.js @@ -1,7 +1,8 @@ -import { CollabSession, JSONConverter, series, substanceGlobals } from 'substance' +import { async, CollabSession, JSONConverter, substanceGlobals } from 'substance' import { PublisherLayout } from 'archivist' import OstPublisher from './OstPublisher' +const {series} = async let converter = new JSONConverter() class OstPublisherLayout extends PublisherLayout { diff --git a/packages/subject-manager/SubjectsPage.js b/packages/subject-manager/SubjectsPage.js index 5a6e1fa..30aba92 100644 --- a/packages/subject-manager/SubjectsPage.js +++ b/packages/subject-manager/SubjectsPage.js @@ -1,10 +1,7 @@ -import { Button, Component, FontAwesomeIcon as Icon, Grid, Input, Layout, Modal, SplitPane, SubstanceError as Err } from 'substance' -import { concat, each, findIndex, flattenDeep, isEmpty, sortBy, map, throttle} from 'lodash-es' +import { Component, FontAwesomeIcon as Icon, SplitPane, SubstanceError as Err } from 'substance' +import { concat, each, flattenDeep, isEmpty, sortBy, map, throttle} from 'lodash-es' import moment from 'moment' -// Sample data for debugging -// import DataSample from '../../data/docs' - class SubjectsPage extends Component { constructor(...args) { super(...args) @@ -42,6 +39,8 @@ class SubjectsPage extends Component { } render($$) { + const Modal = this.getComponent('modal') + let items = this.state.items let el = $$('div').addClass('sc-subjects-page') let main = $$('div').addClass('se-entity-layout') @@ -98,6 +97,8 @@ class SubjectsPage extends Component { } renderFilters($$) { + const Input = this.getComponent('input') + let filters = [] let search = $$('div').addClass('se-search').append( $$(Icon, {icon: 'fa-search'}) @@ -145,6 +146,8 @@ class SubjectsPage extends Component { } renderEmpty($$) { + const Layout = this.getComponent('layout') + let layout = $$(Layout, { width: 'medium', textAlign: 'center' @@ -173,6 +176,8 @@ class SubjectsPage extends Component { } renderAdditionalMenu($$, actions) { + const Button = this.getComponent('button') + let el = $$('div').addClass('se-more').attr({'tabindex': 0}) let actionsList = $$('ul').addClass('se-more-content') each(actions, action => { @@ -188,7 +193,8 @@ class SubjectsPage extends Component { } renderFull($$) { - let urlHelper = this.context.urlHelper + const Grid = this.getComponent('grid') + let items = this.state.items let grid = $$(Grid) @@ -207,6 +213,8 @@ class SubjectsPage extends Component { } renderChildren($$, node, level) { + const Grid = this.getComponent('grid') + let items = this.state.items let edited = ['Updated', moment(node.edited).fromNow(), 'by', node.updatedBy].join(' ') let isHighlighted = node.selected From d2cbd82f8521457e4dbf23de4fd9622467ea3267 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:35:05 +0300 Subject: [PATCH 07/81] Upgrade subjects packages. --- packages/subject/SubjectCommand.js | 4 +++- packages/subject/package.js | 4 +--- packages/subjects/SubjectsImporter.js | 2 +- packages/subjects/SubjectsIndex.js | 2 +- packages/subjects/package.js | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/subject/SubjectCommand.js b/packages/subject/SubjectCommand.js index de081f7..f6e5c21 100644 --- a/packages/subject/SubjectCommand.js +++ b/packages/subject/SubjectCommand.js @@ -1,4 +1,6 @@ -import { ContainerAnnotationCommand } from 'substance' +import { ContainerAnnotationPackage } from 'substance' + +const { ContainerAnnotationCommand } = ContainerAnnotationPackage class SubjectCommand extends ContainerAnnotationCommand { diff --git a/packages/subject/package.js b/packages/subject/package.js index ffb5b90..3d3f442 100644 --- a/packages/subject/package.js +++ b/packages/subject/package.js @@ -1,5 +1,4 @@ import SubjectReference from './SubjectReference' -import SubjectTool from './SubjectTool' import SubjectCommand from './SubjectCommand' import SubjectComponent from './SubjectComponent' @@ -7,8 +6,7 @@ export default { name: 'subject', configure: function(config) { config.addNode(SubjectReference) - config.addTool(SubjectReference.type, SubjectTool, { toolGroup: 'references' }) - config.addCommand(SubjectReference.type, SubjectCommand, { nodeType: SubjectReference.type }) + config.addCommand(SubjectReference.type, SubjectCommand, { nodeType: SubjectReference.type, commandGroup: 'references' }) config.addComponent('container-annotation-fragment', SubjectComponent) config.addIcon(SubjectReference.type, {'fontawesome': 'fa-tags'}) } diff --git a/packages/subjects/SubjectsImporter.js b/packages/subjects/SubjectsImporter.js index 153fd53..28c7d8b 100644 --- a/packages/subjects/SubjectsImporter.js +++ b/packages/subjects/SubjectsImporter.js @@ -8,7 +8,7 @@ class SubjectsImporter extends HTMLImporter { importDocument(subjectsData, reader, facets) { this.reset() - let doc = this.generateDocument() + let doc = this.state.doc each(subjectsData, function(subject) { if(reader) { doc.create({ diff --git a/packages/subjects/SubjectsIndex.js b/packages/subjects/SubjectsIndex.js index 0b9c73d..4481df1 100644 --- a/packages/subjects/SubjectsIndex.js +++ b/packages/subjects/SubjectsIndex.js @@ -61,7 +61,7 @@ class SubjectIndex extends NodeIndex { return new SubjectIndex(this.doc) } - _clear() { + clear() { this.index.clear() } } diff --git a/packages/subjects/package.js b/packages/subjects/package.js index 1101670..f2fa6c6 100644 --- a/packages/subjects/package.js +++ b/packages/subjects/package.js @@ -8,8 +8,8 @@ export default { configure: function(config) { config.defineSchema({ name: 'archivist-subjects', - ArticleClass: Subjects, - defaultTextType: 'paragraph' + DocumentClass: Subjects, + defaultTextType: 'subject' }) config.addNode(Subject) From 8b9e429d24cc2eb87226ef04378b5a86053457d7 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:38:05 +0300 Subject: [PATCH 08/81] Remove obsolete tools. --- packages/entity-reference/EntityReferenceTool.js | 5 ----- packages/entity-reference/package.js | 4 +--- packages/subject/SubjectTool.js | 5 ----- 3 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 packages/entity-reference/EntityReferenceTool.js delete mode 100644 packages/subject/SubjectTool.js diff --git a/packages/entity-reference/EntityReferenceTool.js b/packages/entity-reference/EntityReferenceTool.js deleted file mode 100644 index 8cfa809..0000000 --- a/packages/entity-reference/EntityReferenceTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class EntityReferenceTool extends AnnotationTool {} - -export default EntityReferenceTool \ No newline at end of file diff --git a/packages/entity-reference/package.js b/packages/entity-reference/package.js index e4014ef..6a5e416 100644 --- a/packages/entity-reference/package.js +++ b/packages/entity-reference/package.js @@ -1,12 +1,10 @@ import { platform } from 'substance' -import EntityReferenceTool from './EntityReferenceTool' import EntityReferenceCommand from './EntityReferenceCommand' export default { name: 'entity-reference', configure: function(config) { - config.addTool('entity-reference', EntityReferenceTool, {toolGroup: 'references'}) - config.addCommand('entity-reference', EntityReferenceCommand, { nodeType: 'entity-reference' }) + config.addCommand('entity-reference', EntityReferenceCommand, { nodeType: 'entity-reference', commandGroup: 'references' }) config.addIcon('entity-reference', {'fontawesome': 'fa-book'}) if (platform.isMac) { diff --git a/packages/subject/SubjectTool.js b/packages/subject/SubjectTool.js deleted file mode 100644 index 3eb2148..0000000 --- a/packages/subject/SubjectTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class SubjectTool extends AnnotationTool {} - -export default SubjectTool From ffeebd43bf70ab810423f06a4383007aae42e65f Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:41:22 +0300 Subject: [PATCH 09/81] Upgrade publisher. --- client/publisher/package.js | 6 ++-- packages/ost-publisher/package.js | 57 +++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/client/publisher/package.js b/client/publisher/package.js index c2d919b..e4d6b13 100644 --- a/client/publisher/package.js +++ b/client/publisher/package.js @@ -1,4 +1,4 @@ -import { ProseArticle } from 'substance' +import { ProseEditorPackage } from 'substance' import { ArchivistPackage, ArchivistSubConfigurator, CommentsPackage, DocumentsPackage, IndentationPackage, MetadataEditorPackage, ResourcesPackage, TimecodeAnnotatorPackage, UsersPackage, WhitespacePackage } from 'archivist' import InterviewPackage from '../../packages/interview/package' import FormsPackage from '../../packages/forms/package' @@ -22,6 +22,8 @@ import Subject from '../../packages/subjects/Subject' import Subjects from '../../packages/subjects/package' import Toponym from '../../packages/toponym/Toponym' +const { ProseArticle } = ProseEditorPackage + let appConfig = 'ARCHIVISTCONFIG' appConfig = JSON.parse(appConfig) @@ -72,7 +74,7 @@ export default { let EntitiesConfigurator = new ArchivistSubConfigurator() EntitiesConfigurator.defineSchema({ name: 'archivist-entities', - ArticleClass: ProseArticle + DocumentClass: ProseArticle }) EntitiesConfigurator.addNode(Definition) EntitiesConfigurator.addNode(Person) diff --git a/packages/ost-publisher/package.js b/packages/ost-publisher/package.js index 85ab45f..9d44da3 100644 --- a/packages/ost-publisher/package.js +++ b/packages/ost-publisher/package.js @@ -1,5 +1,6 @@ import OstPublisherLayout from './OstPublisherLayout' import { BracketsPackage, TabbedContextPackage } from 'archivist' +import { ContainerAnnotationPackage, FindAndReplacePackage } from 'substance' export default { name: 'ost-publisher', @@ -7,7 +8,59 @@ export default { config.import(BracketsPackage) config.import(TabbedContextPackage) config.addComponent('editor', OstPublisherLayout) - config.addToolGroup('references') - config.addToolGroup('utils') + + config.import(ContainerAnnotationPackage) + config.import(FindAndReplacePackage, { + targetSurfaces: ['body'] + }) + + // Configure overlay + config.addToolPanel('main-overlay', [ + { + name: 'prompt', + type: 'tool-group', + commandGroups: ['prompt'] + } + ]) + + config.addToolPanel('workflow', [ + { + name: 'workflow', + type: 'tool-group', + commandGroups: ['workflows'] + } + ]) + + // Configure toolbar + config.addToolPanel('toolbar', [ + { + name: 'document', + type: 'tool-group', + showDisabled: true, + style: 'minimal', + commandGroups: ['undo-redo', 'persistence'] + }, + { + name: 'annotations', + type: 'tool-group', + showDisabled: true, + style: 'minimal', + commandGroups: ['annotations'] + }, + { + name: 'references', + type: 'tool-group', + showDisabled: true, + style: 'minimal', + commandGroups: ['references'] + }, + { + name: 'utils', + type: 'tool-group', + showDisabled: true, + style: 'minimal', + commandGroups: ['utils'] + } + ]) } } \ No newline at end of file From 1882e490ce0d33dff7052570a99190e12c16fa7f Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:41:30 +0300 Subject: [PATCH 10/81] Improve styles. --- client/publisher/app.css | 1 - packages/definition/_index.css | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/client/publisher/app.css b/client/publisher/app.css index c0cf8e3..b8c5d33 100644 --- a/client/publisher/app.css +++ b/client/publisher/app.css @@ -1,5 +1,4 @@ /* Publisher Component styles */ -@import '../../node_modules/substance/dist/substance.next.css'; @import '../../node_modules/leaflet/dist/leaflet.css'; @import '../../node_modules/leaflet-control-geocoder/dist/Control.Geocoder.css'; @import './publisher.css'; diff --git a/packages/definition/_index.css b/packages/definition/_index.css index a9548c3..ef2eb4a 100644 --- a/packages/definition/_index.css +++ b/packages/definition/_index.css @@ -31,7 +31,7 @@ } .se-entity-entries .sc-entity-entry.se-definition .se-description { - margin-right: 0px; + margin-right: 20px; } .se-entity-entries .sc-entity-entry.se-definition .se-type, From 5c6cf85168eca245cdd4a3f2727082e23128b2a5 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 3 Aug 2017 00:50:10 +0300 Subject: [PATCH 11/81] Missing labels. --- packages/entity-reference/package.js | 11 +++++------ packages/subject/package.js | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/entity-reference/package.js b/packages/entity-reference/package.js index 6a5e416..8c859ef 100644 --- a/packages/entity-reference/package.js +++ b/packages/entity-reference/package.js @@ -1,4 +1,3 @@ -import { platform } from 'substance' import EntityReferenceCommand from './EntityReferenceCommand' export default { @@ -6,11 +5,11 @@ export default { configure: function(config) { config.addCommand('entity-reference', EntityReferenceCommand, { nodeType: 'entity-reference', commandGroup: 'references' }) config.addIcon('entity-reference', {'fontawesome': 'fa-book'}) + config.addLabel('entity-reference', { + en: 'Entity reference', + ru: 'Связать с сущностью' + }) - if (platform.isMac) { - config.addKeyboardShortcut('cmd+e', { command: 'entity-reference' }) - } else { - config.addKeyboardShortcut('ctrl+e', { command: 'entity-reference' }) - } + config.addKeyboardShortcut('CommandOrControl+E', { command: 'entity-reference' }) } } \ No newline at end of file diff --git a/packages/subject/package.js b/packages/subject/package.js index 3d3f442..9b4aaa3 100644 --- a/packages/subject/package.js +++ b/packages/subject/package.js @@ -9,5 +9,10 @@ export default { config.addCommand(SubjectReference.type, SubjectCommand, { nodeType: SubjectReference.type, commandGroup: 'references' }) config.addComponent('container-annotation-fragment', SubjectComponent) config.addIcon(SubjectReference.type, {'fontawesome': 'fa-tags'}) + + config.addLabel('subject', { + en: 'Subject reference', + ru: 'Связать с рубрикой' + }) } } \ No newline at end of file From 85867ebeff5ed9881fc431221bb6594793d4e9ee Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:00:53 +0300 Subject: [PATCH 12/81] Index subject parents. --- index.es.js | 4 +++- packages/indexer/Indexer.js | 48 +++++++++++++++++++++++++++++++++++-- packages/indexer/package.js | 5 ++-- packages/server/package.js | 5 ++++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/index.es.js b/index.es.js index 21e8a61..0acdce4 100644 --- a/index.es.js +++ b/index.es.js @@ -1,2 +1,4 @@ // interview -export { default as InterviewPackage } from './packages/interview/package' \ No newline at end of file +export { default as InterviewPackage } from './packages/interview/package' +// subjects +export { default as SubjectsPackage } from './packages/subjects/package' \ No newline at end of file diff --git a/packages/indexer/Indexer.js b/packages/indexer/Indexer.js index 155b8ad..2506a72 100644 --- a/packages/indexer/Indexer.js +++ b/packages/indexer/Indexer.js @@ -5,10 +5,17 @@ let forEach = require('lodash/forEach') let isEmpty = require('lodash/isEmpty') // Massive internal libs -let ArgTypes = require('../../node_modules/massive/lib/arg_types') -let Where = require('../../node_modules/massive/lib/where') +let massivePath = require.resolve('massive') +let ArgTypes = require(massivePath + '/../lib/arg_types') +let Where = require(massivePath + '/../lib/where') class Indexer extends ArchivistIndexer { + constructor(config) { + super(config) + + this.resourceEngine = config.resourceEngine + } + searchDocuments(filters, options) { let isTextSearch = filters.query ? true : false let limit = options.limit || 100 @@ -243,6 +250,43 @@ ORDER BY count DESC limit ${limit} offset ${offset}` }) }.bind(this)) } + + _countEntityReferences(doc) { + return new Promise((resolve) => { + let configurator = this.configurator.getConfigurator('archivist-subjects') + + this.resourceEngine.getResourcesTree('subject') + .then(subjectsData => { + let importer = configurator.createImporter('subjects') + let subjects = importer.importDocument(subjectsData, true) + let entitiesIndex = doc.getIndex('entities') + let annotations = [] + let references = {} + forEach(entitiesIndex.byReference, (refs, key) => { + annotations.push(key) + references[key] = Object.keys(refs).length + + let parents = subjects.getParents(key) + parents.forEach(parent => { + if(annotations.indexOf(parent) === -1) { + annotations.push(parent) + } + let counter = references[parent] + if(!counter) { + references[parent] = 1 + } else { + references[parent]++ + } + }) + }) + + resolve({ + annotations: annotations, + references: references + }) + }) + }) + } } module.exports = Indexer \ No newline at end of file diff --git a/packages/indexer/package.js b/packages/indexer/package.js index b7db918..0ca272c 100644 --- a/packages/indexer/package.js +++ b/packages/indexer/package.js @@ -8,8 +8,9 @@ module.exports = { db: db, configurator: config, documentEngine: config.getEngine('document'), - snapshotEngine: config.getEngine('snapshot'), - fragmentStore: config.getStore('fragment') + fragmentStore: config.getStore('fragment'), + resourceEngine: config.getEngine('resource'), + snapshotEngine: config.getEngine('snapshot') }) config.addEngine('indexer', indexer) diff --git a/packages/server/package.js b/packages/server/package.js index 35b62ec..2caa22c 100644 --- a/packages/server/package.js +++ b/packages/server/package.js @@ -7,6 +7,7 @@ let IndexerPackage = require('../indexer/package') let ResourceServerPackage = require('./resource/package') let ConverterServerPackage = require('./converter/package') let DocumentServerPackage = require('./document/package') +let ArchivistSubConfigurator = require('archivist').ArchivistSubConfigurator let AuthServerPackage = require('archivist').AuthServerPackage let CollabServerPackage = require('archivist').CollabServerPackage let UserServerPackage = require('archivist').UserServerPackage @@ -15,6 +16,7 @@ let InspectorPackage = require('archivist').InspectorPackage let db = new Database() let InterviewPackage = require('../../dist/ost.cjs').InterviewPackage +let SubjectsPackage = require('../../dist/ost.cjs').SubjectsPackage module.exports = { name: 'ost-server', @@ -31,5 +33,8 @@ module.exports = { config.import(ResourceServerPackage) config.import(UserServerPackage) config.import(ConverterServerPackage) + + // Subjects subconfigurator + config.addConfigurator('archivist-subjects', new ArchivistSubConfigurator().import(SubjectsPackage)) } } \ No newline at end of file From be427d91ce2e0fe9effc930f700818811dbfbdc9 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:01:21 +0300 Subject: [PATCH 13/81] Remove obsolete tool. --- packages/definition/DefinitionTool.js | 5 ----- packages/definition/package.js | 2 -- packages/person/PersonTool.js | 5 ----- packages/person/package.js | 2 -- packages/prison/PrisonTool.js | 5 ----- packages/prison/package.js | 2 -- packages/toponym/ToponymTool.js | 5 ----- packages/toponym/package.js | 2 -- 8 files changed, 28 deletions(-) delete mode 100644 packages/definition/DefinitionTool.js delete mode 100644 packages/person/PersonTool.js delete mode 100644 packages/prison/PrisonTool.js delete mode 100644 packages/toponym/ToponymTool.js diff --git a/packages/definition/DefinitionTool.js b/packages/definition/DefinitionTool.js deleted file mode 100644 index 8d3a0e4..0000000 --- a/packages/definition/DefinitionTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class DefinitionTool extends AnnotationTool {} - -export default DefinitionTool \ No newline at end of file diff --git a/packages/definition/package.js b/packages/definition/package.js index 74cfca7..0bf7035 100644 --- a/packages/definition/package.js +++ b/packages/definition/package.js @@ -1,5 +1,4 @@ import DefinitionReference from './DefinitionReference' -import DefinitionTool from './DefinitionTool' import DefinitionComponent from './DefinitionComponent' import DefinitionCommand from './DefinitionCommand' import DefinitionContextItem from './DefinitionContextItem' @@ -8,7 +7,6 @@ export default { name: 'definition', configure: function(config) { config.addNode(DefinitionReference) - //config.addTool(DefinitionReference.type, DefinitionTool, {toolGroup: 'references'}) config.addCommand(DefinitionReference.type, DefinitionCommand, { nodeType: DefinitionReference.type }) config.addIcon(DefinitionReference.type, {'fontawesome': 'fa-book'}) config.addComponent('definition', DefinitionComponent) diff --git a/packages/person/PersonTool.js b/packages/person/PersonTool.js deleted file mode 100644 index 19e5e82..0000000 --- a/packages/person/PersonTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class PersonTool extends AnnotationTool {} - -export default PersonTool \ No newline at end of file diff --git a/packages/person/package.js b/packages/person/package.js index 069e6f6..41193a6 100644 --- a/packages/person/package.js +++ b/packages/person/package.js @@ -1,5 +1,4 @@ import PersonReference from './PersonReference' -import PersonTool from './PersonTool' import PersonComponent from './PersonComponent' import PersonCommand from './PersonCommand' import PersonContextItem from './PersonContextItem' @@ -8,7 +7,6 @@ export default { name: 'person', configure: function(config) { config.addNode(PersonReference) - //config.addTool(PersonReference.type, PersonTool, {toolGroup: 'references'}) config.addCommand(PersonReference.type, PersonCommand, { nodeType: PersonReference.type }) config.addIcon(PersonReference.type, {'fontawesome': 'fa-address-book-o'}) config.addComponent('person', PersonComponent) diff --git a/packages/prison/PrisonTool.js b/packages/prison/PrisonTool.js deleted file mode 100644 index 8926220..0000000 --- a/packages/prison/PrisonTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class PrisonTool extends AnnotationTool {} - -export default PrisonTool \ No newline at end of file diff --git a/packages/prison/package.js b/packages/prison/package.js index 8736809..36a9a5e 100644 --- a/packages/prison/package.js +++ b/packages/prison/package.js @@ -1,5 +1,4 @@ import PrisonReference from './PrisonReference' -import PrisonTool from './PrisonTool' import PrisonComponent from './PrisonComponent' import PrisonCommand from './PrisonCommand' import PrisonContextItem from './PrisonContextItem' @@ -8,7 +7,6 @@ export default { name: 'prison', configure: function(config) { config.addNode(PrisonReference) - //config.addTool(PrisonReference.type, PrisonTool, {toolGroup: 'references'}) config.addCommand(PrisonReference.type, PrisonCommand, { nodeType: PrisonReference.type }) config.addIcon(PrisonReference.type, {'fontawesome': 'fa-th'}) config.addComponent('prison', PrisonComponent) diff --git a/packages/toponym/ToponymTool.js b/packages/toponym/ToponymTool.js deleted file mode 100644 index 8037821..0000000 --- a/packages/toponym/ToponymTool.js +++ /dev/null @@ -1,5 +0,0 @@ -import { AnnotationTool } from 'substance' - -class ToponymTool extends AnnotationTool {} - -export default ToponymTool \ No newline at end of file diff --git a/packages/toponym/package.js b/packages/toponym/package.js index 7eff59e..abb11e6 100644 --- a/packages/toponym/package.js +++ b/packages/toponym/package.js @@ -1,5 +1,4 @@ import ToponymReference from './ToponymReference' -import ToponymTool from './ToponymTool' import ToponymComponent from './ToponymComponent' import ToponymCommand from './ToponymCommand' import ToponymContextItem from './ToponymContextItem' @@ -8,7 +7,6 @@ export default { name: 'toponym', configure: function(config) { config.addNode(ToponymReference) - //config.addTool(ToponymReference.type, ToponymTool, {toolGroup: 'references'}) config.addCommand(ToponymReference.type, ToponymCommand, { nodeType: ToponymReference.type }) config.addIcon(ToponymReference.type, {'fontawesome': 'fa-globe'}) config.addComponent('toponym', ToponymComponent) From c11927a13fa5f4633c0dcc15967bfeba2747a7a3 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:01:43 +0300 Subject: [PATCH 14/81] Repair Explorer package. --- packages/explorer/DocumentItem.js | 5 +++-- packages/explorer/Explorer.js | 14 +++++++------- packages/explorer/ResourceReference.js | 3 ++- packages/explorer/_index.css | 7 +++++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/explorer/DocumentItem.js b/packages/explorer/DocumentItem.js index 5df9cab..ab5e720 100644 --- a/packages/explorer/DocumentItem.js +++ b/packages/explorer/DocumentItem.js @@ -1,15 +1,16 @@ -import { Component, Grid } from 'substance' +import { Component } from 'substance' import { forEach, isEmpty } from 'lodash-es' import moment from 'moment' class DocumentItem extends Component { render($$) { + let Grid = this.getComponent('grid') + let item = this.props.item let meta = item.meta let index = this.props.index let config = this.context.config - //let documentIcon = $$(Icon, {icon: 'fa-file-text-o'}) let urlHelper = this.context.urlHelper let url = urlHelper.openDocument(item.documentId) diff --git a/packages/explorer/Explorer.js b/packages/explorer/Explorer.js index 0ae3c2d..379651b 100644 --- a/packages/explorer/Explorer.js +++ b/packages/explorer/Explorer.js @@ -1,4 +1,4 @@ -import { Component, Grid, Layout, SplitPane } from 'substance' +import { Component, SplitPane } from 'substance' import { clone, concat, each, extend, findIndex, findLastIndex, isEmpty, isEqual, isUndefined } from 'lodash-es' // Sample data for debugging @@ -27,12 +27,6 @@ class Explorer extends Component { this._loadTopics() } - // didUpdate(oldProps, oldState) { - // // if(oldState.search !== this.state.search) { - // // this.searchData() - // // } - // } - willUpdateState(state) { let oldFilters = this.state.filters let newFilters = state.filters @@ -80,6 +74,8 @@ class Explorer extends Component { } render($$) { + let Layout = this.getComponent('layout') + let documentItems = this.state.items let el = $$('div').addClass('sc-explorer') @@ -148,6 +144,8 @@ class Explorer extends Component { } renderEmpty($$) { + let Layout = this.getComponent('layout') + let layout = $$(Layout, { width: 'medium', textAlign: 'center' @@ -177,6 +175,8 @@ class Explorer extends Component { } renderFull($$) { + let Grid = this.getComponent('grid') + let items = this.state.items let total = this.state.total let resource = this.state.resource diff --git a/packages/explorer/ResourceReference.js b/packages/explorer/ResourceReference.js index 020d5fc..2f7a632 100644 --- a/packages/explorer/ResourceReference.js +++ b/packages/explorer/ResourceReference.js @@ -1,4 +1,4 @@ -import { Component, Grid } from 'substance' +import { Component } from 'substance' class ResourceReference extends Component { @@ -87,6 +87,7 @@ class ResourceReference extends Component { } renderDocumentList($$) { + let Grid = this.getComponent('grid') let items = this.state.documents let resource = this.state.resource let isTopic = resource ? resource.entityType === 'subject' : false diff --git a/packages/explorer/_index.css b/packages/explorer/_index.css index 80322d5..835e349 100644 --- a/packages/explorer/_index.css +++ b/packages/explorer/_index.css @@ -24,12 +24,19 @@ position: absolute; top: 5px; right: 6px; + height: 30px; + line-height: 30px; background: #4A90E2; padding: 0px 10px; color: #fff; border-radius: 3px; } +.sc-explorer .sc-searchbar .se-search-submit:hover, +.sc-explorer .sc-searchbar .se-search-submit:active { + background: #4A90E2!important; +} + .sc-explorer .se-results-pane { padding-top: 30px; } From c3c6932736f9fdcdb7ed00b934fed40d0456bd68 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:01:57 +0300 Subject: [PATCH 15/81] Schema fixes. --- packages/interview/MetaNode.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/interview/MetaNode.js b/packages/interview/MetaNode.js index b8d9d59..8e92a5b 100644 --- a/packages/interview/MetaNode.js +++ b/packages/interview/MetaNode.js @@ -26,9 +26,9 @@ MetaNode.define({ interviewee_military_service: { type: 'boolean', default: false, field: { editor: "logical", description: "Check if person was in Soviet army", label: "Military service", group: 'Person details'}}, interviewee_sex: { type: 'string', default: '', field: { editor: "select", description: "Person gender", options: ['мужчина', 'женщина'], group: 'Person details'}}, interviewee_place_of_birth: { type: 'string', default: '', field: { editor: "text", description: "Person place of birth", group: 'Person details'}}, - interviewee_year_of_birth: { type: 'string', default: '', field: { editor: "input", dataType: "number", description: "Person year of birth", group: 'Person details'}}, - interviewee_enslaving_year: { type: 'string', default: '', field: { editor: "input", dataType: "number", description: "Person enslaving year", group: 'Person details'}}, - interviewee_homecoming_year: { type: 'string', default: '', field: { editor: "input", dataType: "number", description: "Person homecoming year", group: 'Person details'}}, + interviewee_year_of_birth: { type: 'string', default: '', field: { editor: "input", dataType: "text", description: "Person year of birth", group: 'Person details'}}, + interviewee_enslaving_year: { type: 'string', default: '', field: { editor: "input", dataType: "text", description: "Person enslaving year", group: 'Person details'}}, + interviewee_homecoming_year: { type: 'string', default: '', field: { editor: "input", dataType: "text", description: "Person homecoming year", group: 'Person details'}}, interviewee_photo: { type: 'string', default: '', field: { editor: "text", description: "Path to photo file", group: 'Person details'}}, // Project data From 209edab72b9712bdc28fe7da18b6d6726772c106 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:02:55 +0300 Subject: [PATCH 16/81] Repair Person index package. --- packages/person-index/PersonIndex.js | 20 +++++--------------- packages/person-index/PersonItem.js | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/packages/person-index/PersonIndex.js b/packages/person-index/PersonIndex.js index 18d478f..d007117 100644 --- a/packages/person-index/PersonIndex.js +++ b/packages/person-index/PersonIndex.js @@ -1,4 +1,4 @@ -import { Component, Grid, Layout, SplitPane } from 'substance' +import { Component, SplitPane } from 'substance' import { concat } from 'lodash-es' class PersonIndex extends Component { @@ -29,6 +29,7 @@ class PersonIndex extends Component { render($$) { let el = $$('div').addClass('sc-persons-index') let Header = this.getComponent('header') + let Spinner = this.getComponent('spinner') el.append($$(Header)) @@ -49,26 +50,15 @@ class PersonIndex extends Component { ) ) } else { - el.append( - $$('div').addClass('se-loader').append( - $$('div').addClass('se-spinner').append( - $$('div').addClass('se-rect1'), - $$('div').addClass('se-rect2'), - $$('div').addClass('se-rect3'), - $$('div').addClass('se-rect4'), - $$('div').addClass('se-rect5') - ), - $$('h2').html( - 'Loading...' - ) - ) - ) + el.append($$(Spinner, {message: 'spinner-loading'})) } return el } renderList($$) { + let Grid = this.getComponent('grid') + let items = this.state.items let total = this.state.total let PersonItem = this.getComponent('person-item') diff --git a/packages/person-index/PersonItem.js b/packages/person-index/PersonItem.js index f9d43bb..ef8ecd2 100644 --- a/packages/person-index/PersonItem.js +++ b/packages/person-index/PersonItem.js @@ -1,4 +1,4 @@ -import { Component, Grid } from 'substance' +import { Component } from 'substance' class PersonItem extends Component { From d283c45e8f30eb7f0ce1d99ab4ed6c54c063d45e Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:03:20 +0300 Subject: [PATCH 17/81] Cleanup. --- packages/scholar/package.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/scholar/package.js b/packages/scholar/package.js index c5cb201..e8011c2 100644 --- a/packages/scholar/package.js +++ b/packages/scholar/package.js @@ -1,21 +1,13 @@ -import { DocumentPackage, PagerPackage, ToolboxPackage } from 'archivist' +import { BasePackage } from 'substance' +import { DocumentPackage, PagerPackage, SpinnerPackage, ToolboxPackage } from 'archivist' export default { name: 'scholar', configure: function(config) { + config.import(BasePackage) config.import(DocumentPackage) - - // config.import(Note); - // config.import(Dashboard); config.import(PagerPackage) + config.import(SpinnerPackage) config.import(ToolboxPackage) - // //config.import(LoaderPackage); - // config.import(NotificationPackage); - // config.import(CollaboratorsPackage); - - - // // Default configuration for available modes - // config.addConfigurator('reader', ReaderConfigurator); - // config.addConfigurator('writer', WriterConfigurator); } } \ No newline at end of file From bf5af9b33837521fb22d492e6c72ad32641a880e Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:03:36 +0300 Subject: [PATCH 18/81] Improve publisher. --- packages/ost-publisher/OstPublisher.js | 25 ++++++++++++++++--- packages/ost-publisher/OstPublisherContext.js | 7 ++++++ packages/ost-publisher/OstPublisherLayout.js | 8 +++--- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/packages/ost-publisher/OstPublisher.js b/packages/ost-publisher/OstPublisher.js index b4e7dca..ef4a8d1 100644 --- a/packages/ost-publisher/OstPublisher.js +++ b/packages/ost-publisher/OstPublisher.js @@ -8,7 +8,8 @@ class OstPublisher extends Publisher { super(...args) this.handleActions({ - 'showTopics': this._showTopics + 'showTopics': this._showTopics, + 'resetBrackets': this._resetBrackets }) } @@ -47,7 +48,6 @@ class OstPublisher extends Publisher { let doc = editorSession.getDocument() let contextPanel = this.refs.contextPanel - //let entityIndex = doc.getIndex('entities') let schema = doc.getSchema() let nodes = schema.nodeRegistry.entries let highlights = {} @@ -90,8 +90,14 @@ class OstPublisher extends Publisher { } } - this.contentHighlights.set(highlights) + let contextState = this.refs.contextPanel.getContextState() + if(contextState.contextId !== 'subjects' || contextState.mode !== 'edit') { + this._resetBrackets() + } else { + highlights['subject'] = this.contentHighlights._highlights.subject + } + this.contentHighlights.set(highlights) } } @@ -146,13 +152,24 @@ class OstPublisher extends Publisher { paragraphs = paragraphs.concat(paras) }) let firstPara = doc.getFirst(paragraphs) - this.refs.contentPanel.scrollTo(firstPara) + this.refs.contentPanel.scrollTo(`[data-id="${firstPara}"]`) setTimeout(function(){ this.refs.brackets.highlight(topics) this.highlightReferences(topics, true) }.bind(this), 10) } + + _resetBrackets(type) { + if(type) { + let highlights = {} + highlights[type] = [] + this.contentHighlights.set(highlights) + } + this.refs.brackets.resetBrackets() + let contextPanel = this.refs.contextPanel + contextPanel.resetSubjectsList() + } } export default OstPublisher diff --git a/packages/ost-publisher/OstPublisherContext.js b/packages/ost-publisher/OstPublisherContext.js index fb4cc86..7723a71 100644 --- a/packages/ost-publisher/OstPublisherContext.js +++ b/packages/ost-publisher/OstPublisherContext.js @@ -17,6 +17,13 @@ class OstPublisherContext extends PublisherContext { console.log('Edit container resource', node.id, ',', mode, 'mode') } + resetSubjectsList() { + let context = 'subjects' + if(this.refs[context]) { + this.refs[context].setSelected() + } + } + } export default OstPublisherContext \ No newline at end of file diff --git a/packages/ost-publisher/OstPublisherLayout.js b/packages/ost-publisher/OstPublisherLayout.js index dfd009c..79c7748 100644 --- a/packages/ost-publisher/OstPublisherLayout.js +++ b/packages/ost-publisher/OstPublisherLayout.js @@ -1,5 +1,5 @@ -import { async, CollabSession, JSONConverter, substanceGlobals } from 'substance' -import { PublisherLayout } from 'archivist' +import { async, JSONConverter, substanceGlobals } from 'substance' +import { PublisherLayout, PublisherSession } from 'archivist' import OstPublisher from './OstPublisher' const {series} = async @@ -25,10 +25,10 @@ class OstPublisherLayout extends PublisherLayout { return } - let document = configurator.createArticle() + let document = configurator.createDocument() let doc = converter.importDocument(document, docRecord.data) - let session = new CollabSession(doc, { + let session = new PublisherSession(doc, { configurator: configurator, documentId: documentId, version: docRecord.version, From f11019c90b1ca13631b2e537f581c4e6f02d6c7b Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:03:48 +0300 Subject: [PATCH 19/81] Improve subjects. --- packages/subject/SubjectReference.js | 12 ++++++++++ packages/subject/package.js | 2 +- .../SubjectsContext.js | 22 +++++++++++++------ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/subject/SubjectReference.js b/packages/subject/SubjectReference.js index 6fe1eb4..335ce7b 100644 --- a/packages/subject/SubjectReference.js +++ b/packages/subject/SubjectReference.js @@ -1,4 +1,5 @@ import { ContainerAnnotation } from 'substance' +import { forEach } from 'lodash-es' /** SubjectReference Node. @@ -32,6 +33,17 @@ class SubjectReference extends ContainerAnnotation { isResourceReference() { return false } + + setHighlighted(highlighted, scope) { + if (this.highlighted !== highlighted) { + this.highlighted = highlighted + this.highlightedScope = scope + this.emit('highlighted', highlighted, scope) + forEach(this.fragments, function(frag) { + frag.emit('highlighted', highlighted, scope) + }) + } + } } SubjectReference.define({ diff --git a/packages/subject/package.js b/packages/subject/package.js index 9b4aaa3..1facbc1 100644 --- a/packages/subject/package.js +++ b/packages/subject/package.js @@ -7,7 +7,7 @@ export default { configure: function(config) { config.addNode(SubjectReference) config.addCommand(SubjectReference.type, SubjectCommand, { nodeType: SubjectReference.type, commandGroup: 'references' }) - config.addComponent('container-annotation-fragment', SubjectComponent) + config.addComponent(SubjectReference.type, SubjectComponent) config.addIcon(SubjectReference.type, {'fontawesome': 'fa-tags'}) config.addLabel('subject', { diff --git a/packages/subjects-editor-context/SubjectsContext.js b/packages/subjects-editor-context/SubjectsContext.js index 94ee7f0..3affbfe 100644 --- a/packages/subjects-editor-context/SubjectsContext.js +++ b/packages/subjects-editor-context/SubjectsContext.js @@ -35,8 +35,6 @@ class SubjectsContext extends Component { return this.renderList($$) } else if (mode === 'edit') { return this.renderSubjectSelector($$) - } else { - //return this.renderItem($$) } } @@ -88,11 +86,13 @@ class SubjectsContext extends Component { } highlightNodes(activeNode) { - let subjects = this.state.subjects + let editorSession = this.context.editorSession + let subjects = editorSession.subjects subjects.resetSelection() let activeNodes = subjects.getAllChildren(activeNode) activeNodes.unshift(activeNode) this.send('showTopics', activeNodes) + this.setSelected(activeNode) } renderChildren($$, node, level) { @@ -114,7 +114,7 @@ class SubjectsContext extends Component { .ref(node.id) .on('click', this.highlightNodes.bind(this, node.id)) - if(node.id === this.props.topic) { + if(this.state.selected === node.id) { el.addClass('sm-active') } @@ -124,10 +124,18 @@ class SubjectsContext extends Component { } } + setSelected(node) { + this.extendState({selected: node}) + // let editorSession = this.context.editorSession + // let subjects = editorSession.subjects + // subjects.set([node, 'selected'], true) + // this.rerender() + } + _showList() { - this.extendProps({ - mode: 'list' - }) + this.send('resetBrackets', 'subject') + this.send('switchContext', {mode: 'list'}) + //this.extendState({selected: undefined}) } } From acdf95619d9bc0d5797feedc66de16d90de40cfb Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:04:20 +0300 Subject: [PATCH 20/81] Fix scroll resources. --- packages/resources-context/ResourcesContext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/resources-context/ResourcesContext.js b/packages/resources-context/ResourcesContext.js index 7764f87..1a2dd7b 100644 --- a/packages/resources-context/ResourcesContext.js +++ b/packages/resources-context/ResourcesContext.js @@ -26,7 +26,7 @@ class ResourcesContext extends Component { didUpdate() { if(this.state.entityId && !this.state.noScroll) { - this.refs.panelEl.scrollTo(this.state.entityId) + this.refs.panelEl.scrollTo(`[data-id="${this.state.entityId}"]`) } } From d2801f7ed5efbc59bebf36535e86e92f954ee2c8 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:04:31 +0300 Subject: [PATCH 21/81] Repair Reader package. --- packages/reader/Reader.js | 46 +++++++++++++++++++++++---------- packages/reader/ReaderLayout.js | 25 ++++++------------ packages/reader/package.js | 11 +++++++- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/packages/reader/Reader.js b/packages/reader/Reader.js index dfbcdd8..aef2bde 100644 --- a/packages/reader/Reader.js +++ b/packages/reader/Reader.js @@ -1,7 +1,10 @@ -import { ContainerEditor, Highlights, Layout, ProseEditor, SplitPane, TextPropertyEditor } from 'substance' -import { forEach, map, orderBy, uniq } from 'lodash-es' +import { ProseEditorPackage } from 'substance' +import { ContainerEditor, Highlights, Layout, SplitPane, TextPropertyEditor } from 'substance' +import { forEach, map, uniq } from 'lodash-es' import ReaderContext from './ReaderContext' +const { ProseEditor } = ProseEditorPackage + class Reader extends ProseEditor { constructor(...args) { super(...args) @@ -19,10 +22,12 @@ class Reader extends ProseEditor { let parent = this.getParent() let entityId = parent.props.entityId if(entityId) { - this._showReferences(entityId, true) + setTimeout(() => { + this._showReferences(entityId, true) + }, 10) } if(parent.props.fragment) { - this.refs.contentPanel.scrollTo(parent.props.fragment) + this.refs.contentPanel.scrollTo(`[data-id="${parent.props.fragment}"]`) } } @@ -81,13 +86,15 @@ class Reader extends ProseEditor { disabled: true }).addClass('se-title'), $$(ContainerEditor, { - disabled: 'true', + disabled: true, editorSession: this.editorSession, node: doc.get('body'), - commands: configurator.getSurfaceCommandNames(), - textTypes: configurator.getTextTypes() + commands: configurator.getSurfaceCommandNames() }).ref('body'), - $$(Overlay) + $$(Overlay, { + toolPanel: configurator.getToolPanel('main-overlay'), + theme: 'dark' + }) ) contentPanel.append(layout) @@ -134,12 +141,25 @@ class Reader extends ProseEditor { let doc = editorSession.getDocument() let entityIndex = doc.getIndex('entities') let refs = entityIndex.get(entityId) - let ordered = orderBy(refs, ref => { - let p = ref.path[0] - return container.getPosition(p) + // We are sorting references by paregraph position + // if nodes annotations are in same paragraph + // we will sort them by start offset + let refIds = Object.keys(refs) + let ordered = refIds.sort((a,b) => { + const refAPath = refs[a].getPath() + const refBPath = refs[b].getPath() + + if (refAPath[0] !== refBPath[0]){ + return (container.getPosition(refAPath[0]) - container.getPosition(refBPath[0])) + } else { + const refAOffset = refs[a].start.getOffset() + const refBOffset = refs[b].start.getOffset() + + return (refAOffset - refBOffset) + } }) - this.refs.contentPanel.scrollTo(ordered[0].id) + this.refs.contentPanel.scrollTo(`[data-id="${ordered[0]}"]`) this.highlightReferences([entityId]) if(!silent) { @@ -159,7 +179,7 @@ class Reader extends ProseEditor { paragraphs = paragraphs.concat(paras) }) let firstPara = doc.getFirst(paragraphs) - this.refs.contentPanel.scrollTo(firstPara) + this.refs.contentPanel.scrollTo(`[data-id="${firstPara}"]`) setTimeout(function(){ this.refs.brackets.highlight(topics) diff --git a/packages/reader/ReaderLayout.js b/packages/reader/ReaderLayout.js index d8c51af..a64a56e 100644 --- a/packages/reader/ReaderLayout.js +++ b/packages/reader/ReaderLayout.js @@ -1,6 +1,7 @@ -import { Component, EditorSession, JSONConverter, Layout, series } from 'substance' +import { async, Component, EditorSession, JSONConverter } from 'substance' import Reader from './Reader' +const {series} = async let converter = new JSONConverter() class ReaderLayout extends Component { @@ -35,9 +36,7 @@ class ReaderLayout extends Component { } if (newProps.entityId !== this.props.entityId && newProps.entityId !== undefined) { - setTimeout(function(){ - this.refs.reader.highlightReferences([newProps.entityId]) - }.bind(this), 10) + this.refs.reader.highlightReferences([newProps.entityId]) } } @@ -50,24 +49,16 @@ class ReaderLayout extends Component { } render($$) { + let Layout = this.getComponent('layout') + let Spinner = this.getComponent('spinner') + let el = $$('div').addClass('sc-read-document') let Header = this.getComponent('header') el.append($$(Header)) let main = $$(Layout, { width: 'medium', textAlign: 'center' - }).append( - $$('div').addClass('se-spinner').append( - $$('div').addClass('se-rect1'), - $$('div').addClass('se-rect2'), - $$('div').addClass('se-rect3'), - $$('div').addClass('se-rect4'), - $$('div').addClass('se-rect5') - ), - $$('h2').html( - 'Loading...' - ) - ) + }).append($$(Spinner, {message: 'spinner-loading'})) this._updateLayout() @@ -107,7 +98,7 @@ class ReaderLayout extends Component { return } //let docRecord = SampleDoc - let document = configurator.createArticle() + let document = configurator.createDocument() let doc = converter.importDocument(document, docRecord.data) let session = new EditorSession(doc, { diff --git a/packages/reader/package.js b/packages/reader/package.js index 4c045f8..b74b147 100644 --- a/packages/reader/package.js +++ b/packages/reader/package.js @@ -1,3 +1,4 @@ +import { ContainerAnnotationPackage } from 'substance' import { BracketsPackage, TabbedContextPackage } from 'archivist' import ReaderLayout from './ReaderLayout' @@ -7,6 +8,14 @@ export default { config.import(BracketsPackage) config.import(TabbedContextPackage) config.addComponent('reader', ReaderLayout) - config.addToolGroup('references') + + config.import(ContainerAnnotationPackage) + config.addToolPanel('main-overlay', [ + { + name: 'prompt', + type: 'tool-group', + commandGroups: ['prompt'] + } + ]) } } \ No newline at end of file From 2253d07495e04a0ec1cb6e4236c6976424e5882a Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:04:53 +0300 Subject: [PATCH 22/81] Repair scholar client package. --- client/scholar/package.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/scholar/package.js b/client/scholar/package.js index fdb0359..7a7d9a3 100644 --- a/client/scholar/package.js +++ b/client/scholar/package.js @@ -1,4 +1,4 @@ -import { ProseArticle } from 'substance' +import { ProseEditorPackage } from 'substance' import ScholarPackage from '../../packages/scholar/package' import HeaderPackage from '../../packages/header/package' import ExplorerPackage from '../../packages/explorer/package' @@ -21,6 +21,8 @@ import Person from '../../packages/person/Person' import Prison from '../../packages/prison/Prison' import Toponym from '../../packages/toponym/Toponym' +const { ProseArticle } = ProseEditorPackage + let appConfig = 'ARCHIVISTCONFIG' appConfig = JSON.parse(appConfig) @@ -57,7 +59,7 @@ export default { let EntitiesConfigurator = new ScholarSubConfigurator() EntitiesConfigurator.defineSchema({ name: 'archivist-entities', - ArticleClass: ProseArticle + DocumentClass: ProseArticle }) EntitiesConfigurator.addNode(Definition) EntitiesConfigurator.addNode(Person) From c5e67ddf3cd001a15b47e40c36581fed7b33e2af Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Thu, 10 Aug 2017 17:05:10 +0300 Subject: [PATCH 23/81] Improve html containers. --- client/publisher/index.html | 6 ++---- client/publisher/index.production.html | 20 +++++++++----------- client/scholar/index.html | 19 ++++++++----------- client/scholar/index.production.html | 20 ++++++++------------ 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/client/publisher/index.html b/client/publisher/index.html index 9855c37..a5b3a50 100644 --- a/client/publisher/index.html +++ b/client/publisher/index.html @@ -6,14 +6,12 @@ diff --git a/client/publisher/index.production.html b/client/publisher/index.production.html index db881fb..9d780e7 100644 --- a/client/publisher/index.production.html +++ b/client/publisher/index.production.html @@ -2,19 +2,17 @@ OST Publisher - - - + + + diff --git a/client/scholar/index.html b/client/scholar/index.html index 73394fe..51e3677 100644 --- a/client/scholar/index.html +++ b/client/scholar/index.html @@ -2,21 +2,18 @@ Archivist Scholar - - + + - + diff --git a/client/scholar/index.production.html b/client/scholar/index.production.html index ba3de95..1933fa5 100644 --- a/client/scholar/index.production.html +++ b/client/scholar/index.production.html @@ -17,22 +17,18 @@ - - + + - + - From 218726c5ecf56a4aa5906ed322d6f17ae2f0c2b1 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 12 Aug 2017 01:05:01 +0300 Subject: [PATCH 24/81] Update eslint config. --- .eslintrc.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7bb3185..48c2cc5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,21 +1,29 @@ module.exports = { - "env": { - "browser": true, - "commonjs": true, - "node": true - }, "parserOptions": { "sourceType": "module", - "ecmaVersion": 6 + "ecmaVersion": 6, + "ecmaFeatures": { + "jsxnec": true, + }, }, "extends": "eslint:recommended", - "globals": { - "Promise": true - }, + "globals": [ + // browser + "window", "document", "URL", "XMLHttpRequest", + // browser / nodejs + "console", "setTimeout", "setInterval", "clearInterval", + // nodejs + "global", + // EcmaScript 6 + "Promise", "Map", "Set", "WeakMap", + // commonjs + "require", "module", "exports" + // + ].reduce((m, key)=>{m[key]=true;return m}, {}), "rules": { // 0 - off, 1 - warning, 2 - error "indent": ["error", 2, { "SwitchCase": 1 }], - "semi": [0, "never"], + "semi": [0, "always"], "comma-dangle": [2, "only-multiline"], "no-cond-assign": 2, "no-console": [2, { allow: ["warn", "info", "error", "assert"] }], @@ -40,6 +48,7 @@ module.exports = { // turned of as we want to be able to use this.hasOwnProperty() for instance "no-prototype-builtins": 0, "no-regex-spaces": 2, + "no-restricted-globals": [2, "Document", "Node"], "no-sparse-arrays": 0, "no-unexpected-multiline": 2, "no-unreachable": 2, @@ -47,7 +56,7 @@ module.exports = { "use-isnan": 2, "valid-jsdoc": 0, "valid-typeof": 2, - "strict": 0, // [2, "safe"], + "strict": [2, "safe"], // Best practices "accessor-pairs": 0, @@ -126,6 +135,6 @@ module.exports = { "no-undef-init": 2, "no-undefined": 0, "no-unused-vars": 2, - "no-use-before-define": [2, { "functions": false }] + "no-use-before-define": [2, { "functions": false, "classes": false }] } }; \ No newline at end of file From 9657bb51722d3153a5658b558550724ae2d4935a Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 12 Aug 2017 01:05:22 +0300 Subject: [PATCH 25/81] Keep collaborators inside document record. --- db/reset.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/reset.sql b/db/reset.sql index 4cae5c2..681d157 100644 --- a/db/reset.sql +++ b/db/reset.sql @@ -83,6 +83,7 @@ CREATE TABLE "documents" ( title text, language text, annotations text[], + collaborators text[], "references" jsonb, "fullText" text, "updatedAt" timestamp, From a4ccd276d7389ec732ee8c266fc1866779c4d8ab Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 12 Aug 2017 17:13:25 +0300 Subject: [PATCH 26/81] Improve collaborators support. --- client/publisher/ResourceClient.js | 24 ++++++++++++++++---- packages/ost-publisher/OstPublisher.js | 4 ++++ packages/ost-publisher/OstPublisherLayout.js | 3 ++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/client/publisher/ResourceClient.js b/client/publisher/ResourceClient.js index 596054f..6ebc6de 100644 --- a/client/publisher/ResourceClient.js +++ b/client/publisher/ResourceClient.js @@ -82,27 +82,41 @@ class ResourceClient { listEntities(filters, options, cb) { let filtersRequest = encodeURIComponent(JSON.stringify(filters)) let optionsRequest = encodeURIComponent(JSON.stringify(options)) - request('GET', '/api/entities?filters=' + filtersRequest + '&options=' + optionsRequest, null, cb) + this.request('GET', '/api/entities?filters=' + filtersRequest + '&options=' + optionsRequest, null, cb) } searchEntities(query, language, filters, options, cb) { let filtersRequest = encodeURIComponent(JSON.stringify(filters)) let optionsRequest = encodeURIComponent(JSON.stringify(options)) - request('GET', '/api/entities/search?query=' + query + '&language=' + language + '&filters=' + filtersRequest + '&options=' + optionsRequest, null, cb) + this.request('GET', '/api/entities/search?query=' + query + '&language=' + language + '&filters=' + filtersRequest + '&options=' + optionsRequest, null, cb) } /* - Read all document resources + Fetch all document resources + */ + getDocumentCollaborators(documentId, cb) { + this.request('GET', '/api/collaborators/document/' + documentId, null, cb) + } + + /* + Fetch all document resources */ getDocumentResources(documentId, cb) { - request('GET', '/api/entities/document/' + documentId, null, cb) + this.request('GET', '/api/entities/document/' + documentId, null, cb) } /* Get subjects data */ getSubjects(cb) { - request('GET', '/api/entities/tree/subject', null, cb) + this.request('GET', '/api/entities/tree/subject', null, cb) + } + + /* + Get collaborator data + */ + getCollaborator(userId, cb) { + this.request('GET', '/api/collaborators/' + userId, null, cb) } } diff --git a/packages/ost-publisher/OstPublisher.js b/packages/ost-publisher/OstPublisher.js index ef4a8d1..cf8dc15 100644 --- a/packages/ost-publisher/OstPublisher.js +++ b/packages/ost-publisher/OstPublisher.js @@ -40,6 +40,10 @@ class OstPublisher extends Publisher { }.bind(this)) } }) + + // If there is no collaborator data we should add it + let author = change.info.userId + if(author) this._addCollaborator(author) } // TODO: figure out why selection flags changed after comment update diff --git a/packages/ost-publisher/OstPublisherLayout.js b/packages/ost-publisher/OstPublisherLayout.js index 79c7748..faea705 100644 --- a/packages/ost-publisher/OstPublisherLayout.js +++ b/packages/ost-publisher/OstPublisherLayout.js @@ -46,7 +46,8 @@ class OstPublisherLayout extends PublisherLayout { series([ this._loadResources(documentId, session), - this._loadSubjects(session) + this._loadSubjects(session), + this._loadCollaborators(documentId, session) ], () => { this.setState({ session: session From 92a78b82d8419344da0b5d5f0f07b9be75837676 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 12 Aug 2017 23:06:24 +0300 Subject: [PATCH 27/81] Fix prison context item position. --- packages/prison/_index.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/prison/_index.css b/packages/prison/_index.css index fbb31ad..35869e4 100644 --- a/packages/prison/_index.css +++ b/packages/prison/_index.css @@ -31,11 +31,15 @@ } .se-entity-entries .sc-entity-entry.se-prison .se-title { - margin-top: 30px; + margin-top: 0px; margin-bottom: 10px; margin-right: 60px; } +.sc-reader .se-entity-entries .sc-entity-entry.se-prison .se-title { + margin-top: 30px; +} + .sc-entity-entry.se-prison .se-prison-type { position: absolute; left: 20px; From 7d809fd4ea722df0811a38c01d10da57a8df0086 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 14 Aug 2017 19:03:24 +0300 Subject: [PATCH 28/81] Set schemas version. --- packages/interview/package.js | 1 + packages/subjects/package.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/interview/package.js b/packages/interview/package.js index 4c666a0..2fee7c6 100644 --- a/packages/interview/package.js +++ b/packages/interview/package.js @@ -16,6 +16,7 @@ export default { configure: function(config) { config.defineSchema({ name: 'archivist-interview', + version: '1.0.0', DocumentClass: Interview, defaultTextType: 'paragraph' }) diff --git a/packages/subjects/package.js b/packages/subjects/package.js index f2fa6c6..ccee7d2 100644 --- a/packages/subjects/package.js +++ b/packages/subjects/package.js @@ -8,6 +8,7 @@ export default { configure: function(config) { config.defineSchema({ name: 'archivist-subjects', + version: '1.0.0', DocumentClass: Subjects, defaultTextType: 'subject' }) From 8a753310fef707cda10da3972acda94c33906580 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 14 Aug 2017 19:06:34 +0300 Subject: [PATCH 29/81] Expose active collaborators. --- packages/ost-publisher/package.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ost-publisher/package.js b/packages/ost-publisher/package.js index 9d44da3..7ce1465 100644 --- a/packages/ost-publisher/package.js +++ b/packages/ost-publisher/package.js @@ -1,11 +1,12 @@ import OstPublisherLayout from './OstPublisherLayout' -import { BracketsPackage, TabbedContextPackage } from 'archivist' +import { BracketsPackage, CollaboratorsPackage, TabbedContextPackage } from 'archivist' import { ContainerAnnotationPackage, FindAndReplacePackage } from 'substance' export default { name: 'ost-publisher', configure: function(config) { config.import(BracketsPackage) + config.import(CollaboratorsPackage) config.import(TabbedContextPackage) config.addComponent('editor', OstPublisherLayout) From e4442403e441daa6e2caea7f522f8a8d0e8dd620 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 14 Aug 2017 19:06:52 +0300 Subject: [PATCH 30/81] Connect collaboration engine. --- packages/engine/package.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/engine/package.js b/packages/engine/package.js index a693308..7833aee 100644 --- a/packages/engine/package.js +++ b/packages/engine/package.js @@ -6,6 +6,7 @@ module.exports = { config.import(ArchivistStorePackage); config.import(require('./mailer/package')) config.import(require('archivist').AuthEnginePackage) + config.import(require('archivist').CollabEnginePackage) config.import(require('archivist').SnapshotEnginePackage) config.import(require('./document/package')) config.import(require('./resource/package')) From 6cdffc40b2cdbc9c3dc1ffd666ae82f2f1180a4e Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 14 Aug 2017 19:07:12 +0300 Subject: [PATCH 31/81] Reset resource view on filter changes. --- packages/explorer/Explorer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/explorer/Explorer.js b/packages/explorer/Explorer.js index 379651b..56d4405 100644 --- a/packages/explorer/Explorer.js +++ b/packages/explorer/Explorer.js @@ -447,7 +447,8 @@ class Explorer extends Component { if(op === ' ~~') metaFilter[prop] = '%' + value + '%' this.extendState({ filters: extend({}, filters, metaFilter), - metaFilters: metaFilters + metaFilters: metaFilters, + resource: false }) } @@ -463,7 +464,8 @@ class Explorer extends Component { metaFilters[id] = value this.extendState({ filters: extend({}, filters, metaFilter), - metaFilters: metaFilters + metaFilters: metaFilters, + resource: false }) } @@ -478,7 +480,8 @@ class Explorer extends Component { if(filterKey2) delete filters[filterKeys[filterKey2]] this.extendState({ filters: extend({}, filters), - metaFilters: metaFilters + metaFilters: metaFilters, + resource: false }) } @@ -495,7 +498,8 @@ class Explorer extends Component { }) this.extendState({ filters: extend({}, filters), - metaFilters: metaFilters + metaFilters: metaFilters, + resource: false }) } From 6898bc529f284a32debd459ae6e8fb9b8f99d1be Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Fri, 18 Aug 2017 12:05:13 +0300 Subject: [PATCH 32/81] Context item view mode. --- packages/definition/DefinitionContextItem.js | 15 ++++++++------- packages/person/PersonContextItem.js | 15 ++++++++------- packages/prison/PrisonContextItem.js | 15 ++++++++------- packages/toponym/ToponymContextItem.js | 15 ++++++++------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/packages/definition/DefinitionContextItem.js b/packages/definition/DefinitionContextItem.js index 1c732cb..ab0539b 100644 --- a/packages/definition/DefinitionContextItem.js +++ b/packages/definition/DefinitionContextItem.js @@ -17,10 +17,6 @@ class DefinitionContextItem extends Component { let el = $$('div') .attr("data-id", this.props.entityId) .addClass('sc-entity-entry se-definition') - - if(this.props.mode !== 'view') { - el.on('click', this.handleEditorClick) - } if(this.props.focus) { el.addClass('se-focused') @@ -29,11 +25,16 @@ class DefinitionContextItem extends Component { el.append( $$('div').addClass('se-type').append(this.getLabel('definition')), $$('div').addClass('se-title').append(node.name), - $$('div').addClass('se-description').setInnerHTML(node.description), - $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) - .on('click', this.editEntity) + $$('div').addClass('se-description').setInnerHTML(node.description) ) + if(this.props.mode !== 'view') { + el.append( + $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) + .on('click', this.editEntity) + ).on('click', this.handleEditorClick) + } + return el } diff --git a/packages/person/PersonContextItem.js b/packages/person/PersonContextItem.js index 7889a68..77b16b0 100644 --- a/packages/person/PersonContextItem.js +++ b/packages/person/PersonContextItem.js @@ -18,10 +18,6 @@ class PersonContextItem extends Component { .attr("data-id", this.props.entityId) .addClass('sc-entity-entry se-person') - if(this.props.mode !== 'view') { - el.on('click', this.handleEditorClick) - } - if(this.props.focus) { el.addClass('se-focused') } @@ -29,11 +25,16 @@ class PersonContextItem extends Component { el.append( $$('div').addClass('se-type').append(this.getLabel('person')), $$('div').addClass('se-title').append(node.name), - $$('div').addClass('se-description').setInnerHTML(node.description), - $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) - .on('click', this.editEntity) + $$('div').addClass('se-description').setInnerHTML(node.description) ) + if(this.props.mode !== 'view') { + el.append( + $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) + .on('click', this.editEntity) + ).on('click', this.handleEditorClick) + } + return el } diff --git a/packages/prison/PrisonContextItem.js b/packages/prison/PrisonContextItem.js index f3ca732..96fd759 100644 --- a/packages/prison/PrisonContextItem.js +++ b/packages/prison/PrisonContextItem.js @@ -17,10 +17,6 @@ class PrisonContextItem extends Component { let el = $$('div') .attr("data-id", this.props.entityId) .addClass('sc-entity-entry se-prison') - - if(this.props.mode !== 'view') { - el.on('click', this.handleEditorClick) - } if(this.props.focus) { el.addClass('se-focused') @@ -29,11 +25,16 @@ class PrisonContextItem extends Component { el.append( $$('div').addClass('se-type').append(this.getLabel('prison')), $$('div').addClass('se-title').append(node.name), - $$('div').addClass('se-description').setInnerHTML(node.description), - $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) - .on('click', this.editEntity) + $$('div').addClass('se-description').setInnerHTML(node.description) ) + if(this.props.mode !== 'view') { + el.append( + $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) + .on('click', this.editEntity) + ).on('click', this.handleEditorClick) + } + return el } diff --git a/packages/toponym/ToponymContextItem.js b/packages/toponym/ToponymContextItem.js index 24d2689..6482344 100644 --- a/packages/toponym/ToponymContextItem.js +++ b/packages/toponym/ToponymContextItem.js @@ -17,10 +17,6 @@ class ToponymContextItem extends Component { let el = $$('div') .attr("data-id", this.props.entityId) .addClass('sc-entity-entry se-toponym') - - if(this.props.mode !== 'view') { - el.on('click', this.handleEditorClick) - } if(this.props.focus) { el.addClass('se-focused') @@ -29,11 +25,16 @@ class ToponymContextItem extends Component { el.append( $$('div').addClass('se-type').append(this.getLabel('toponym')), $$('div').addClass('se-title').append(node.name), - $$('div').addClass('se-description').setInnerHTML(node.description), - $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) - .on('click', this.editEntity) + $$('div').addClass('se-description').setInnerHTML(node.description) ) + if(this.props.mode !== 'view') { + el.append( + $$('div').addClass('se-edit-entity').append(this.context.iconProvider.renderIcon($$, 'editEntity')) + .on('click', this.editEntity) + ).on('click', this.handleEditorClick) + } + return el } From 883e6c79d3865f22b488d40205b5cec3cc621ce6 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Fri, 18 Aug 2017 12:06:00 +0300 Subject: [PATCH 33/81] Small fixes. --- client/publisher/index.production.html | 1 - client/publisher/package.js | 1 + client/scholar/app.css | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/client/publisher/index.production.html b/client/publisher/index.production.html index 9d780e7..6a0be27 100644 --- a/client/publisher/index.production.html +++ b/client/publisher/index.production.html @@ -13,7 +13,6 @@ @import url('/libs/font-awesome/css/font-awesome.min.css'); @import './publisher.css'; - diff --git a/client/publisher/package.js b/client/publisher/package.js index e4d6b13..4c2c562 100644 --- a/client/publisher/package.js +++ b/client/publisher/package.js @@ -74,6 +74,7 @@ export default { let EntitiesConfigurator = new ArchivistSubConfigurator() EntitiesConfigurator.defineSchema({ name: 'archivist-entities', + version: '1.0.0', DocumentClass: ProseArticle }) EntitiesConfigurator.addNode(Definition) diff --git a/client/scholar/app.css b/client/scholar/app.css index fe28e96..94092b4 100644 --- a/client/scholar/app.css +++ b/client/scholar/app.css @@ -1,5 +1,4 @@ /* Scholar styles */ -@import '../../node_modules/substance/dist/substance.next.css'; @import '../../node_modules/plyr/dist/plyr.css'; @import '../../node_modules/leaflet/dist/leaflet.css'; @import '../../node_modules/leaflet.markercluster/dist/MarkerCluster.css'; From 83b73ea82cd2aebaab38cbefbe48b24d1a5db569 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Fri, 18 Aug 2017 12:06:13 +0300 Subject: [PATCH 34/81] Update deps. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5642745..b8be8b0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "", "main": "dist/ost.cjs.js", "dependencies": { - "archivist": "archivist/archivist#960984b6073e0b825ac618a2d3b4bde4ddee65ab", + "archivist": "archivist/archivist#f928b644bb97cdfa1196ba4ebd617d8281712943", "bluebird": "^3.4.7", "body-parser": "^1.15.2", "config": "^1.21.0", @@ -15,7 +15,7 @@ "massive": "^2.5.0", "moment": "^2.17.1", "plyr": "^2.0.11", - "substance": "substance/substance#d0f842bdf54ee982394fab2a93e0aa40fbc78b93", + "substance": "substance/substance#8e210712637bd59c9e3da5d1de6bb46a82af6728", "ws": "^1.1.1" }, "devDependencies": { @@ -35,5 +35,5 @@ "test": "gulp test" }, "license": "GPL-3.0", - "version": "2.0.0-alpha.1" + "version": "1.0.0-alpha.1" } From f0597dc4fa1c8ef2769330a68744195e227adfda Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Fri, 18 Aug 2017 23:42:17 +0300 Subject: [PATCH 35/81] Update libraries versions. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b8be8b0..b653de7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "", "main": "dist/ost.cjs.js", "dependencies": { - "archivist": "archivist/archivist#f928b644bb97cdfa1196ba4ebd617d8281712943", + "archivist": "archivist/archivist#3040a12f13e5757a0a1f5272f12c1b7bef4ab7d9", "bluebird": "^3.4.7", "body-parser": "^1.15.2", "config": "^1.21.0", @@ -15,7 +15,7 @@ "massive": "^2.5.0", "moment": "^2.17.1", "plyr": "^2.0.11", - "substance": "substance/substance#8e210712637bd59c9e3da5d1de6bb46a82af6728", + "substance": "substance/substance#f975ffe9a724aa0a31d846fceb741d3171845290", "ws": "^1.1.1" }, "devDependencies": { From 2a17c5942fcb68a3c5be32928a3b045c321642fc Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 19 Aug 2017 16:24:33 +0300 Subject: [PATCH 36/81] Update archivist. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b653de7..f68864e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "", "main": "dist/ost.cjs.js", "dependencies": { - "archivist": "archivist/archivist#3040a12f13e5757a0a1f5272f12c1b7bef4ab7d9", + "archivist": "archivist/archivist#d2b47de9113582ef8120b441d6717829185a562f", "bluebird": "^3.4.7", "body-parser": "^1.15.2", "config": "^1.21.0", From 7fab9fdcf8fce42abdcc458bdc54b1a5f5147705 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sun, 20 Aug 2017 22:48:26 +0300 Subject: [PATCH 37/81] Improve translations. --- client/publisher/package.js | 14 +++++++------- package.json | 2 +- packages/definition-manager/package.js | 4 ++++ packages/entity-reference/package.js | 4 ++-- packages/interview/package.js | 22 +++++++++++++++++++++- packages/ost-publisher/package.js | 2 +- packages/person-manager/package.js | 4 ++++ packages/prison-manager/package.js | 4 ++++ packages/subject-manager/package.js | 5 ++++- packages/subject/package.js | 4 ++-- packages/toponym-manager/package.js | 4 ++++ 11 files changed, 54 insertions(+), 15 deletions(-) diff --git a/client/publisher/package.js b/client/publisher/package.js index 4c2c562..27360b3 100644 --- a/client/publisher/package.js +++ b/client/publisher/package.js @@ -110,13 +110,13 @@ export default { config.setResourceClient(ResourceClient) config.setMenuItems([ - {icon: 'fa-file-text', label: 'Documents', action: 'archive'}, - {icon: 'fa-tags', label: 'Subjects', action: 'subjects'}, - {icon: 'fa-users', label: 'Persons', action: 'persons'}, - {icon: 'fa-th', label: 'Prisons', action: 'prisons'}, - {icon: 'fa-globe', label: 'Toponyms', action: 'toponyms'}, - {icon: 'fa-book', label: 'Definitions', action: 'definitions'}, - {icon: 'fa-id-badge', label: 'Users', action: 'users'} + {icon: 'fa-file-text', label: 'documents', action: 'archive'}, + {icon: 'fa-tags', label: 'subjects', action: 'subjects'}, + {icon: 'fa-users', label: 'persons', action: 'persons'}, + {icon: 'fa-th', label: 'prisons', action: 'prisons'}, + {icon: 'fa-globe', label: 'toponyms', action: 'toponyms'}, + {icon: 'fa-book', label: 'definitions', action: 'definitions'}, + {icon: 'fa-id-badge', label: 'users', action: 'users'} ]) config.setDefaultResourceTypes(['definition', 'person', 'prison', 'toponym']) diff --git a/package.json b/package.json index f68864e..9f75216 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "", "main": "dist/ost.cjs.js", "dependencies": { - "archivist": "archivist/archivist#d2b47de9113582ef8120b441d6717829185a562f", + "archivist": "archivist/archivist#5f2caa75cba16ff6c0dca7b00c882ef6fc805b15", "bluebird": "^3.4.7", "body-parser": "^1.15.2", "config": "^1.21.0", diff --git a/packages/definition-manager/package.js b/packages/definition-manager/package.js index b311fac..3ee115a 100644 --- a/packages/definition-manager/package.js +++ b/packages/definition-manager/package.js @@ -4,5 +4,9 @@ export default { name: 'definition-manager', configure: function(config) { config.addPage(DefinitionsPage.pageName, DefinitionsPage) + config.addLabel('definitions', { + en: 'Definitions', + ru: 'Дефиниции' + }) } } \ No newline at end of file diff --git a/packages/entity-reference/package.js b/packages/entity-reference/package.js index 8c859ef..e3d953f 100644 --- a/packages/entity-reference/package.js +++ b/packages/entity-reference/package.js @@ -6,8 +6,8 @@ export default { config.addCommand('entity-reference', EntityReferenceCommand, { nodeType: 'entity-reference', commandGroup: 'references' }) config.addIcon('entity-reference', {'fontawesome': 'fa-book'}) config.addLabel('entity-reference', { - en: 'Entity reference', - ru: 'Связать с сущностью' + en: 'entity reference', + ru: 'связать с сущностью' }) config.addKeyboardShortcut('CommandOrControl+E', { command: 'entity-reference' }) diff --git a/packages/interview/package.js b/packages/interview/package.js index 2fee7c6..dac1c44 100644 --- a/packages/interview/package.js +++ b/packages/interview/package.js @@ -25,7 +25,6 @@ export default { // Import Substance Core packages config.import(BasePackage) - config.import(PersistencePackage) config.import(ParagraphPackage) config.import(HeadingPackage) config.import(BlockquotePackage) @@ -42,5 +41,26 @@ export default { config.import(PrisonPackage) config.import(ToponymPackage) config.import(EntityReferencePackage) + + config.addLabel('undo', { + en: 'undo', + ru: 'отмена' + }) + config.addLabel('redo', { + en: 'redo', + ru: 'вернуть' + }) + config.addLabel('strong', { + en: 'strong', + ru: 'жирный' + }) + config.addLabel('emphasis', { + en: 'emphasis', + ru: 'наклонный' + }) + config.addLabel('link', { + en: 'link', + ru: 'ссылка' + }) } } \ No newline at end of file diff --git a/packages/ost-publisher/package.js b/packages/ost-publisher/package.js index 7ce1465..98588d9 100644 --- a/packages/ost-publisher/package.js +++ b/packages/ost-publisher/package.js @@ -39,7 +39,7 @@ export default { type: 'tool-group', showDisabled: true, style: 'minimal', - commandGroups: ['undo-redo', 'persistence'] + commandGroups: ['undo-redo'] }, { name: 'annotations', diff --git a/packages/person-manager/package.js b/packages/person-manager/package.js index 8491938..af9855e 100644 --- a/packages/person-manager/package.js +++ b/packages/person-manager/package.js @@ -4,5 +4,9 @@ export default { name: 'person-manager', configure: function(config) { config.addPage(PersonsPage.pageName, PersonsPage) + config.addLabel('persons', { + en: 'Persons', + ru: 'Персоналии' + }) } } \ No newline at end of file diff --git a/packages/prison-manager/package.js b/packages/prison-manager/package.js index c875154..f2bea76 100644 --- a/packages/prison-manager/package.js +++ b/packages/prison-manager/package.js @@ -4,5 +4,9 @@ export default { name: 'prison-manager', configure: function(config) { config.addPage(PrisonsPage.pageName, PrisonsPage) + config.addLabel('Prisons', { + en: 'Prisons', + ru: 'Места заключения' + }) } } \ No newline at end of file diff --git a/packages/subject-manager/package.js b/packages/subject-manager/package.js index c33f7b9..d81013e 100644 --- a/packages/subject-manager/package.js +++ b/packages/subject-manager/package.js @@ -4,9 +4,12 @@ export default { name: 'subject-manager', configure: function(config) { config.addPage(SubjectsPage.pageName, SubjectsPage) - config.addIcon('collapsed', { 'fontawesome': 'fa-caret-right' }) config.addIcon('expanded', { 'fontawesome': 'fa-caret-down' }) config.addIcon('dnd', { 'fontawesome': 'fa-arrows' }) + config.addLabel('subjects', { + en: 'Subjects', + ru: 'Темы' + }) } } \ No newline at end of file diff --git a/packages/subject/package.js b/packages/subject/package.js index 1facbc1..c7f384e 100644 --- a/packages/subject/package.js +++ b/packages/subject/package.js @@ -11,8 +11,8 @@ export default { config.addIcon(SubjectReference.type, {'fontawesome': 'fa-tags'}) config.addLabel('subject', { - en: 'Subject reference', - ru: 'Связать с рубрикой' + en: 'subject reference', + ru: 'связать с рубрикой' }) } } \ No newline at end of file diff --git a/packages/toponym-manager/package.js b/packages/toponym-manager/package.js index 6af38a2..4a64488 100644 --- a/packages/toponym-manager/package.js +++ b/packages/toponym-manager/package.js @@ -4,5 +4,9 @@ export default { name: 'toponym-manager', configure: function(config) { config.addPage(ToponymsPage.pageName, ToponymsPage) + config.addLabel('toponyms', { + en: 'Toponyms', + ru: 'Топонимы' + }) } } \ No newline at end of file From f69ecc4ec331f23f0b2f45a2f63529cca355dded Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 21 Aug 2017 00:22:25 +0300 Subject: [PATCH 38/81] Set minimum width. --- packages/ost-publisher/_index.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/ost-publisher/_index.css b/packages/ost-publisher/_index.css index e69de29..6cc62d4 100644 --- a/packages/ost-publisher/_index.css +++ b/packages/ost-publisher/_index.css @@ -0,0 +1,3 @@ +.sc-publisher .se-context-section { + min-width: 480px; +} \ No newline at end of file From 379a6f4f4b44ba12bee64158eff7cb5d28b95ba4 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Mon, 21 Aug 2017 00:22:34 +0300 Subject: [PATCH 39/81] Set language. --- client/publisher/package.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/publisher/package.js b/client/publisher/package.js index 27360b3..013db78 100644 --- a/client/publisher/package.js +++ b/client/publisher/package.js @@ -31,6 +31,7 @@ export default { name: 'archivist-publisher', configure: function(config) { // Use the default Archivist package + config.setDefaultLanguage(appConfig.defaultLanguage) config.import(ArchivistPackage) config.import(DocumentsPackage) // Override Archivist form package From 4a5b3a88555060a5b4e02ad7ffe043f9e24b7c15 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 9 Sep 2017 13:49:21 +0300 Subject: [PATCH 40/81] Keep scholar poly fills together. --- client/scholar/assets/multirange.js | 94 ----------------------------- client/scholar/assets/polyfills.js | 1 + 2 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 client/scholar/assets/multirange.js create mode 100644 client/scholar/assets/polyfills.js diff --git a/client/scholar/assets/multirange.js b/client/scholar/assets/multirange.js deleted file mode 100644 index cbac586..0000000 --- a/client/scholar/assets/multirange.js +++ /dev/null @@ -1,94 +0,0 @@ -(function() { - "use strict"; - - var supportsMultiple = self.HTMLInputElement && "valueLow" in HTMLInputElement.prototype; - - var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value"); - - self.multirange = function(input) { - if (supportsMultiple || input.classList.contains("multirange")) { - return; - } - - var values = input.getAttribute("value").split(","); - var min = +input.min || 0; - var max = +input.max || 100; - var ghost = input.cloneNode(); - ghost.onchange = function() { - var event = document.createEvent('Event'); - event.initEvent('change', true, true); - input.addEventListener('change', function (e) { - }, false); - input.dispatchEvent(event); - } - ghost.oninput = function() { - var event = document.createEvent('Event'); - event.initEvent('input', true, true); - input.addEventListener('input', function (e) { - }, false); - input.dispatchEvent(event); - } - - input.classList.add("multirange", "original"); - ghost.classList.add("multirange", "ghost"); - - input.value = values[0] || min + (max - min) / 2; - ghost.value = values[1] || min + (max - min) / 2; - - input.parentNode.insertBefore(ghost, input.nextSibling); - - Object.defineProperty(input, "originalValue", descriptor.get ? descriptor : { - // Fuck you Safari >:( - get: function() { return this.value; }, - set: function(v) { this.value = v; } - }); - - Object.defineProperties(input, { - valueLow: { - get: function() { return Math.min(this.originalValue, ghost.value); }, - set: function(v) { this.originalValue = v; }, - enumerable: true - }, - valueHigh: { - get: function() { return Math.max(this.originalValue, ghost.value); }, - set: function(v) { ghost.value = v; }, - enumerable: true - } - }); - - if (descriptor.get) { - // Again, fuck you Safari - Object.defineProperty(input, "value", { - get: function() { return this.valueLow + "," + this.valueHigh; }, - set: function(v) { - var values = v.split(","); - this.valueLow = values[0]; - this.valueHigh = values[1]; - }, - enumerable: true - }); - } - - function update() { - ghost.style.setProperty("--low", 100 * ((input.valueLow - min) / (max - min)) + 1 + "%"); - ghost.style.setProperty("--high", 100 * ((input.valueHigh - min) / (max - min)) - 1 + "%"); - } - - input.addEventListener("input", update); - ghost.addEventListener("input", update); - - update(); - } - - multirange.init = function() { - Array.from(document.querySelectorAll("input[type=range][multiple]:not(.multirange)")).forEach(multirange); - } - - if (document.readyState == "loading") { - document.addEventListener("DOMContentLoaded", multirange.init); - } - else { - multirange.init(); - } - -})(); \ No newline at end of file diff --git a/client/scholar/assets/polyfills.js b/client/scholar/assets/polyfills.js new file mode 100644 index 0000000..f49f8f6 --- /dev/null +++ b/client/scholar/assets/polyfills.js @@ -0,0 +1 @@ +Array.from||(Array.from=function(e){"use strict";return[].slice.call(e)}),function e(t,n,r){function i(o,l){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!l&&a)return a(o,!0);if(u)return u(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var u="function"==typeof require&&require,o=0;o Date: Sat, 9 Sep 2017 13:49:41 +0300 Subject: [PATCH 41/81] Don't use notifications inside reader. --- packages/reader/ReaderLayout.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/reader/ReaderLayout.js b/packages/reader/ReaderLayout.js index a64a56e..1a7e682 100644 --- a/packages/reader/ReaderLayout.js +++ b/packages/reader/ReaderLayout.js @@ -62,14 +62,7 @@ class ReaderLayout extends Component { this._updateLayout() - if (this.state.error) { - main = $$('div').append( - $$(Notification, { - type: 'error', - message: this.state.error.message - }) - ) - } else if (this.state.session) { + if (this.state.session) { main = $$(Reader, { configurator: this.props.configurator, editorSession: this.state.session From 25cb5490292d324bcad830af9aafd68704ed770a Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 9 Sep 2017 13:50:01 +0300 Subject: [PATCH 42/81] Male legacy version. --- make.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/make.js b/make.js index a5c301d..c545ef3 100644 --- a/make.js +++ b/make.js @@ -66,7 +66,9 @@ function buildApp(app, production) { globals: { 'substance': 'substance', 'archivist': 'archivist' - } + }, + buble: production === true, + useStrict: production !== true }) b.custom('injecting config', { @@ -79,7 +81,7 @@ function buildApp(app, production) { } }) if(production) { - b.minify('./dist/' + app + '/' + app + '.js', './dist/' + app + '/' + app + '.min.js') + b.minify('./dist/' + app + '/' + app + '.js') } else { b.copy('./dist/' + app + '/app.js.map', './dist/' + app + '/' + app + '.js.map') } @@ -107,9 +109,24 @@ function buildServerJS() { function _buildDeps(min) { b.make('substance', 'lib') b.copy('node_modules/substance/dist', './dist/libs/substance') - if(min) b.minify('./dist/libs/substance/substance.js', './dist/libs/substance/substance.min.js') + + if(min) { + b.custom('applying modification', { + src: './dist/libs/substance/substance.es5.js', + dest: './dist/libs/substance/substance.legacy.js', + execute: function(file) { + const code = fs.readFileSync(file[0], 'utf8') + const result = code.replace(/(\(ref = this\)._initialize.apply\(ref, args\);)[\s\S]{13}/g, 'var ref;(ref = this)._initialize.apply(ref, args);') + fs.writeFileSync(this.outputs[0], result, 'utf8') + } + }) + + b.minify('./dist/libs/substance/substance.legacy.js') + } + + //if(min) b.minify('./dist/libs/substance/substance.js', './dist/libs/substance/substance.min.js') b.make('archivist', 'lib') b.copy('node_modules/archivist/dist', './dist/libs/archivist') - if(min) b.minify('./dist/libs/archivist/archivist.js', './dist/libs/archivist/archivist.min.js') + if(min) b.minify('./dist/libs/archivist/archivist.es5.js') } \ No newline at end of file From a016071fd3ca48eb481d28406b99256feecba113 Mon Sep 17 00:00:00 2001 From: Daniel Beilinson Date: Sat, 9 Sep 2017 13:50:17 +0300 Subject: [PATCH 43/81] Change connected scripts. --- client/scholar/index.html | 2 +- client/scholar/index.production.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/scholar/index.html b/client/scholar/index.html index 51e3677..f93b96a 100644 --- a/client/scholar/index.html +++ b/client/scholar/index.html @@ -2,11 +2,11 @@ Archivist Scholar + - - + + + + + + \ No newline at end of file diff --git a/fixGeo.js b/fixGeo.js new file mode 100644 index 0000000..12b0c48 --- /dev/null +++ b/fixGeo.js @@ -0,0 +1,618 @@ +/* + General script for importing data from old MongoDB setup. + Data must be exported as JSON before running this script. + Script expects path to collection's JSON files on input, + e.g. import documents=../../data/documents.json users=../../data/users.json etc +*/ + +let process = require('process') +let fs = require('fs') +let Promise = require('bluebird') +let forEach = require('lodash/forEach') +let map = require('lodash/map') +let uniq = require('lodash/uniq') +let JSONConverter = require('substance').JSONConverter +let documentHelpers = require('substance').documentHelpers +let Database = require('./packages/server/Database') +let Configurator = require('archivist-js').ServerConfigurator +let EnginePackage = require('./packages/engine/package') +let IndexerPackage = require('./packages/indexer/package') +let InterviewPackage = require('./dist/ost.cjs').InterviewPackage + +let args = process.argv.slice(2) +let config = {} + +args.forEach(function(arg) { + let option = arg.split('=') + if(option.length === 2) { + config[option[0]] = option[1] + } +}) + +let db = new Database() +let configurator = new Configurator().import(InterviewPackage) +let converter = new JSONConverter() +configurator.setDBConnection(db) +configurator.import(EnginePackage) +configurator.import(IndexerPackage) + +let defaultUser = '54bd3cff742c750408dacf9d' +let entitiesTypesMap = {} +let subjectsTree = {} + +function importUsers() { + let exists = _fileExists(config.users) + if(!exists) return + + let jsonContents = fs.readFileSync(config.users) + let jsonData = JSON.parse(jsonContents) + let usersData = [] + + jsonData.forEach(function(user) { + let userData = { + userId: user._id['$oid'], + name: user.name, + email: user.email, + created: _getTimeFromId(user._id['$oid']) + } + usersData.push(userData) + }) + + let userStore = configurator.getStore('user') + return userStore.seed(usersData) +} + +function importPersons() { + let exists = _fileExists(config.persons) + if(!exists) return + + let jsonContents = fs.readFileSync(config.persons) + let jsonData = JSON.parse(jsonContents) + let personsData = [] + + jsonData.forEach(function(person) { + let personData = { + entityId: person._id['$oid'], + name: person.name, + description: person.description, + synonyms: [], + created: person.createdAt['$date'], + edited: person.updatedAt['$date'], + entityType: 'person', + data: { + name: person.name, + synonyms: [], + description: person.description, + global: person.global, + } + } + personData.updatedBy = person.edited ? person.edited['$oid'] : defaultUser + personData.userId = person.edited ? person.edited['$oid'] : defaultUser + entitiesTypesMap[personData.entityId] = personData.entityType + personsData.push(personData) + }) + + let entityStore = configurator.getStore('entity') + return entityStore.seed(personsData) +} + +function importDefinitions() { + let exists = _fileExists(config.definitions) + if(!exists) return + + let jsonContents = fs.readFileSync(config.definitions) + let jsonData = JSON.parse(jsonContents) + let definitionsData = [] + + jsonData.forEach(function(definition) { + let definitionData = { + entityId: definition._id['$oid'], + name: definition.title, + description: definition.description, + synonyms: [], + created: definition.createdAt['$date'], + edited: definition.updatedAt['$date'], + entityType: 'definition', + data: { + name: definition.title, + description: definition.description, + definitionType: definition.definition_type + } + } + + definitionData.synonyms = definition.synonyms + if(definitionData.synonyms.indexOf(definition.title) > -1) { + let pos = definitionData.synonyms.indexOf(definition.title) + definitionData.synonyms.splice(pos, 1) + } + definitionData.data.synonyms = definitionData.synonyms + + definitionData.updatedBy = definition.edited ? definition.edited['$oid'] : defaultUser + definitionData.userId = definition.edited ? definition.edited['$oid'] : defaultUser + entitiesTypesMap[definitionData.entityId] = definitionData.entityType + definitionsData.push(definitionData) + }) + + let entityStore = configurator.getStore('entity') + return entityStore.seed(definitionsData) +} + +function fixLocations() { + let entityStore = configurator.getStore('entity') + + return new Promise(function(resolve) { + db.connection.run("SELECT * from entities WHERE data->>'country' = 'Россия' AND (data->'point'->>0)::float < 42 AND (data->'point'->>1)::float > 30", function(err, res) { + if (err) { + console.error('Entity read error', err) + } + + resolve(res) + }) + }).then(res => { + let fixes = [] + res.forEach(r=>{ + r.data.point = r.data.point.reverse() + fixes.push( + entityStore.updateEntity(r.entityId,r) + ) + }) + return Promise.all(fixes) + }) +} + +function importLocations() { + let exists = _fileExists(config.locations) + if(!exists) return + + let jsonContents = fs.readFileSync(config.locations) + let jsonData = JSON.parse(jsonContents) + let locationsData = [] + + jsonData.forEach(function(location) { + let locationData = { + entityId: location._id['$oid'], + name: location.name, + description: location.description, + edited: location.updatedAt['$date'], + entityType: location.type, + data: { + name: location.name, + description: location.description, + country: location.country, + point: location.point + } + } + + locationData.synonyms = location.synonyms + if(locationData.synonyms.indexOf(location.name) > -1) { + let pos = locationData.synonyms.indexOf(location.name) + locationData.synonyms.splice(pos, 1) + } + locationData.data.synonyms = locationData.synonyms + + if(locationData.entityType === 'toponym') { + locationData.data.currentName = location.current_name + } else if (locationData.entityType === 'prison') { + locationData.data.nearestLocality = location.nearest_locality + locationData.data.prisonType = location.prison_type + } + + locationData.created = location.createdAt ? location.createdAt['$date'] : location.updatedAt['$date'] + locationData.updatedBy = location.edited ? location.edited['$oid'] : defaultUser + locationData.userId = location.edited ? location.edited['$oid'] : defaultUser + entitiesTypesMap[locationData.entityId] = locationData.entityType + locationsData.push(locationData) + }) + + let entityStore = configurator.getStore('entity') + return entityStore.seed(locationsData) +} + +function importSubjects() { + let exists = _fileExists(config.subjects) + if(!exists) return + + let jsonContents = fs.readFileSync(config.subjects) + let jsonData = JSON.parse(jsonContents) + let subjectsData = [] + + jsonData.forEach(function(subject) { + let subjectData = { + entityId: subject._id['$oid'], + name: subject.name, + synonyms: [subject.name], + description: subject.description || '', + edited: subject.updatedAt['$date'], + entityType: 'subject', + data: { + name: subject.name, + workname: subject.workname, + description: subject.description || '', + parent: subject.parent || null, + position: subject.position + } + } + + if(subject.name !== subject.workname) subjectData.synonyms.push(subject.workname) + subjectData.created = subject.createdAt ? subject.createdAt['$date'] : subject.updatedAt['$date'] + subjectData.updatedBy = subject.edited ? subject.edited['$oid'] : defaultUser + subjectData.userId = subject.edited ? subject.edited['$oid'] : defaultUser + subjectsData.push(subjectData) + + subjectsTree[subjectData.entityId] = {id: subjectData.entityId, parent: subjectData.data.parent} + }) + + let entityStore = configurator.getStore('entity') + return entityStore.seed(subjectsData) +} + +function importDocuments() { + let exists = _fileExists(config.documents) + if(!exists) return + + let jsonContents = fs.readFileSync(config.documents) + let jsonData = JSON.parse(jsonContents) + + let changes = {} + let documents = {} + let snapshots = {} + + jsonData.forEach(function(doc) { + // Document processing + // =================== + + let docId = doc._id['$oid'] + + let documentData = { + nodes: [], + schema: { + name: "archivist-interview", + version: "1.0.0" + } + } + + let bodyNode = { + id: 'body', + type: 'container', + nodes: [] + } + + let contentNodes = doc.nodes.content.nodes + let entities = [] + let subjects = [] + let references = {} + let paragraphsMap = {} + let fullText = '' + let metaSource = {} + let metaNode = {} + let pIndex = 1 + let sIndex = 1 + let eIndex = 1 + let tIndex = 1 + let cIndex = 1 + let subjectIndex = 1 + let entityIndexes = { + 'person': 1, + 'definition': 1, + 'prison': 1, + 'toponym': 1 + } + + contentNodes.forEach(function(nodeId) { + let paragraphId = 'paragraph-' + pIndex + let paragraph = doc.nodes[nodeId] + paragraph.id = paragraphId + + fullText += '\r\n' + paragraph.content + paragraphsMap[nodeId] = paragraphId + bodyNode.nodes.push(paragraphId) + documentData.nodes.push(paragraph) + pIndex++ + }) + + forEach(doc.nodes, function(node) { + if(node.startOffset < 0 || node.endOffset < 0) { + console.log(doc._id['$oid'], ' must be fixed') + return + } + if(node.type === 'strong') { + node.id = 'strong-' + sIndex + node.path[0] = paragraphsMap[node.path[0]] + node.start = { + offset: node.startOffset, + path: node.path + } + node.end = { + offset: node.endOffset, + path: node.path + } + documentData.nodes.push(node) + sIndex++ + } else if (node.type === 'emphasis') { + node.id = 'emphasis-' + eIndex + node.path[0] = paragraphsMap[node.path[0]] + node.start = { + offset: node.startOffset, + path: node.path + } + node.end = { + offset: node.endOffset, + path: node.path + } + documentData.nodes.push(node) + eIndex++ + } else if (node.type === 'timecode') { + node.id = 'timecode-' + tIndex + node.path[0] = paragraphsMap[node.path[0]] + node.start = { + offset: node.startOffset, + path: node.path + } + node.end = { + offset: node.endOffset, + path: node.path + } + documentData.nodes.push(node) + tIndex++ + } else if (node.type === 'subject_reference') { + let subject = { + id: 'subject-' + subjectIndex, + containerId: 'body', + type: 'subject', + start: { + path: [ + paragraphsMap[node.startPath[0]], + 'content' + ], + offset: node.startOffset + }, + end: { + path: [ + paragraphsMap[node.endPath[0]], + 'content' + ], + offset: node.endOffset + }, + reference: node.target + } + forEach(node.target, function(subject) { + if(references[subject]) { + references[subject]++ + } else { + references[subject] = 1 + } + }) + subjects = subjects.concat(node.target) + documentData.nodes.push(subject) + subjectIndex++ + } else if (node.type === 'comment') { + let comment = { + id: 'comment-' + cIndex, + content: node.content, + containerId: 'body', + type: 'comment', + start: { + path: [ + paragraphsMap[node.startPath[0]], + 'content' + ], + offset: node.startOffset + }, + end: { + path: [ + paragraphsMap[node.endPath[0]], + 'content' + ], + offset: node.endOffset + }, + author: defaultUser, + createdAt: node.created_at, + replies: [] + } + documentData.nodes.push(comment) + cIndex++ + } else if (node.type === 'entity_reference') { + let entityType = entitiesTypesMap[node.target] + let entity = { + id: entityType + '-' + entityIndexes[entityType], + end: { + offset: node.endOffset, + path: [ + paragraphsMap[node.path[0]], + 'content' + ] + }, + start: { + offset: node.startOffset, + path: [ + paragraphsMap[node.path[0]], + 'content' + ] + }, + reference: node.target, + type: entityType + } + if(references[node.target]) { + references[node.target]++ + } else { + references[node.target] = 1 + } + entities.push(node.target) + documentData.nodes.push(entity) + entityIndexes[entityType]++ + } else if (node.type === 'waypoint') { + node.density = node.density.toString() + documentData.nodes.push(node) + } else if (node.type === 'document') { + metaSource = node + metaNode = { + id: 'meta', + type: 'meta', + title: node.title, + state: '', + abstract: node.abstract, + abstract_translation: node.abstract_en, + abstract_translation_second: node.abstract_de, + media_id: node.media_id, + operator: node.operator, + conductor: node.conductor, + record_type: node.record_type, + project_name: node.project_name, + project: node.project || 'Международный проект документации рабского и принудительного труда', + published_on: '2016-11-16', + short_summary: node.short_summary, + short_summary_translation: node.short_summary_en, + interview_date: '1990-11-16', + sound_operator: node.sound_operator, + interviewee_bio: node.interviewee_bio, + interviewee_bio_translation: node.interviewee_bio_en, + interviewee_bio_translation_second: node.interviewee_bio_de, + persons_present: node.persons_present, + project_location: node.project_location, + interview_duration: parseInt(node.interview_duration, 10), + interview_location: node.interview_location, + interviewee_photo: node.interviewee_photo, + interviewee_category: node.interviewee_category, + interviewee_detention_place_type: node.forced_labor_type, + interviewee_forced_labor_type: node.detention_place_type, + interviewee_state: node.person_state || 'военнопленный', + interviewee_military_service: node.military_service || false, + interviewee_sex: node.sex || 'мужчина', + interviewee_place_of_birth: node.place_of_birth, + interviewee_year_of_birth: node.year_of_birth, + interviewee_enslaving_year: node.enslaving_year, + interviewee_homecoming_year: node.homecoming_year, + interviewee_waypoints: node.interviewee_waypoints || [] + } + + try { + metaNode.published_on = new Date(node.published_on).toISOString() + } catch(e) { + console.log('Invalid published time:', node.published_on) + } + + try { + metaNode.interview_date = new Date(node.interview_date).toISOString() + } catch(e) { + console.log('Invalid interview time:', node.interview_date) + } + + if(node.transcripted) metaNode.state = 'transcripted' + if(node.verified) metaNode.state = 'verified' + if(node.finished) metaNode.state = 'finished' + if(node.published) metaNode.state = 'published' + + documentData.nodes.unshift(metaNode) + } + + }) + + documentData.nodes.unshift(bodyNode) + + entities = uniq(entities) + subjects = uniq(subjects) + + let annotations = [] + annotations = annotations.concat(entities, subjects) + + forEach(references, function(cnt, ref) { + if(subjectsTree[ref]) { + let parent = subjectsTree[ref].parent + while(parent) { + if(references[parent]) { + references[parent]++ + } else { + references[parent] = 1 + } + parent = subjectsTree[parent] ? subjectsTree[parent].parent : false + } + } + }) + + let article = configurator.createArticle(); + let jsonDoc = converter.importDocument(article, documentData); + let changeset = documentHelpers.getChangeFromDocument(jsonDoc); + + changes[docId] = [changeset] + + documents[docId] = { + documentId: docId, + schemaName: 'archivist-interview', + schemaVersion: '1.0.0', + info: {}, + meta: metaNode, + version: 1, + indexedVersion: 0, + title: metaNode.title, + language: 'russian', + annotations: annotations, + references: references, + fullText: fullText, + updatedAt: metaSource.updated_at, + updatedBy: defaultUser, + userId: defaultUser + } + + // snapshots[docId] = { + // '1': { + // documentId: docId, + // version: 1, + // data: documentData, + // created: new Date() + // } + // } + + }) + + let changeStore = configurator.getStore('change') + let documentStore = configurator.getStore('document') + let snapshotStore = configurator.getStore('snapshot') + + return documentStore.seed(documents) + .then(function() { + return changeStore.seed(changes) + }) + .then(function() { + return snapshotStore.seed(snapshots) + }) +} + +function reindexEntities() { + return new Promise(function(resolve) { + db.connection.run("REINDEX INDEX anno_refs", function(err, res) { + if (err) { + console.error('Entity reindexing error', err) + } + + resolve(res) + }) + }) +} + +function _fileExists(path) { + try { + fs.accessSync(path, fs.F_OK) + return true + } catch (e) { + console.log('Sorry, given file doesn\'t exists:', path) + return false + } +} + +function _getTimeFromId(id) { + let timestamp = id.toString().substring(0, 8) + let date = new Date(parseInt(timestamp, 16) * 1000) + return date.toISOString() +} + +fixLocations() + .then(function() { + console.log('Entities has been fixed!') + db.shutdown() + process.exit() + }) + .catch(function(error) { + console.error(error) + db.shutdown() + process.exit(1) + }) From 61385e7f4cfebec8e0b9f1af4589922bf8da0ac9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 24 Jul 2018 02:06:34 +0300 Subject: [PATCH 69/81] Disable minifier. --- make.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make.js b/make.js index cfd50ce..596efd6 100644 --- a/make.js +++ b/make.js @@ -36,7 +36,8 @@ b.task('server', () => { // build all b.task('default', ['dev']) b.task('dev', ['clean', 'assets', 'deps', 'server', 'client']) -b.task('production', ['clean', 'assets', 'deps-min', 'server', 'client-min']) +//b.task('production', ['clean', 'assets', 'deps-min', 'server', 'client-min']) +b.task('production', ['clean', 'assets', 'deps', 'server', 'client']) function buildApp(app, production) { return function() { From f25b66b397b0f71284648005a358ea873a9edefb Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 24 Jul 2018 02:13:38 +0300 Subject: [PATCH 70/81] Disable minifier. --- make.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/make.js b/make.js index 596efd6..7db8e1d 100644 --- a/make.js +++ b/make.js @@ -36,8 +36,7 @@ b.task('server', () => { // build all b.task('default', ['dev']) b.task('dev', ['clean', 'assets', 'deps', 'server', 'client']) -//b.task('production', ['clean', 'assets', 'deps-min', 'server', 'client-min']) -b.task('production', ['clean', 'assets', 'deps', 'server', 'client']) +b.task('production', ['clean', 'assets', 'deps-min', 'server', 'client-min']) function buildApp(app, production) { return function() { @@ -82,7 +81,7 @@ function buildApp(app, production) { } }) if(production) { - b.minify('./dist/' + app + '/' + app + '.js') + //b.minify('./dist/' + app + '/' + app + '.js') } else { b.copy('./dist/' + app + '/app.js.map', './dist/' + app + '/' + app + '.js.map') } From 64e250cfd9407d2e7d1f5feab1254f305b7f3d96 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 24 Jul 2018 02:20:30 +0300 Subject: [PATCH 71/81] Disable minifier. --- client/publisher/index.production.html | 4 ++-- client/scholar/index.production.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/publisher/index.production.html b/client/publisher/index.production.html index 171bf3c..7b96087 100644 --- a/client/publisher/index.production.html +++ b/client/publisher/index.production.html @@ -2,8 +2,8 @@ OST Publisher - - + +