From 04669f11c4427087ed7469c6cc75f51d64032f19 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 10 Jun 2024 14:58:05 +0100 Subject: [PATCH] CoCo changes --- config.json | 184 ++++++++++++++----------- ctl | 253 +--------------------------------- oml/__main__.py | 3 +- oml/item/models.py | 25 ++-- oml/localnodes.py | 2 +- oml/server.py | 6 +- oml/settings.py | 2 +- oml/setup.py | 58 ++++---- static/js/fullscreenButton.js | 2 +- static/js/infoView.js | 152 +++++++++----------- 10 files changed, 222 insertions(+), 465 deletions(-) diff --git a/config.json b/config.json index c6dad60..5b56813 100644 --- a/config.json +++ b/config.json @@ -11,7 +11,7 @@ "id": "title", "title": "Title", "type": "string", - "additionalSort": [{"key": "author", "operator": "+"}, {"key": "date", "operator": "-"}], + "additionalSort": [{"key": "person", "operator": "+"}, {"key": "identifier", "operator": "-"}], "autocomplete": true, "autocompleteSort": [{"key": "title", "operator": "+"}], "columnRequired": true, @@ -21,10 +21,10 @@ "sortType": "title" }, { - "id": "author", - "title": "Author", + "id": "person", + "title": "Person", "type": ["string"], - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "date", "operator": "-"}], + "additionalSort": [{"key": "title", "operator": "+"}], "autocomplete": true, "columnRequired": true, "columnWidth": 192, @@ -34,9 +34,9 @@ "sortType": "person" }, { - "id": "publisher", - "title": "Publisher", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "id": "type", + "title": "Object Type", + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "type": ["string"], "autocomplete": true, "columnWidth": 128, @@ -44,52 +44,101 @@ "find": true, "sort": true }, + { + "id": "technique", + "title": "Technique", + "type": ["string"], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 128, + "filter": true, + "find": true, + "sort": true + }, + { + "id": "inscription", + "title": "Inscription Type", + "type": ["string"], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 96, + "filter": true, + "sort": true + }, + { + "id": "subject", + "title": "Subject", + "type": ["string"], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 128, + "filter": true, + "find": true, + "sort": true + }, { "id": "place", "title": "Place", "type": ["string"], - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], "columnWidth": 128, "filter": true, "find": true, "sort": true }, { - "id": "date", - "title": "Date", + "id": "dataset", + "title": "From Dataset", "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], - "columnWidth": 96, - "filter": true, - "filterMap": "(-?\\d+)", - "sort": true - }, - { - "id": "series", - "title": "Series", - "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 128, "filter": true, "find": true, "sort": true }, { - "id": "edition", - "title": "Edition", + "id": "slkb", + "title": "Sloane Lab Knowledge Base", "type": "string", + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 128, + "find": true, + "sort": true + }, + { + "id": "source", + "title": "Source", + "type": ["string"], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 128, + "find": true, + "sort": true + }, + { + "id": "identifier", + "title": "Identifier", + "type": "string", + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 128, + "find": true, + "sort": true + }, + { + "id": "catalogue", + "title": "Historical Catalogue Entry", + "type": "string", + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], + "columnWidth": 128, + "find": true, + "sort": true + }, + { + "id": "description", + "title": "Description", + "type": "text", "find": true }, { - "id": "language", - "title": "Language", - "type": ["string"], - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], - "columnWidth": 128, - "filter": true, - "find": true, - "sort": true + "id": "comments", + "title": "Curator Comments", + "type": "text", + "find": true }, { "id": "pages", @@ -100,42 +149,11 @@ "format": {"type": "unit", "args": ["pages"]}, "sort": true }, - { - "id": "categories", - "title": "Categories", - "type": ["string"], - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], - "columnWidth": 128, - "filter": true, - "find": true, - "sort": true - }, - { - "id": "isbn", - "title": "ISBN", - "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], - "format": {"type": "ISBN", "args": [13, true]}, - "columnWidth": 128, - "sort": true - }, - { - "id": "description", - "title": "Description", - "type": "text", - "find": true - }, - { - "id": "tableofcontents", - "title": "Table of Contents", - "type": "text", - "find": true - }, { "id": "extension", "title": "Extension", "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 80, "format": {"type": "upper", "args": []}, "filter": true, @@ -145,7 +163,7 @@ "id": "size", "title": "Size", "type": "integer", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 64, "format": {"type": "value", "args": ["B"]}, "sort": true @@ -154,7 +172,7 @@ "id": "id", "title": "ID", "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 96, "sort": true }, @@ -162,7 +180,7 @@ "id": "created", "title": "First Seen", "type": "date", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 144, "format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}, "sort": true @@ -171,7 +189,7 @@ "id": "added", "title": "Date Added", "type": "date", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 144, "format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}, "sort": true @@ -180,7 +198,7 @@ "id": "modified", "title": "Last Modified", "type": "date", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 144, "format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}, "sort": true @@ -189,7 +207,7 @@ "id": "accessed", "title": "Last Read", "type": "date", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 144, "format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}, "sort": true @@ -198,7 +216,7 @@ "id": "timesaccessed", "title": "Times Accessed", "type": "integer", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 64, "format": {"type": "number", "args": []}, "sort": true @@ -207,7 +225,7 @@ "id": "mediastate", "title": "Media State", "type": "string", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "find": true, "sort": true, "values": [ @@ -220,7 +238,7 @@ "id": "transferadded", "title": "Added", "type": "date", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}, "sort": true }, @@ -228,7 +246,7 @@ "id": "transferprogress", "title": "Progress", "type": "float", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "format": {"type": "percent", "args": [1, 0]}, "sort": true }, @@ -236,7 +254,7 @@ "id": "sharemetadata", "title": "Share Metadata", "type": "boolean", - "additionalSort": [{"key": "title", "operator": "+"}, {"key": "author", "operator": "+"}], + "additionalSort": [{"key": "title", "operator": "+"}, {"key": "person", "operator": "+"}], "columnWidth": 144, "format": {"type": "boolean", "args": []}, "sort": true @@ -338,11 +356,11 @@ "ui": { "fileInfo": "extension", "filters": [ - {"id": "author", "sort": [{"key": "items", "operator": "-"}]}, - {"id": "publisher", "sort": [{"key": "items", "operator": "-"}]}, - {"id": "date", "sort": [{"key": "name", "operator": "-"}]}, - {"id": "language", "sort": [{"key": "items", "operator": "-"}]}, - {"id": "categories", "sort": [{"key": "items", "operator": "-"}]} + {"id": "place", "sort": [{"key": "items", "operator": "-"}]}, + {"id": "subject", "sort": [{"key": "items", "operator": "-"}]}, + {"id": "type", "sort": [{"key": "name", "operator": "-"}]}, + {"id": "technique", "sort": [{"key": "items", "operator": "-"}]}, + {"id": "person", "sort": [{"key": "items", "operator": "-"}]} ], "filtersSize": 176, "find": {"conditions": [], "operator": "&"}, @@ -351,13 +369,13 @@ "iconSize": 256, "item": "", "itemView": "info", - "listColumns": ["title", "author", "publisher", "date"], + "listColumns": ["title", "person", "type", "subject"], "listColumnWidth": {}, "lists": {}, "listSelection": [], "listSort": [ - {"key": "author", "operator": "+"}, - {"key": "date", "operator": "+"}, + {"key": "person", "operator": "+"}, + {"key": "subject", "operator": "+"}, {"key": "title", "operator": "+"} ], "listView": "grid", @@ -370,7 +388,7 @@ "help": "introduction" }, "section": "books", - "showAnnotations": false, + "showAnnotations": true, "showAnnotationUsers": "all", "showBrowser": true, "showDebugMenu": false, diff --git a/ctl b/ctl index 3131db1..55c92ab 100755 --- a/ctl +++ b/ctl @@ -1,255 +1,6 @@ #!/usr/bin/env bash -NAME="openmedialibrary" - cd "`dirname "$0"`" -if [ -e oml ]; then - cd .. -fi BASE=`pwd` -SYSTEM=`uname -s` -PLATFORM=`uname -m` -GIT_BASE=https://code.0x2620.org/0x2620 -PYTHON=python3 - -DATA="$BASE/data" -if [ ! -e "$DATA" ] && [ -e "$BASE/config" ]; then - if [ "$1" == "stop" ] || [ "$1" == "restart" ]; then - DATA="$BASE/config" - else - mv "$BASE/config" "$DATA" - fi -else - if [ ! -e "$BASE/data/release.json" ] && [ -e "$BASE/config/release.json" ]; then - mv "$BASE/config/release.json" "$BASE/data/release.json" - fi -fi -PID="$DATA/$NAME.pid" - -PLATFORM_PYTHON=3.4 -SHARED_PYTHON=3.7 -if [ -e "$BASE/platform_local" ]; then - export PLATFORM_ENV="$BASE/platform_local" -else - if [ $SYSTEM == "Linux" ]; then - if [ $PLATFORM == "x86_64" ]; then - ARCH=64 - PLATFORM_PYTHON=3.11 - else - ARCH=32 - fi - if [ $PLATFORM == "aarch64" ]; then - ARCH="_aarch64" - PLATFORM_PYTHON=3.5 - fi - if [ $PLATFORM == "armv7l" ]; then - ARCH="_armv7l" - fi - PLATFORM="linux$ARCH" - if [ -e "$BASE/platform_${PLATFORM}/lib/libunrar.so" ]; then - export UNRAR_LIB_PATH="$BASE/platform_${PLATFORM}/lib/libunrar.so" - fi - fi - if [ $SYSTEM == "Darwin" ]; then - PLATFORM="darwin64" - PLATFORM_PYTHON=3.7 - if [ -e "$BASE/platform_${PLATFORM}/lib/libunrar.dylib" ]; then - export UNRAR_LIB_PATH="$BASE/platform_${PLATFORM}/lib/libunrar.dylib" - fi - fi - export PLATFORM_ENV="$BASE/platform_${PLATFORM}" -fi -PATH="$PLATFORM_ENV/bin:$PATH" - -SHARED_ENV="$BASE/platform/Shared" -export SHARED_ENV - -if [ -e "$SHARED_ENV/etc/openssl/openssl.cnf" ]; then - export OPENSSL_CONF="$SHARED_ENV/etc/openssl/openssl.cnf" -fi - -PATH="$SHARED_ENV/bin:$PATH" -export PATH - -if [ $SYSTEM == "Darwin" ]; then - export DYLD_FALLBACK_LIBRARY_PATH="$PLATFORM_ENV/lib" - export SSL_CERT_FILE="$SHARED_ENV/etc/openssl/cert.pem" - export SSL_CERT_DIR="$SHARED_ENV/etc/openssl/certs" -fi - -PYTHONPATH="${PLATFORM_ENV}/lib/python${PLATFORM_PYTHON}/site-packages" -PYTHONPATH="${PYTHONPATH}:${SHARED_ENV}/lib/python${PLATFORM_PYTHON}/site-packages" -PYTHONPATH="${PYTHONPATH}:${SHARED_ENV}/lib/python${SHARED_PYTHON}/site-packages" -PYTHONPATH="${PYTHONPATH}:${BASE}/${NAME}" -export PYTHONPATH - -oxCACHE="$DATA/ox" -export oxCACHE - -#must be called to update commands in $PATH -hash -r 2>/dev/null - -# allow more open files -ulimit -S -n 2048 - -function update_gitbase() { - if [ -e "${BASE}/openmedialibrary/.git/config" ]; then - GIT_BASE=`grep origin .git/config -A 1 | grep url | cut -f2 -d=` - fi -} - -if [ "$1" == "start" ]; then - cd "$BASE/$NAME" - if [ -e "$PID" ]; then - if ps -p `cat "$PID"` > /dev/null; then - echo openmedialibrary already running - exit 1 - fi - fi - $PYTHON oml server "$PID" - exit $? -fi -if [ "$1" == "debug" ]; then - cd "$BASE/$NAME" - if [ -e "$PID" ]; then - if ps -p `cat "$PID"` > /dev/null; then - echo openmedialibrary already running - exit 1 - fi - fi - shift - $PYTHON oml server debug "$PID" - exit $? -fi -if [ "$1" == "stop" ]; then - if [ -e "$PID" ]; then - _PID=`cat "$PID"` - kill $_PID - waited=0 - while ps -p $_PID > /dev/null - do - sleep 1 - waited=$(($waited+1)) - if [ $waited -gt 60 ]; then - kill -9 $_PID - sleep 1 - fi - done - test -e "$PID" && rm "$PID" - fi - exit $? -fi -if [ "$1" == "restart" ]; then - if [ -e "$PID" ]; then - "$0" stop - "$0" start - exit $? - else - "$0" start - exit $? - fi -fi - -function get_port() { - port=$(grep '"port"' "${BASE}/data/server.json" | cut -f2 -d: | cut -f1 -d, | xargs) - return $port -} - -function open_linux() { - port=$(get_port) - if [ -e /usr/bin/gio ]; then - gio open "file://${BASE}/openmedialibrary/static/html/load.html#$port" - else - xdg-open "file://${BASE}/openmedialibrary/static/html/load.html#$port" - fi -} - - -if [ "$1" == "open" ]; then - if [ $SYSTEM == "Darwin" ]; then - open "/Applications/Collections of Collections.app" - fi - if [ $SYSTEM == "Linux" ]; then - if [ -e "$PID" ]; then - if ps -p `cat "$PID"` > /dev/null; then - open_linux - else - open_linux - "$0" start & - fi - else - open_linux - "$0" start & - fi - fi - exit 0 -fi -if [ "$1" == "autostart" ]; then - if [ $SYSTEM == "Darwin" ]; then - open "/Applications/Collections of Collections.app" --args --autostart - fi - if [ $SYSTEM == "Linux" ]; then - if [ ! -e "$PID" ]; then - $PYTHON "$NAME/oml/gtkstatus.py" --autostart - exit $? - fi - fi - exit 0 -fi - -if [ "$1" == "ui" ]; then - shift - $PYTHON "$NAME/oml/ui.py" "$@" - exit $? -fi -if [ "$1" == "init" ]; then - update_gitbase - if [ ! -e "${BASE}/platform" ]; then - git clone --depth 1 $GIT_BASE/openmedialibrary_platform.git "${BASE}/platform" - fi - if [ ! -e "${PLATFORM_ENV}" ]; then - git clone --depth 1 $GIT_BASE/openmedialibrary_platform_${PLATFORM}.git "${PLATFORM_ENV}" - fi - cd "${BASE}" - if [ ! -e "${BASE}/ctl" ]; then - ln -s openmedialibrary/ctl - fi - "${BASE}/ctl" update_static - exit -fi -if [ "$1" == "update" ]; then - cd "$BASE/$NAME" - if [ ! -e "${PLATFORM_ENV}" ]; then - update_gitbase - git clone --depth 1 $GIT_BASE/openmedialibrary_platform_${PLATFORM}.git "${PLATFORM_ENV}" - fi - if [ -d "$BASE/$NAME/.git" ]; then - OLD=`"$0" version` - cd "$BASE/platform" - echo Update shared platform... - git pull - cd "${PLATFORM_ENV}" - echo Update platform... - git pull - echo Update $NAME... - cd "$BASE/$NAME" - find . -name "*.pyc" -exec rm "{}" \; - git pull - "$0" update_static > /dev/null - NEW=`"$0" version` - "$0" postupdate -o $OLD -n $NEW - else - $PYTHON oml update - fi - exit $? -fi -if [ "$1" == "python" ]; then - cd "$BASE/$NAME" - shift - $PYTHON $@ - exit $? -fi - -cd "$BASE/$NAME" -$PYTHON oml $@ -exit $? +source $BASE/venv/bin/activate +python3 oml $@ diff --git a/oml/__main__.py b/oml/__main__.py index 795f3a1..5cdf00d 100644 --- a/oml/__main__.py +++ b/oml/__main__.py @@ -6,7 +6,8 @@ import sys from os.path import normpath, dirname, abspath, join import site -base = normpath(dirname(dirname(dirname(abspath(__file__))))) +base = dirname(dirname(abspath(__file__))) +site.addsitedir(base) if sys.platform == 'win32': for site_packages in ( diff --git a/oml/item/models.py b/oml/item/models.py index 61732d1..68b5e0a 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -269,6 +269,7 @@ class Item(db.Model): for v in value ] for v in value: + print(key['id'], v) add(key['id'], v) if key['id'] in current_values: removed_values = current_values[key['id']] - set(value) @@ -327,20 +328,22 @@ class Item(db.Model): a.delete() meta_keys = ( - 'author', - 'categories', - 'cover', - 'date', + 'person', + 'slkb', + 'dataset', + 'source', + 'catalogue', + 'technique', + 'subject', + 'inscription', + 'type', + 'identifier', 'description', - 'edition', - 'isbn', - 'language', + 'comments', + 'cover', 'pages', 'place', - 'publisher', - 'series', 'sharemetadata', - 'tableofcontents', 'title', 'sorttitle' ) @@ -741,7 +744,7 @@ class File(db.Model): not_item = True if not_item: return - j = self.item.json(keys=['title', 'author', 'publisher', 'date', 'extension']) + j = self.item.json(keys=['title', 'people', 'type', 'subject', 'extension']) current_path = self.fullpath() if not os.path.exists(current_path): diff --git a/oml/localnodes.py b/oml/localnodes.py index dcd2751..3fee796 100644 --- a/oml/localnodes.py +++ b/oml/localnodes.py @@ -55,7 +55,7 @@ def get_broadcast_interfaces(): )) class LocalNodes(dict): - service_type = '_oml._tcp.local.' + service_type = '_coco._tcp.local.' local_info = None local_ips = None diff --git a/oml/server.py b/oml/server.py index 8d39872..38b0638 100644 --- a/oml/server.py +++ b/oml/server.py @@ -98,12 +98,12 @@ async def shutdown(): def run(): PID = sys.argv[2] if len(sys.argv) > 2 else None + debug = "debug" in sys.argv if len(sys.argv) > 3 and sys.argv[2] == 'debug': PID = sys.argv[3] debug = True - else: - debug = False - + if PID == "debug": + PID = None log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s' if debug: logging.basicConfig(level=logging.DEBUG, format=log_format) diff --git a/oml/settings.py b/oml/settings.py index 0fad9ee..bf5cbf9 100644 --- a/oml/settings.py +++ b/oml/settings.py @@ -8,7 +8,7 @@ from oml.utils import get_user_id from oml import fulltext base_dir = os.path.normpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')) -top_dir = os.path.dirname(base_dir) +top_dir = base_dir static_path = os.path.join(base_dir, 'static') updates_path = os.path.normpath(os.path.join(top_dir, 'updates')) diff --git a/oml/setup.py b/oml/setup.py index ee62cb6..b461af8 100644 --- a/oml/setup.py +++ b/oml/setup.py @@ -93,14 +93,21 @@ CREATE TABLE useritem ( CREATE TABLE sort ( item_id VARCHAR(32) NOT NULL, title VARCHAR(1000), - author VARCHAR(1000), - publisher VARCHAR(1000), + person VARCHAR(1000), + type VARCHAR(1000), + technique VARCHAR(1000), + inscription VARCHAR(1000), + subject VARCHAR(1000), place VARCHAR(1000), - date VARCHAR(1000), - language VARCHAR(1000), + dataset VARCHAR(1000), + slkb VARCHAR(1000), + source VARCHAR(1000), + identifier VARCHAR(1000), + catalogue VARCHAR(1000), pages BIGINT, extension VARCHAR(1000), size BIGINT, + id VARCHAR(1000), created DATETIME, added DATETIME, modified DATETIME, @@ -109,32 +116,37 @@ CREATE TABLE sort ( mediastate VARCHAR(1000), transferadded DATETIME, transferprogress FLOAT, - id VARCHAR(1000), - isbn VARCHAR(1000), random BIGINT, PRIMARY KEY (item_id), FOREIGN KEY(item_id) REFERENCES item (id) ); -CREATE INDEX ix_sort_accessed ON sort (accessed); -CREATE INDEX ix_sort_added ON sort (added); -CREATE INDEX ix_sort_author ON sort (author); -CREATE INDEX ix_sort_created ON sort (created); -CREATE INDEX ix_sort_date ON sort (date); -CREATE INDEX ix_sort_extension ON sort (extension); -CREATE INDEX ix_sort_id ON sort (id); -CREATE INDEX ix_sort_isbn ON sort (isbn); -CREATE INDEX ix_sort_language ON sort (language); -CREATE INDEX ix_sort_mediastate ON sort (mediastate); -CREATE INDEX ix_sort_modified ON sort (modified); -CREATE INDEX ix_sort_pages ON sort (pages); -CREATE INDEX ix_sort_place ON sort (place); -CREATE INDEX ix_sort_publisher ON sort (publisher); -CREATE INDEX ix_sort_random ON sort (random); -CREATE INDEX ix_sort_size ON sort (size); -CREATE INDEX ix_sort_timesaccessed ON sort (timesaccessed); CREATE INDEX ix_sort_title ON sort (title); +CREATE INDEX ix_sort_person ON sort (person); +CREATE INDEX ix_sort_type ON sort (type); +CREATE INDEX ix_sort_technique ON sort (technique); +CREATE INDEX ix_sort_inscription ON sort (inscription); +CREATE INDEX ix_sort_subject ON sort (subject); +CREATE INDEX ix_sort_place ON sort (place); +CREATE INDEX ix_sort_dataset ON sort (dataset); +CREATE INDEX ix_sort_slkb ON sort (slkb); +CREATE INDEX ix_sort_source ON sort (source); +CREATE INDEX ix_sort_identifier ON sort (identifier); +CREATE INDEX ix_sort_catalogue ON sort (catalogue); + +CREATE INDEX ix_sort_pages ON sort (pages); +CREATE INDEX ix_sort_extension ON sort (extension); +CREATE INDEX ix_sort_size ON sort (size); +CREATE INDEX ix_sort_id ON sort (id); +CREATE INDEX ix_sort_created ON sort (created); +CREATE INDEX ix_sort_added ON sort (added); +CREATE INDEX ix_sort_modified ON sort (modified); +CREATE INDEX ix_sort_accessed ON sort (accessed); + +CREATE INDEX ix_sort_mediastate ON sort (mediastate); CREATE INDEX ix_sort_transferadded ON sort (transferadded); CREATE INDEX ix_sort_transferprogress ON sort (transferprogress); +CREATE INDEX ix_sort_random ON sort (random); + CREATE TABLE file ( created DATETIME, modified DATETIME, diff --git a/static/js/fullscreenButton.js b/static/js/fullscreenButton.js index f8b49d0..dece583 100644 --- a/static/js/fullscreenButton.js +++ b/static/js/fullscreenButton.js @@ -25,7 +25,7 @@ oml.ui.fullscreenButton = function() { that.updateElement = function() { return that.options({ - disabled: ui.itemView != 'book' + disabled: ui.itemView != 'info' }); }; diff --git a/static/js/infoView.js b/static/js/infoView.js index cb1210b..5810cb9 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -6,7 +6,7 @@ oml.ui.infoView = function(externalData, isMixed) { var ui = oml.user.ui, - arrayKeys = ['author', 'place', 'publisher', 'language', 'categories'], + arrayKeys = oml.config.itemKeys.filter(key => Ox.isArray(key.type)).map(key => key.id), editables = {}, @@ -66,6 +66,7 @@ oml.ui.infoView = function(externalData, isMixed) { $image, $reflection, $reflectionImage; + if (!externalData) { $data = Ox.Element() .addClass('OxSelectable') @@ -83,8 +84,13 @@ oml.ui.infoView = function(externalData, isMixed) { } function formatKey(key) { + const itemKey = Ox.getObjectById(oml.config.itemKeys, key) + if (!itemKey) { + console.log("known itemKey", key) + return "FIXME: " + key + } return '' - + Ox._(Ox.getObjectById(oml.config.itemKeys, key).title) + + Ox._(itemKey.title) + ': '; } @@ -95,6 +101,21 @@ oml.ui.infoView = function(externalData, isMixed) { return value ? (Ox.isArray(value) ? value : [value]).map(function(value) { if (key == 'date' && value) { value = value.slice(0, 4); + } else if (key == "dataset") { + return 'British Library'; + } else if ([ + 'source', + 'catalogue', + 'slkb', + ].includes(key)) { + console.log(key, value) + return value.split(', ').map(function(link) { + const display = Ox.parseURL(link).host + if (key == 'catalogue') { + link = 'https://knowledgebase.sloanelab.org/resource/?uri=' + encodeURIComponent(link) + } + return '' + display + ''; + }).join(', '); } return ( key && !externalData ? '' : '' @@ -543,26 +564,26 @@ oml.ui.infoView = function(externalData, isMixed) { ) .appendTo($info); - // -------- Author -------- + // -------- Person -------- $('
') .css({ marginTop: '2px' }) .append( - editables['author'] = Ox.EditableContent({ + editables['person'] = Ox.EditableContent({ clickLink: oml.clickLink, editable: isEditable, format: function(value) { - return formatValue(splitValue(value, 'author'), 'author'); + return formatValue(splitValue(value, 'person'), 'person'); }, placeholder: formatLight(Ox._( - isMixed.author ? 'Mixed Author' : 'Unknown Author' + isMixed.person ? 'Mixed Person' : 'Unknown Person' )), tooltip: isEditable ? oml.getEditTooltip() : '', value: Ox.encodeHTMLEntities( - (data.author || []).map(function(value, index) { - return index < data.author.length - 1 + (data.person || []).map(function(value, index) { + return index < data.person.length - 1 ? value.replace(/ \(Ed\.\)$/, '') : value; }).join(separator) @@ -575,7 +596,7 @@ oml.ui.infoView = function(externalData, isMixed) { }) .bindEvent({ submit: function(event) { - editMetadata('author', Ox.decodeHTMLEntities(event.value)); + editMetadata('person', Ox.decodeHTMLEntities(event.value)); } }) ) @@ -588,7 +609,13 @@ oml.ui.infoView = function(externalData, isMixed) { marginTop: '4px', }) .appendTo($info); - ['publisher', 'place', 'date'].forEach(function(key, index) { + [ + 'place', + 'technique', + 'type', + 'inscription', + 'subject', + ].forEach(function(key, index) { if (index) { $('').html(', ').appendTo($div); } @@ -599,6 +626,7 @@ oml.ui.infoView = function(externalData, isMixed) { clickLink: oml.clickLink, editable: isEditable, format: function(value) { + console.log('xx', key, value) return formatValue( Ox.contains(arrayKeys, key) ? splitValue(value) : value, @@ -630,7 +658,10 @@ oml.ui.infoView = function(externalData, isMixed) { marginTop: '4px', }) .appendTo($info); - ['series', 'edition', 'language', 'pages'].forEach(function(key, index) { + [ + 'dataset', 'slkb', 'source', 'catalogue' + + ].forEach(function(key, index) { if (index) { $('').html(', ').appendTo($div); } @@ -641,14 +672,7 @@ oml.ui.infoView = function(externalData, isMixed) { clickLink: oml.clickLink, editable: isEditable, format: function(value) { - return ( - Ox.contains(['series', 'language'], key) - ? formatValue : Ox.identity - )( - Ox.contains(arrayKeys, key) - ? splitValue(value) : value, - key - ); + return formatValue(value, key) }, placeholder: formatLight(Ox._( isMixed[key] ? 'mixed' : 'unknown' @@ -668,79 +692,17 @@ oml.ui.infoView = function(externalData, isMixed) { .appendTo($div); }); - // -------- Categories -------- - - if (data.categories || isEditable) { - $div = $('
') - .css({ - marginTop: '4px', - }) - .appendTo($info); - $('') - .html(formatKey('categories')) - .appendTo($div); - editables['categories'] = Ox.EditableContent({ - clickLink: oml.clickLink, - editable: isEditable, - format: function(value) { - return formatValue(splitValue(value), 'categories'); - }, - placeholder: formatLight(Ox._( - isMixed.categories ? 'mixed' : 'unknown' - )), - tooltip: isEditable ? oml.getEditTooltip() : '', - value: Ox.encodeHTMLEntities((data.categories || []).join(separator)) - }) - .bindEvent({ - submit: function(event) { - editMetadata('categories', Ox.decodeHTMLEntities(event.value)); - } - }) - .appendTo($div); - } - - // -------- ISBN -------- - - if (data.isbn || isEditable) { - $div = $('
') - .css({ - marginTop: '4px', - }) - .appendTo($info); - $('') - .html(formatKey('isbn')) - .appendTo($div); - editables['isbn'] = Ox.EditableContent({ - editable: isEditable, - format: function(value) { - return (value ? [ - Ox.formatISBN(value, 13, true), - Ox.formatISBN(value, 10, true) - ] : []).join(separator); - }, - placeholder: formatLight(Ox._( - isMixed.isbn ? 'mixed' : 'unknown' - )), - tooltip: isEditable ? oml.getEditTooltip() : '', - value: Ox.formatISBN(data.isbn || '', 13, true) - }) - .bindEvent({ - submit: function(event) { - this.options({ - value: Ox.formatISBN(event.value, 13, true) - }); - editMetadata( - 'isbn', Ox.formatISBN(event.value, 13) - ); - } - }) - .appendTo($div); - } - // -------- Description, Table of Contents -------- - ['description', 'tableofcontents'].forEach(function(key) { + ['description', 'comments'].forEach(function(key) { + const itemKey = Ox.getObjectById(oml.config.itemKeys, key) if (data[key] || isEditable) { + $('
') + .css({ + marginTop: '8px', + }) + .html(formatKey(key)) + .appendTo($info); $('
') .css({ marginTop: '8px', @@ -795,7 +757,7 @@ oml.ui.infoView = function(externalData, isMixed) { ) .appendTo($data); if (!oml.readOnly) { - renderIdentifyButton(data).appendTo($data); + //renderIdentifyButton(data).appendTo($data); ['accessed', 'modified', 'added', 'created'].forEach(function(id) { var title; @@ -825,6 +787,15 @@ oml.ui.infoView = function(externalData, isMixed) { }); + if (data.mediastate == 'available') { + oml.$ui.viewer = oml.ui.viewer().appendTo(that) + $(oml.$ui.viewer.find('.OxSplitPanel')[0]).css({ + top: '320px', + height: "100%", + }) + } + + function editMetadata(key, value) { var edit = Ox.extend( {id: !isMultiple ? data.id : ui.listSelection}, @@ -870,6 +841,7 @@ oml.ui.infoView = function(externalData, isMixed) { }; + if (!externalData) { ui.item && that.updateElement(ui.item); } else if (!isMultiple) {