Permalink
Switch branches/tags
5d_cell_tracking albert-dev canvas-tilelayer classification-editor cmw-merge-in-progress-ndimensional dev feature/simulation-widget feature/update-cytoscape.js features/boss-tile-source features/ci-xenial features/dendrogram-node-filter features/django-2.0 features/django-2.1 features/exporter-annotation-based-removal-update features/exporter-exclude-skeletons-by-annotation features/h2n5-tile-source features/ilastik-integration features/image-block-layer features/label-stack-manager features/landmarks-remote-projects features/layout-menu features/multi-node-provider features/multi-swc-import features/neuroglancer-skeleton features/node-query-grid-cache features/request-headers features/simple-trakem2-xml-based-node-update features/streaming-cursor-spatial-query features/synapse-plot-with-plotly features/timeviz features/tracing-intersection-cache features/travis-16.04 features/travis-celery-tests features/travis-mypy features/use-map-in-overlay features/webpack features/3d-viewer-line-width features/3d-viewer-mesh-line features/3d-viewer-multi-layer-z-sections features/3d-viewer-pick-complete-skeleton features/3dviewer-ortho-scale-bar features/1817-travis-clean gh-pages graph-widget-confidence-removal groupgraph-client-splits hotfix/meta-annotation-fulljoin imglib-backend ini-internal intersection-table-creation issues/dvid-orthoview-tracing issues/1085-treenode-connector-spatial-query issues/1282-pixi-layer-blend-mode-mode-and-filter issues/1710-explicit-downsample-factors log-scale maintenance/2017.12.07 maintenance/2018.02.16 maintenance/2018.04.15 maintenance/2018.07.19+skeleton-api-change maintenance/2018.11.09 master migration-fix navigator-annotation-updates nblast-js new-find-path-skeletons non-arrow-markers orthoslices pm-network-api public-web-api refactors/tile-source refactors/webgl-tracing-overlay release/2018.02.16 release/2018.04.15 release/2018.07.19 release/2018.11.09 remove-segmentation-tool render-service-fix simple-import-export svgcanvas-export synapse-plot sync-real-scale tests/add-more-gui-tests travis/fix-pg-10 volume-tests-fix volume-trace-fork volume-tracing
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
214 lines (186 sloc) 7.71 KB
# -*- coding: utf-8 -*-
"""Specifies static assets (CSS, JS) required by the CATMAID front-end.
This module specifies all the static files that are required by the
CATMAID front-end. The configuration is separated in libraries and CATMAID's
own files:
Libraries: To add a new library, add a new entry into the libraries_js
dictionary and, if needed, add the libraries CSS files to sourcefiles
tuple of the 'library' entry in the ``STYLESHEETS`` dictionary.
CATMAID files: By default all CSS files in the ``static/css`` directory are
included as well as all JavaScript files in ``static/js`` and CATMAID's
subdirectories in it. However, if you want to add new files explicitly, add
CSS to the source_filenames tuple in the 'catmaid' entry of the ``STYLESHEETS``
dictionary. JavaScript files go into the 'catmaid' entry of the ``JAVASCRIPT``
dictonary at the end of this file.
"""
from collections import OrderedDict
from importlib import import_module
import six
# python module names of CATMAID extensions which could potentially be installed
KNOWN_EXTENSIONS = (
'synapsesuggestor',
)
class PipelineSpecUpdater(object):
def __init__(self, input_dict=None):
if input_dict is None:
input_dict = OrderedDict()
self.result = input_dict
self.existing_output_files = set()
def update(self, other_dict, key_prefix='catmaid-ext-'):
"""Include items from other_dict in the input dict, ensuring that no data will be overwritten and the result
will not cause multiple libraries to create static files of the same name. key_prefix will be prepended to
the keys in other_dict when they are inserted into the input dict (default 'catmaid-ext-')."""
for key, value in six.iteritems(other_dict):
new_key = key_prefix + str(key)
assert new_key not in self.result, 'Extension static file IDs must not overwrite existing static file IDs'
assert value['output_filename'] not in self.existing_output_files, \
'Extension static files must not overwrite existing static files ({})'.format(value['output_filename'])
self.existing_output_files.add(value['output_filename'])
self.result['{}{}'.format(key_prefix, key)] = value
STYLESHEETS = OrderedDict()
STYLESHEETS['libraries'] = {
'source_filenames': (
'libs/jquery/themes/smoothness/jquery-ui.css',
'libs/jquery/datatable/css/demo_table.css',
'libs/jquery/datatable/extras/Buttons/css/buttons.dataTables.css',
'libs/jquery/jquery.growl.css',
'libs/jquery/jquery-ui.combobox.css',
'libs/jsTree/themes/default/style.css',
),
'output_filename': 'css/libraries.css',
'extra_context': {
'media': 'screen,projection',
}
}
STYLESHEETS['catmaid'] = {
'source_filenames': (
'css/*.css',
),
'output_filename': 'css/catmaid.css',
'extra_context': {
'media': 'screen,projection',
}
}
libraries_js = OrderedDict([
('modernizr', ['*.js']),
('jquery', ['jquery-2.1.3.min.js',
'jquery-ui.min.js', 'jquery-ui.*.js',
'jquery.dataTables.min.js', 'jquery.*.js',
'dataTables.buttons.js', 'buttons.html5.min.js']),
('jszip', ['*.js']),
('jsTree', ['jstree.js']),
('colorpicker', ['colors.js', 'colorPicker.data.js', 'colorPicker.js',
'jqColor.js']),
('fabric.js', ['all.modified.js']),
('raphael', ['raphael.js', 'g.raphael.js', 'g.pie-min.js', 'g.line.altered.js',
'raphael-custom.js', 'colorwheel.js', 'raphael.export.js']),
('d3', ['d3.v3.js', 'venn.js', 'mds.js', 'colorbrewer.js']),
('sylvester', ['sylvester.js']),
('msgpack-lite', ['msgpack.min.js']),
('numeric', ['numeric-1.2.6.js']),
('three.js', ['three.js', 'controls/TrackballControls.js',
'camera/CombinedCamera.js', 'Detector.js',
'lines/LineSegmentsGeometry.js', 'lines/LineGeometry.js',
'lines/LineSegments2.js', 'lines/Line2.js',
'lines/LineMaterial.js', 'loaders/VRMLLoader.js',
'lines/Wireframe.js', 'lines.WireframeGeometry2',
'loaders/VRMLLoader.js', 'renderer/Projector.js',
'renderer/SVGRenderer.js', 'exporters/OBJExporter.js',
'math/Lut.js', 'modifiers/*.js']),
('threex', ['*.js']),
('plotly', ['*.js']),
('pixi.js', ['*.js']),
('cytoscapejs', ['cytoscape.js', 'cytoscape-spread.js',
'arbor.js', 'cytoscape-arbor.js',
'cola.js', 'cytoscape-cola.js',
'dagre.js', 'cytoscape-dagre.js',
'springy.js', 'cytoscape-springy.js']),
('jsnetworkx', ['*.js']),
('filesaver', ['*.js']),
('whammy', ['whammy.js']),
('blazy', ['blazy.min.js']),
('geometry', ['geometry.js', 'intersects.js']), # order matters
('catmaid', ['request.js', 'CATMAID.js', 'error.js', 'events.js', 'state.js',
'command.js', 'models/*.js', 'skeleton_source.js',
'datastores.js', 'settings-manager.js', '*.js']),
])
JAVASCRIPT = OrderedDict()
for k, v in six.iteritems(libraries_js):
JAVASCRIPT[k + '-lib'] = {
'source_filenames': ['libs/%s/%s' % (k, f) for f in v],
'output_filename': 'js/libs/%s-lib.js' % k,
}
# Some libraries expect their own JavaScript files to be available under a
# particular name. Therefore, we can't use pipeline with them and include them
# separately. Entries follow the same pattern as above: key - path.
non_pipeline_js = {}
# Even non-pipeline files have to be made known to pipeline, because it takes
# care of collecting them into the STATIC_ROOT directory.
for k, v in six.iteritems(non_pipeline_js):
JAVASCRIPT[k] = {
'source_filenames': (v,),
'output_filename': v
}
# Regular CATMAID front-end files
JAVASCRIPT['catmaid'] = {
'source_filenames': (
'js/tools.js',
'js/CATMAID.js',
'js/dom.js',
'js/extensions.js',
'js/data-view.js',
'js/action.js',
'js/settings-manager.js',
'js/helpers/*.js',
'js/init.js',
'js/network-api.js',
'js/project.js',
'js/stack.js',
'js/stack-viewer.js',
'js/tile-source.js',
'js/treelines.js',
'js/ui.js',
'js/layout.js',
'js/user.js',
'js/WindowMaker.js',
'js/skeleton-model.js',
'js/skeleton-group.js',
'js/time-series.js',
'js/tools/navigator.js',
'js/tools/box-selection-tool.js',
'js/tools/roi-tool.js',
'js/tools/segmentation-tool.js',
'js/tools/*.js',
'js/layers/tile-layer.js',
'js/layers/pixi-layer.js',
'js/layers/*.js',
'js/widgets/detail-dialog.js',
'js/widgets/options-dialog.js',
'js/3d/*.js',
'js/widgets/*.js',
),
'output_filename': 'js/catmaid.js',
}
installed_extensions = []
stylesheet_updater = PipelineSpecUpdater(STYLESHEETS)
non_pipeline_js_updater = PipelineSpecUpdater(non_pipeline_js)
javascript_updater = PipelineSpecUpdater(JAVASCRIPT)
for app_name in KNOWN_EXTENSIONS:
try:
app = import_module(app_name)
installed_extensions.append(app_name)
app_pipelinefiles = import_module(app_name + '.pipelinefiles')
except ImportError:
continue
try:
stylesheet_updater.update(app_pipelinefiles.STYLESHEETS)
except AttributeError:
pass
try:
non_pipeline_js_updater.update(app_pipelinefiles.non_pipeline_js)
except AttributeError:
pass
try:
javascript_updater.update(app_pipelinefiles.JAVASCRIPT)
except AttributeError:
pass