Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generate-sef.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ fi
mkdir -p dist/vocabs
cp vocabs/*.rdf dist/vocabs/
echo "✓ Vocabularies copied to dist/vocabs/"

cp src/translations.rdf dist/
echo "✓ Translations copied to dist/"
11 changes: 6 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<script type="text/javascript" src="lib/xml-c14n-sync.js"></script>
<script type="text/javascript">
window.onload = function() {
// preload the vocabulary documents into the SaxonJS document pool,
// so doc() resolves them synchronously during initialization
// preload the vocabulary documents and the string catalog into the SaxonJS
// document pool, so doc() resolves them synchronously during initialization
const vocabs = ["vocabs/foaf.rdf", "vocabs/dcterms.rdf"];
Promise.all(vocabs.map(href =>
SaxonJS.getResource({ location: href, type: "xml" })))
.then(resources => {
Promise.all([SaxonJS.getResource({ location: "src/translations.rdf", type: "xml" }), ...vocabs.map(href =>
SaxonJS.getResource({ location: href, type: "xml" }))])
.then(([catalog, ...resources]) => {
const pool = {};
pool[new URL("dist/translations.rdf", document.baseURI).href] = catalog; // the catalog resolves against the SEF, the vocabularies against this page
vocabs.forEach((href, i) =>
pool[new URL(href, document.baseURI).href] = resources[i]);
return SaxonJS.transform({
Expand Down
29 changes: 19 additions & 10 deletions src/annotate.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ version="3.0">
intersect (descendant::* | self::*[@property]))[last()]"/>
<xsl:sequence select="ixsl:call($event, 'preventDefault', [])[current-date() lt xs:date('2000-01-01')]"/>

<!-- MUST come before rdfae:populate-form, which reaches the form by id() and so does nothing at all -
silently, over an empty sequence - when a host has re-rendered the page DOM and dropped the
overlay. rdfae:show-overlay rebuilds it too, but it runs after populate, so the dialog opened
blank in exactly that case. It keeps its own guard as the backstop for callers that reach it
without going through this handler -->
<xsl:if test="empty(id($rdfae:overlay-id, ixsl:page()))">
<xsl:call-template name="rdfae:init-overlay"/>
</xsl:if>

<xsl:choose>
<!-- edit mode -->
<xsl:when test="exists($annotation)">
Expand Down Expand Up @@ -85,11 +94,10 @@ version="3.0">
<xsl:function name="rdfae:selection-valid" as="xs:boolean">
<xsl:param name="range"/>

<xsl:variable name="start" select="ixsl:get($range, 'startContainer')"/>
<xsl:variable name="end" select="ixsl:get($range, 'endContainer')"/>
<xsl:sequence select="ixsl:call($start, 'isSameNode', [ $end ])
or (ixsl:get($start, 'nodeType') = 3 and ixsl:get($end, 'nodeType') = 3
and ixsl:call(ixsl:get($start, 'parentNode'), 'isSameNode', [ ixsl:get($end, 'parentNode') ]))"/>
<xsl:variable name="start" select="ixsl:get($range, 'startContainer')" as="node()?"/>
<xsl:variable name="end" select="ixsl:get($range, 'endContainer')" as="node()?"/>
<xsl:sequence select="$start is $end
or ($start instance of text() and $end instance of text() and $start/.. is $end/..)"/>
</xsl:function>

<!-- the single write path for RDFa attributes, shared by create and edit. No modes:
Expand Down Expand Up @@ -187,7 +195,7 @@ version="3.0">
<xsl:template name="rdfae:unwrap-element">
<xsl:param name="element" as="element()"/>

<xsl:variable name="parent" select="ixsl:get($element, 'parentNode')"/>
<xsl:variable name="parent" select="$element/.." as="node()"/>
<xsl:for-each select="1 to xs:integer(ixsl:get($element, 'childNodes.length'))">
<xsl:sequence select="ixsl:call($parent, 'insertBefore', [ ixsl:get($element, 'firstChild'), $element ])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
Expand Down Expand Up @@ -275,8 +283,8 @@ version="3.0">
<div id="output-modal" class="rdfa-editor-ui" style="display: none;">
<div class="modal-content">
<span class="modal-close">&#215;</span>
<h3 id="output-title">Output</h3>
<button id="output-download" type="button" style="display: none;">Download</button>
<h3 id="output-title"><xsl:value-of select="rdfae:label('output')"/></h3>
<button id="output-download" type="button" style="display: none;"><xsl:value-of select="rdfae:label('download')"/></button>
<pre id="output-content"/>
</div>
</div>
Expand Down Expand Up @@ -336,7 +344,7 @@ version="3.0">
</xsl:variable>

<xsl:call-template name="rdfae:show-output">
<xsl:with-param name="title" select="'Extracted RDF/XML'"/>
<xsl:with-param name="title" select="rdfae:label('extracted-rdfxml')"/>
<xsl:with-param name="text" select="serialize(rdfae:group-triples($rdf), map{ 'method': 'xml', 'indent': true() })"/>
<xsl:with-param name="filename" select="'content.rdf'"/>
<xsl:with-param name="media-type" select="'application/rdf+xml'"/>
Expand All @@ -351,7 +359,8 @@ version="3.0">

<!-- clicking the backdrop (not the content) closes the modal -->
<xsl:template match="div[@id = 'output-modal']" mode="ixsl:onclick">
<xsl:if test="ixsl:call(ixsl:get(ixsl:event(), 'target'), 'isSameNode', [ . ])">
<xsl:variable name="target" select="ixsl:get(ixsl:event(), 'target')" as="node()?"/>
<xsl:if test="$target is .">
<ixsl:set-style name="display" select="'none'"/>
</xsl:if>
</xsl:template>
Expand Down
33 changes: 33 additions & 0 deletions src/classes.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rdfae="https://w3id.org/atomgraph/rdfa-editor#"
exclude-result-prefixes="#all"
version="3.0">

<!--
The classes the editor's chrome wears, as opposed to the ones it runs on. A host
with a design system of its own redeclares these and its buttons and helper text
join the rest of its UI, without forking the templates that emit them.

Only presentational tokens belong here. Everything else the editor emits is
load-bearing - rdfa-editor-content, slash-item, typeahead-input, remove-action
and the rest are what its own ixsl:on* rules match on and its stylesheets select,
so a host that changed them would break dispatch rather than restyle anything.
The defaults are what the editor's own CSS styles, so a standalone editor looks
the same whether or not a host configures anything.
-->

<xsl:param name="button-primary-class" as="xs:string" select="'btn-primary'"/>

<xsl:param name="button-secondary-class" as="xs:string" select="'btn-secondary'"/>

<xsl:param name="button-danger-class" as="xs:string" select="'btn-danger'"/>

<xsl:param name="helper-text-class" as="xs:string" select="'helper-text'"/>

<xsl:param name="checkbox-label-class" as="xs:string" select="'checkbox-label'"/>

</xsl:stylesheet>
Loading
Loading