Verified Commit 5874fbe5 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

EHN: Very basic implementation of a welcome screen

parent 2c65efb8
......@@ -5,6 +5,7 @@
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* Copyright (C) 2019 IndiScale GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
......@@ -24,6 +25,7 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:include href="common.xsl"/>
<xsl:include href="welcome.xsl"/>
<xsl:variable name="basepath">
<xsl:call-template name="uri_ends_with_slash">
<xsl:with-param name="uri">
......@@ -125,6 +127,9 @@
<xsl:if test="not(/Response/Query/Selection)">
<xsl:apply-templates mode="entities" select="/Response/*"/>
</xsl:if>
<xsl:if test="count(/Response/*)&lt;2 and not(/Response/Error|/Response/Info|/Response/Warning)">
<xsl:call-template name="welcome"/>
</xsl:if>
</div>
<div class="panel panel-warning caosdb-f-edit caosdb-v-edit-panel caosdb-v-edit-panel hidden">
<div class="panel-heading">
......
......@@ -4,6 +4,7 @@
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* Copyright (C) 2019 IndiScale GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
......@@ -22,19 +23,11 @@
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template name="squarefield">
<xsl:param name="content"/>
<xsl:element name="div">
<xsl:attribute name="class">caosdb-square</xsl:attribute>
<xsl:element name="div">
<xsl:attribute name="class">caosdb-square-content</xsl:attribute>
<xsl:value-of select="$content"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template name="welc_filesystem_button">
<xsl:param name="baseloc">
<xsl:value-of select="$filesystempath"/>
</xsl:param>
<xsl:template name="welcome">
<div class="jumbotron caosdb-f-welcome-panel">
<h1>Welcome</h1>
<p>This is CaosDB.</p>
<p>This is the default welcome message. If you are an administrator you can override it. Just copy <code>src/core/xsl/welcome.xsl</code> to <code>src/ext/xsl/welcome.xsl</code> and change this content. Then run <code>make</code> again in CaosdDB's web interface's root directory.</p>
</div>
</xsl:template>
</xsl:stylesheet>
......@@ -4,6 +4,7 @@
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* Copyright (C) 2019 IndiScale GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
......@@ -45,32 +46,10 @@ QUnit.test("availability", function(assert) {
assert.ok(this.welcomeXSL);
})
QUnit.test("squarefield template available, produces div.caosdb-square which has actually width=height.",function(assert){
// inject an entrance rule
var entry_t = this.welcomeXSL.createElement("xsl:template");
this.welcomeXSL.firstElementChild.appendChild(entry_t);
entry_t.outerHTML = '<xsl:template match="/"><div style="width: 145px;"><xsl:call-template name="squarefield"><xsl:with-param name="content">content</xsl:with-param></xsl:call-template></div></xsl:template>';
// check template works at all
var xsl = this.welcomeXSL;
var xml = str2xml("<root/>");
var html = xslt(xml,xsl);
assert.ok(html,"document fragment exists");
// check output
var match = xml2str(html).match(/^<div.*><div class="caosdb-square"><div class="caosdb-square-content">content<\/div><\/div><\/div>$/);
assert.ok(match,"div created");
// check actual size
document.body.appendChild(html);
var square_e = $(".caosdb-square")[0];
assert.equal(square_e.offsetWidth,"145","width is 145px");
assert.equal(square_e.offsetHeight,"145","height is 145px");
var elem =document.getElementsByClassName("caosdb-square")[0].parentNode;
elem.parentNode.removeChild(elem);
QUnit.test("welcome template produces .caosdb-f-welcome-panel", function(assert) {
var xsl = injectTemplate(this.welcomeXSL, '<xsl:template match="/"><xsl:call-template name="welcome"/></xsl:template>');
var xml_str = '<root>';
var xml = str2xml(xml_str);
var html = xslt(xml, xsl);
assert.ok($(html.firstElementChild).hasClass("caosdb-f-welcome-panel"), "has class .caosdb-f-welcome-panel");
});
/* MISC FUNCTIONS */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment