diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b5b722b22458929f474b4ca2829743725ae4125..dcabc44bbaddc5f4f49931a3d1bd60e943f2dd47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated (for soon-to-be removed features) +* css-class `.caosdb-property-text-value`. Please use + `.caosdb-f-property-text-value` or `.caosdb-v-property-text-value` instead. + ### Removed (for now removed features) * `ext_revisions` module. This module was only a work-around which had been diff --git a/Makefile b/Makefile index d45ade7ac320a58eaadcec6f621370296c9e471b..dfe13ff4326a9b22ae567a2cc44e04695bd3b9b5 100644 --- a/Makefile +++ b/Makefile @@ -95,24 +95,24 @@ build_properties: @ln -s $(PUBLIC_DIR) $(PUBLIC_DIR)/$(BUILD_NUMBER) @ln -s $(PUBLIC_DIR) $(PUBLIC_DIR)/webinterface -PORT = 8000 +TEST_PORT ?= 8000 TIMEOUT = 60 run-test-server: test - $(MISC_DIR)/unit_test_http_server.py $(PORT) $(TIMEOUT) False $(PUBLIC_DIR) + $(MISC_DIR)/unit_test_http_server.py $(TEST_PORT) $(TIMEOUT) False $(PUBLIC_DIR) keep-test-server: test - $(MISC_DIR)/unit_test_http_server.py $(PORT) -1 True $(PUBLIC_DIR) + $(MISC_DIR)/unit_test_http_server.py $(TEST_PORT) -1 True $(PUBLIC_DIR) run-qunit: test $(foreach exec, firefox Xvfb xwd,\ $(if $(shell which $(exec)),echo "found $(exec)",$(error "No $(exec) in PATH"))) # start server in background - $(MISC_DIR)/unit_test_http_server.py $(PORT) $(TIMEOUT) False $(PUBLIC_DIR) & + $(MISC_DIR)/unit_test_http_server.py $(TEST_PORT) $(TIMEOUT) False $(PUBLIC_DIR) & # start firefox with virtual xserver Xvfb :1 -screen 0 1024x768x24 & - DISPLAY=:1 firefox "http://localhost:$(PORT)/?hidepassed" & + DISPLAY=:1 firefox "http://localhost:$(TEST_PORT)/?hidepassed" & while [ 1 -eq 1 ]; do \ sleep 5 ; \ diff --git a/src/core/css/webcaosdb.css b/src/core/css/webcaosdb.css index c62ad4feaffe51d344deb38d8dffb811a2f6258c..b76e06445caf685b614845d2e831a2e8c98a8d09 100644 --- a/src/core/css/webcaosdb.css +++ b/src/core/css/webcaosdb.css @@ -159,7 +159,8 @@ tbody:not(:hover) tr .caosdb-v-entity-version-hint-cur { /* DEPRECATED css class .caosdb-property-text-value - Use * .caosdb-f-property-single-raw-value or introduce new * .caosdb-v-property-text-value */ -.caosdb-property-text-value { +.caosdb-property-text-value, +.caosdb-v-property-text-value { white-space: pre-line; } diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index 176572f472014e7b06e0f269291baf392e8ef01f..90d6bfd23b989bbff133a63d65e1e68d99f4b3bb 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -824,10 +824,7 @@ function setPropertySafe(valueelement, property, propold) { preview.init(); } } else { - /* DEPRECATED css class .caosdb-property-text-value - Use - * .caosdb-f-property-single-raw-value or introduce new - * .caosdb-v-property-text-value */ - valueelement.innerHTML = "<span class='caosdb-property-text-value'>" + property.value + "</span>"; + valueelement.innerHTML = "<span class='caosdb-f-property-single-raw-value caosdb-f-property-text-value caosdb-v-property-text-value'>" + property.value + "</span>"; } } diff --git a/src/core/js/edit_mode.js b/src/core/js/edit_mode.js index 8ec85661cd5c62212aab44fbdafee4368938b35e..85645aabaf7d05cb7abe928b4792b5de6ef9e352 100644 --- a/src/core/js/edit_mode.js +++ b/src/core/js/edit_mode.js @@ -5,6 +5,8 @@ * Copyright (C) 2018 Research Group Biomedical Physics, * Max-Planck-Institute for Dynamics and Self-Organization Göttingen * Copyright (C) 2019 Henrik tom Wörden + * Copyright (C) 2019-2021 IndiScale GmbH <info@indiscale.com> + * Copyright (C) 2019-2021 Timm Fitschen <t.fitschen@indiscale.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as diff --git a/src/core/js/ext_cosmetics.js b/src/core/js/ext_cosmetics.js index e70f8e5779bb75ebd08a47ec080fc57dc1348dc4..7cc6e714378dece69a12ecccf56f237f1ee69dcb 100644 --- a/src/core/js/ext_cosmetics.js +++ b/src/core/js/ext_cosmetics.js @@ -1,13 +1,35 @@ -var cosmetics = new function() { - this.init = function() { - this.linkify(); - } +/* + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +"use strict"; + +/** + * Cosmetics module is a collection of small look-and-feel tweaks for the + * caosdb webui. + * + * @author Timm Fitschen + */ +var cosmetics = new function () { - this.linkify = function() { - /* DEPRECATED css class .caosdb-property-text-value - Use - * .caosdb-f-property-single-raw-value or introduce new - * .caosdb-v-property-text-value */ - $('.caosdb-property-text-value').each(function(index) { + var _linkify = function () { + $('.caosdb-f-property-text-value').each(function (index) { if (/^https?:\/\//.test(this.innerText)) { var uri = this.innerText; var text = uri @@ -18,9 +40,30 @@ var cosmetics = new function() { } }); } + + /** + * Convert any text-value beginning with 'http(s)://' into a link. + * + * A listener detects edit-mode changes and previews + */ + var linkify = function () { + _linkify(); + + // edit-mode-listener + document.body.addEventListener(edit_mode.end_edit.type, _linkify, true); + // preview listener + document.body.addEventListener(preview.previewReadyEvent.type, _linkify, true); + } + + this.init = function () { + if ("${BUILD_MODULE_EXT_COSMETICS_LINKIFY}" == "ENABLED") { + linkify(); + } + } + } -$(document).ready(function() { - cosmetics.init(); +$(document).ready(function () { + caosdb_modules.register(cosmetics); }); diff --git a/src/core/xsl/entity.xsl b/src/core/xsl/entity.xsl index 95f5031975d99b9252474ac7469c214b22b5ef68..d562bf99f7611b976e10d5349d0c99972d6d8fdd 100644 --- a/src/core/xsl/entity.xsl +++ b/src/core/xsl/entity.xsl @@ -309,7 +309,7 @@ <!-- DEPRECATED css class .caosdb-property-text-value - Use .caosdb-f-property-single-raw-value or introduce new .caosdb-v-property-text-value --> - <xsl:value-of select="'caosdb-f-property-single-raw-value caosdb-property-text-value'"/> + <xsl:value-of select="'caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value'"/> </xsl:attribute> <xsl:call-template name="trim"> <xsl:with-param name="str"> @@ -324,7 +324,7 @@ <!-- DEPRECATED css class .caosdb-property-text-value - Use .caosdb-f-property-single-raw-value or introduce new .caosdb-v-property-text-value --> - <span class="caosdb-f-property-single-raw-value caosdb-property-text-value"/> + <span class="caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value"/> </xsl:otherwise> </xsl:choose> </xsl:template> diff --git a/test/core/js/modules/entity.xsl.js b/test/core/js/modules/entity.xsl.js index 21ce97ac3536b325ba77d6bc2d482b926619ae5d..bbc1cac0c7eff6bb06c6826c6efb7054827e82c3 100644 --- a/test/core/js/modules/entity.xsl.js +++ b/test/core/js/modules/entity.xsl.js @@ -154,7 +154,7 @@ QUnit.test("single-value template with reference property.", function(assert) { 'value': '', 'reference': 'true', 'boolean': 'false' - })), "<span xmlns=\"http://www.w3.org/1999/xhtml\" class=\"caosdb-f-property-single-raw-value caosdb-property-text-value\"></span>", "empty value produces empty span."); + })), "<span xmlns=\"http://www.w3.org/1999/xhtml\" class=\"caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value\"></span>", "empty value produces empty span."); let link = callTemplate(this.entityXSL, 'single-value', { 'value': '1234', 'reference': 'true',