Skip to content

Commit

Permalink
Improve HTML UI to de-emphasize inlined resources and property 'noise…
Browse files Browse the repository at this point in the history
…'. Fixes #59056596
  • Loading branch information
cbeer committed Nov 13, 2013
1 parent 9d8e80d commit 5b1c0c7
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 36 deletions.
10 changes: 10 additions & 0 deletions fcrepo-http-api/src/main/resources/views/common.css
Expand Up @@ -28,6 +28,12 @@ dd {
padding-left: 54px;
}

#metadata .panel-body {
word-wrap: break-word;
text-indent: -35px;
padding-left: 35px;
}

#datastream_payload_container {
display: none;
}
Expand All @@ -43,4 +49,8 @@ dd {

#actions {
margin-bottom: 3em;
}

.namespace {
font-size: .8em;
}
19 changes: 16 additions & 3 deletions fcrepo-http-api/src/main/resources/views/common.vsl
Expand Up @@ -3,21 +3,34 @@
#* @vtlvariable name="model" type="com.hp.hpl.jena.rdf.model.Model" *#
#macro( triples $sub )
<dl>

#set ($last_quad = false)
#foreach($quad in $helpers.getSortedTriples($model, $rdf.find($nodeany, $sub, $nodeany, $nodeany)))
<dt>
<span class="namespace muted" title="$quad.getPredicate().getNameSpace()">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace())</span><span class="localName">$quad.getPredicate().getLocalName()</span>

</dt>
#if($last_quad == false || !$last_quad.getPredicate().equals($quad.getPredicate()))
<dt>
#if($last_quad == false || !$last_quad.getPredicate().getNameSpace().equals($quad.getPredicate().getNameSpace()))
<span class="namespace text-muted" title="$quad.getPredicate().getNameSpace()">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace(), false)</span>
#else
<span class="namespace text-muted" title="$quad.getPredicate().getNameSpace()">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace(), true)</span>
#end
<span class="localName">$quad.getPredicate().getLocalName()</span>
</dt>
#end
<dd>
#if($quad.getObject().isURI() && $quad.getObject().getURI().startsWith("http"))
<a href="$quad.getObject().getURI()" property="$quad.getPredicate().toString()">$esc.html($quad.getObject())</a>
#elseif ($quad.getObject().isLiteral())
<span property="$quad.getPredicate().toString()">$esc.html($quad.getObject().getLiteral().getLexicalForm())</span>
#else
<span property="$quad.getPredicate().toString()">$esc.html($quad.getObject())</span>
#end
#if( $quad.getPredicate().toString().equals("http://fedora.info/definitions/v4/rest-api#digest") )
<a href="$topic/fcr:fixity">check fixity</a>
#end
</dd>
#set ($last_quad = $quad)

#end
</dl>
#end
Expand Down
27 changes: 20 additions & 7 deletions fcrepo-http-api/src/main/resources/views/mode-root.vsl
Expand Up @@ -37,21 +37,34 @@


## output triples for the topic node
<div class="well">
#triples($topic)
<div class="panel panel-default">
<div class="panel-heading">
<h4>Properties</h4>
</div>
<div class="panel-body">
#triples($topic)
</div>
</div>

## output other nodes

<h2>Triples for other nodes</h2>
<h2>Inlined Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if( $subject != $topic )
<div class="well" resource="$subject.getURI()">
<h3><a href="$subject.getURI()">$helpers.getObjectTitle($rdf, $subject.asNode())</a></h3>
#triples($subject.asNode())
</div>
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples">
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
</div>

</div>

Expand Down
26 changes: 20 additions & 6 deletions fcrepo-http-api/src/main/resources/views/node.vsl
Expand Up @@ -37,21 +37,35 @@
#parse("views/common-metadata.vsl")

## output triples for the topic node
<div class="well">
#triples($topic)
<div class="panel panel-default">
<div class="panel-heading">
<h4>Properties</h4>
</div>
<div class="panel-body">
#triples($topic)
</div>
</div>


## output other nodes

<h2>Triples for other nodes</h2>
<h2>Inlined Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if( $subject != $topic )
<div class="well" resource="$subject.getURI()">
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
#triples($subject.asNode())
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples" >
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
</div>
</div>


Expand Down
40 changes: 30 additions & 10 deletions fcrepo-http-api/src/main/resources/views/nt-file.vsl
Expand Up @@ -42,28 +42,48 @@
#parse("views/common-metadata.vsl")

## output triples for the topic node
<div class="well">
#triples($topic)
<div class="panel panel-default">
<div class="panel-heading">
<h4>Properties</h4>
</div>
<div class="panel-body">
#triples($topic)
</div>
</div>


## output other nodes

<h2>Triples for other nodes</h2>
<h2>Inlined Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if( $subject != $topic )
#if ( $subject.getURI() )
<div class="well" resource="$subject.getURI()">
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
#triples($subject.asNode())
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples" >
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#else
<div class="well" resource="$subject.getId()">
<h3>$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</h3>
#triples($subject.asNode())
</div>
<div class="panel panel-default" resource="$subject.getId()">
<div class="panel-heading" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getId())_triples" >
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getId())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
#end
</div>
</div>


Expand Down
25 changes: 19 additions & 6 deletions fcrepo-http-api/src/main/resources/views/nt-resource.vsl
Expand Up @@ -38,21 +38,34 @@
#parse("views/common-metadata.vsl")

## output triples for the topic node
<div class="well">
#triples($topic)
<div class="panel panel-default">
<div class="panel-heading">
<h4>Properties</h4>
</div>
<div class="panel-body">
#triples($topic)
</div>
</div>

## output other nodes

<h2>Triples for other nodes</h2>
<h2>Inlined Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if( $subject != $topic )
<div class="well" resource="$subject.getURI()">
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
#triples($subject.asNode())
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples" >
<h3><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
</div>
</div>

</div>
Expand Down
Expand Up @@ -219,11 +219,32 @@ public List<Quad> getSortedTriples(final Model model,
* @return
*/
public String getNamespacePrefix(final PrefixMapping mapping,
final String namespace) {
final String namespace, final boolean compact) {
final String nsURIPrefix = mapping.getNsURIPrefix(namespace);

if (nsURIPrefix == null) {
return namespace;
if (compact) {
final int hashIdx = namespace.lastIndexOf("#");

final int split;

if (hashIdx > 0) {
split = namespace.substring(0, hashIdx).lastIndexOf("/");
} else {
split = namespace.lastIndexOf("/");
}

if (split > 0) {
return "..." + namespace.substring(split);
} else {
return namespace;
}

} else {
return namespace;
}


} else {
return nsURIPrefix + ":";
}
Expand Down Expand Up @@ -294,4 +315,13 @@ public Property rdfsDomain() {
public Resource rdfsClass() {
return RDFS.Class;
}

/**
* Transform a source string to something appropriate for HTML ids
* @param source
* @return
*/
public String parameterize(final String source) {
return source.toLowerCase().replaceAll("[^a-z0-9\\-_]+", "_");
}
}
Expand Up @@ -149,9 +149,9 @@ public void shouldExtractNamespaceAndPrefix() {
final Model model = createDefaultModel();
model.setNsPrefix("prefix", "namespace");

assertEquals("prefix:", testObj.getNamespacePrefix(model, "namespace"));
assertEquals("prefix:", testObj.getNamespacePrefix(model, "namespace", false));
assertEquals("some-other-namespace", testObj.getNamespacePrefix(model,
"some-other-namespace"));
"some-other-namespace", false));
}

@Test
Expand Down

0 comments on commit 5b1c0c7

Please sign in to comment.