Commit 4ec4d6e5 authored by Stephan Kreutzer's avatar Stephan Kreutzer

'sos-grid-2' prototype added.

parent 77abbc5f
......@@ -325,6 +325,7 @@ function Poi(id, title, description, parents, children)
return _parents;
}
// TODO: This might not get filled in some cases.
that.getChildren = function()
{
return _children;
......
Stephan Kreutzer, Bahnhofstraße 71, 74321 Bietigheim-Bissingen, GERMANY (http://hypertext-systems.org, http://publishing-systems.org, https://skreutzer.de, <skreutzer@fsfe.org>).
This diff is collapsed.
The $/sos-grid-2/index.xhtml is generated via a XSLT transformation using the
$/sos_xml_to_sos_grid_xhtml_1.xsl XSLT stylesheet on a SOS XML file.
The already existing file is based on $/../../examples/development_process.xml
(commit https://gitlab.com/skreutzer/sos-experimental/tree/77abbc5fd446428cb677cd247d3e607b61c922d6).
#!/bin/sh
java -cp ./xml_xslt_transformator_1 xml_xslt_transformator_1 jobfile_xml_xslt_transformator_1.xml resultinfo_xml_xslt_transformator_1.xml
<?xml version="1.0" encoding="UTF-8"?>
<xml-xslt-transformator-1-jobfile>
<job input-file="../../examples/development_process.xml" entities-resolver-config-file="./xml_xslt_transformator_1/entities/config_empty.xml" stylesheet-file="./sos_xml_to_sos_grid_xhtml_1.xsl" output-file="./sos-grid-2/index.xhtml"/>
</xml-xslt-transformator-1-jobfile>
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 2.
*
* SOS Grid Prototype 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3 or any later version,
* as published by the Free Software Foundation.
*
* SOS Grid Prototype 2 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 2. If not, see <http://www.gnu.org/licenses/>.
*/
body
{
font-family: sans-serif;
}
#causes
{
width: 32%;
height: 18%;
position: absolute;
left: 0%;
top: 0%;
text-align: right;
}
#current
{
width: 32%;
height: 18%;
position: absolute;
left: 34%;
top: 0%;
text-align: center;
}
#effects
{
width: 32%;
height: 18%;
position: absolute;
left: 68%;
top: 0%;
text-align: left;
}
#details
{
width: 96%;
height: 38%;
position: absolute;
left: 2%;
top: 62%;
}
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 2.
*
* SOS Grid Prototype 2 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 or any later
* version of the license, as published by the Free Software Foundation.
*
* SOS Grid Prototype 2 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 2. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
let gridNavigator = new SosGridNavigator();
function SosGridNavigator()
{
let that = this;
that.NavigateIssue = function(issueId) {
Reset();
ResetDetails();
_currentIssue = _gridEngine.getIssueById(issueId);
if (_currentIssue == null)
{
throw "Loading an Issue failed.";
}
if (RenderIssue(_currentIssue) != true)
{
return false;
}
return true;
}
that.ShowDetails = function(id, type) {
ResetDetails();
if (_currentIssue == null)
{
console.log("SosGridNavigator.ShowDetails() without _currentIssue.");
return -1;
}
let poi = null;
if (type === "current")
{
poi = _currentIssue;
}
else if (type == "cause")
{
for (let i = 0; i < _currentIssue.getCauses().length; i++)
{
if (_currentIssue.getCauses()[i].getId() === id)
{
poi = _currentIssue.getCauses()[i];
break;
}
}
}
else if (type == "effect")
{
for (let i = 0; i < _currentIssue.getEffects().length; i++)
{
if (_currentIssue.getEffects()[i].getId() === id)
{
poi = _currentIssue.getEffects()[i];
break;
}
}
}
else
{
console.log("Type '" + type + "' not supported.");
return -1;
}
if (poi == null)
{
console.log("Couldn't find POI with ID '" + id + "'.");
return -1;
}
if (RenderDetails(poi) != 0)
{
return -1;
}
return 0;
}
let _gridEngine = new SosGridEngine();
let _currentIssue = null;
}
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 2.
*
* SOS Grid Prototype 2 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 or any later
* version of the license, as published by the Free Software Foundation.
*
* SOS Grid Prototype 2 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 2. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
function RenderIssue(issue)
{
let target = document.getElementById('current');
if (target == null)
{
throw "Renderer: Can't find target with ID 'current'.";
}
let container = document.createElement("div");
let header = document.createElement("h3");
header.appendChild(document.createTextNode("Issue"));
container.appendChild(header);
if (issue.getPreviousIssueId() != null)
{
let navigationLink = document.createElement("a");
navigationLink.setAttribute("href", "javascript:void(0);");
// TODO: Prevent injection (any maybe at other places, too).
navigationLink.setAttribute("onclick", "gridNavigator.NavigateIssue(\"" + issue.getPreviousIssueId() + "\");");
let arrow = document.createTextNode("prev");
navigationLink.appendChild(arrow);
container.appendChild(navigationLink);
}
else
{
let span = document.createElement("span");
span.setAttribute("style", "color: gray;");
let arrow = document.createTextNode("prev");
span.appendChild(arrow);
container.appendChild(span);
}
container.appendChild(document.createTextNode(" "));
if (issue.getNextIssueId() != null)
{
let navigationLink = document.createElement("a");
navigationLink.setAttribute("href", "javascript:void(0);");
// TODO: Prevent injection (any maybe at other places, too).
navigationLink.setAttribute("onclick", "gridNavigator.NavigateIssue(\"" + issue.getNextIssueId() + "\");");
let arrow = document.createTextNode("next");
navigationLink.appendChild(arrow);
container.appendChild(navigationLink);
}
else
{
let span = document.createElement("span");
span.setAttribute("style", "color: gray;");
let arrow = document.createTextNode("next");
span.appendChild(arrow);
container.appendChild(span);
}
container.appendChild(document.createElement("br"));
container.appendChild(document.createElement("br"));
let title = document.createTextNode(issue.getTitle());
let span = document.createElement("span");
span.setAttribute("onclick", "gridNavigator.ShowDetails(\"" + issue.getId() + "\", \"current\");");
span.appendChild(title);
container.appendChild(span);
target.appendChild(container);
target = document.getElementById('causes');
if (target == null)
{
throw "Renderer: Can't find target with ID 'causes'.";
}
container = document.createElement("div");
header = document.createElement("h3");
header.appendChild(document.createTextNode("Causes"));
container.appendChild(header);
for (let i = 0; i < issue.getCauses().length; i++)
{
let title = document.createTextNode(issue.getCauses()[i].getTitle());
let span = document.createElement("span");
span.setAttribute("onclick", "gridNavigator.ShowDetails(\"" + issue.getCauses()[i].getId() + "\", \"cause\");");
span.appendChild(title);
container.appendChild(span);
container.appendChild(document.createElement("hr"));
}
target.appendChild(container);
target = document.getElementById('effects');
container = document.createElement("div");
header = document.createElement("h3");
header.appendChild(document.createTextNode("Effects"));
container.appendChild(header);
for (let i = 0; i < issue.getEffects().length; i++)
{
let title = document.createTextNode(issue.getEffects()[i].getTitle());
let span = document.createElement("span");
span.setAttribute("onclick", "gridNavigator.ShowDetails(\"" + issue.getEffects()[i].getId() + "\", \"effect\");");
span.appendChild(title);
container.appendChild(span);
container.appendChild(document.createElement("hr"));
}
target.appendChild(container);
return true;
}
function Reset()
{
let targets = new Array("causes", "current", "effects")
for (let i = 0; i < targets.length; i++)
{
let target = document.getElementById(targets[i]);
if (target == null)
{
throw "Renderer: Can't find target with ID '" + targets[i] + "'.";
}
while (target.hasChildNodes() == true)
{
target.removeChild(target.lastChild);
}
}
}
function RenderDetails(poi)
{
let target = document.getElementById("details");
if (target == null)
{
throw "Renderer: Can't find target with ID 'details'.";
}
let container = document.createElement("div");
let header = document.createElement("h3");
header.appendChild(document.createTextNode("Details"));
container.appendChild(header);
let description = poi.getText();
if (description != null)
{
container.appendChild(document.createTextNode(description));
}
target.appendChild(container);
return 0;
}
function ResetDetails()
{
let target = document.getElementById("details");
if (target == null)
{
throw "Renderer: Can't find target with ID 'details'.";
}
while (target.hasChildNodes() == true)
{
target.removeChild(target.lastChild);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018-2019 Stephan Kreutzer
This file is part of SOS Grid Prototype 2.
SOS Grid Prototype 2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3 or any later version,
as published by the Free Software Foundation.
SOS Grid Prototype 2 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 3 for more details.
You should have received a copy of the GNU Affero General Public License 3
along with SOS Grid Prototype 2. If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:sos="http://www.untiednations.com/SOS">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
<xsl:template match="/">
<html version="-//W3C//DTD XHTML 1.1//EN" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
<xsl:text>&#xA;</xsl:text>
<xsl:comment> This file was created by sos_xml_to_sos_grid_xhtml_1.xsl of SOS Grid Prototype 2, which is free software licensed under the GNU Affero General Public License 3 or any later version (see https://gitlab.com/skreutzer/sos-experimential/tree/master/prototypes/sos-grid-2/ and http://www.untiednations.com/community/plan-sos/). </xsl:comment>
<xsl:text>&#xA;</xsl:text>
<xsl:comment>
Copyright (C) 2018-2019 Stephan Kreutzer
This file is part of SOS Grid Prototype 2.
SOS Grid Prototype 2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3 or any later version,
as published by the Free Software Foundation.
SOS Grid Prototype 2 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 3 for more details.
You should have received a copy of the GNU Affero General Public License 3
along with SOS Grid Prototype 2. If not, see &lt;http://www.gnu.org/licenses/&gt;.
The data in the &lt;div id="sos-input"/&gt; is not part of this program,
it's user data that is only processed. A different license may apply.
</xsl:comment>
<xsl:text>&#xA;</xsl:text>
<title>SOS Grid Prototype 2</title>
<meta content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" name="viewport"/>
<link rel="stylesheet" type="text/css" href="./css/styles.css"/>
<!-- <script src="...">//</script> to prevent self-closing by XSLT outputting XHTML. -->
<script type="text/javascript" src="./js/sos-grid-engine.js">//</script>
<script type="text/javascript" src="./js/sos-grid-renderer.js">//</script>
<script type="text/javascript" src="./js/sos-grid-navigation.js">//</script>
<script type="text/javascript">
<xsl:text>
"use strict";
// As browsers/W3C/WHATWG are incredibly evil, they might ignore the self-declarative
// XML namespace of this document and the given content type in the header, and instead
// assume/render "text/html", which then fails with JavaScript characters that are
// XML/XHTML special characters which need to be escaped, if the file is saved under
// a name that happens to end with ".html" (!!!). Just have the file name end with
// ".xhtml" and it might magically start to work.
function loadGrid()
{
if (window.location.hash.length > 1)
{
gridNavigator.NavigateIssue(window.location.hash.substr(1));
}
else
{
// NavigateIssue() with empty ID string: load the "default" (first) Issue.
gridNavigator.NavigateIssue("");
}
}
window.onload = function () {
let loadLink = document.getElementById('loadLink');
loadLink.parentNode.removeChild(loadLink);
loadGrid();
if ("onhashchange" in window)
{
window.onhashchange = loadGrid;
}
};
</xsl:text>
</script>
</head>
<body>
<div id="grid">
<div id="causes"/>
<div id="current"/>
<div id="effects"/>
<div id="details"/>
<div id="loadLink">
<a href="#" onclick="loadGrid();">Load</a>
</div>
</div>
<!--
As the stupid browser execution environment is sandboxed, local files can't
be dynamically read from disk, and as we're forced to load the entire source
into memory anyway because of this, if it's XML, we could easily put it into
the DOM instead of parsing XML from a JavaScript variable. This interferes
with XHTML GUI work in this XSLT file, but if the XML source would need to be
escaped to be a JavaScript string literal, a conversion is unavoidable, so
the XHTML file can just as well be the result of a XSLT conversion from the source.
-->
<div id="sos-input" style="display:none;">
<xsl:comment> The data contained in this element and sub-elements is not part of this program, it's user data and might be under a different license than this program. This program also doesn't depend on it or link it as a library, it's only processed. </xsl:comment>
<xsl:apply-templates select="/sos:SOS"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="//sos:*">
<xsl:element name="sos:{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()|text()"/>
</xsl:element>
</xsl:template>
<xsl:template match="//sos:*//text()">
<xsl:copy/>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
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