Skip to content

Commit

Permalink
Deprecate maturity and show status with Rainbow
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Jul 28, 2023
1 parent c724eb0 commit a3ec2e0
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 17 deletions.
8 changes: 0 additions & 8 deletions ogc/bblocks/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ required:
- version
- dateOfLastChange
- sources
- maturity
- scope
properties:
itemIdentifier:
Expand Down Expand Up @@ -113,13 +112,6 @@ properties:
link:
type: string
format: uri
maturity:
description: Level of maturity for this Building Block.
enum:
- mature
- proposal
- stable
- development
schema:
description: URL (or array thereof) for JSON schemas of this Building Block.
oneOf:
Expand Down
5 changes: 0 additions & 5 deletions ogc/bblocks/register-context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ context:
dateOfLastChange:
'@id': dct:modified
'@type': xsd:date
maturity:
'@id': bblocks:maturity
'@type': '@id'
'@context':
'@base': http://www.opengis.net/def/bblocks/maturity/
scope:
'@id': bblocks:scope
'@type': '@id'
Expand Down
Binary file added ogc/bblocks/slate-assets/images/ajax-loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions ogc/bblocks/slate-assets/javascripts/all_nosearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,92 @@ $(function() {
window.onpopstate = function() {
activateLanguage(getLanguageFromQueryString());
};

$(function() {
var $rainbowPopup = $('<div class="rainbow-popup">').hide().appendTo($('body'));

var showRainbowPopup = function($elem) {
var position = $elem.offset();
$rainbowPopup.show()
.css({
'left': position.left,
'top': position.top + $elem.outerHeight(),
});
};

var activeRainbow = null;

$('[data-rainbow-uri]').on('mouseover', function(e) {
var definitionPred = 'http://www.w3.org/2004/02/skos/core#definition';
var $this = $(this),
rainbowContent = $this.data('rainbow-content');

if (rainbowContent === false) {
// Failed
return;
}

if (rainbowContent) {
$rainbowPopup.html(rainbowContent);
showRainbowPopup($this);
return;
}
// Fetch rainbow
var uri = $this.data('rainbow-uri') || $this.attr('href');
if (!uri) {
$this.data('rainbow-content', false);
return;
}
activeRainbow = uri;
$rainbowPopup.html('').addClass('loading');
showRainbowPopup($this);
$.ajax(uri, {
'headers': {
'Accept': 'application/json',
},
'datatype': 'json',
})
.then(function(data) {
// Assume data is expanded JSON-LD
if (!Array.isArray(data)) {
data = [data];
}
var i, resource;
for (i = 0; i < data.length; i++) {
if (data[i]['@id'] === uri) {
resource = data[i];
break;
}
}
if (!resource || !resource[definitionPred]) {
$this.data('rainbow-content', false);
return;
}
var definitions = Array.isArray(resource[definitionPred])
? resource[definitionPred]
: [resource[definitionPred]],
definition;
for (i = 0; i < definitions.length; i++) {
if (definitions[i]['@value']) {
definition = definitions[i]['@value'];
break;
}
}
if (!definition) {
$this.data('rainbow-content', false);
return;
}
var contentFunc = definition[0] === '<' ? 'html' : 'text',
$contentT = $('<div class="title">').text($this.text()),
$contentP = $('<p>')[contentFunc](definition),
content = $('<div>').append($contentT).append($contentP).prop('innerHTML');
$this.data('rainbow-content', content);
if (activeRainbow === uri) {
$rainbowPopup.removeClass('loading').html(content);
}
});
}).on('mouseout', function() {
activeRainbow = null;
$rainbowPopup.hide();
});
});
36 changes: 36 additions & 0 deletions ogc/bblocks/slate-assets/stylesheets/screen.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,39 @@ aside a {
.content .highlight pre.highlight {
max-height: 30em;
}

.rainbow-popup {
position: absolute;
z-index: 999;
max-width: 400px;
padding: 0.6em 0.6em 0;
background: #8fbcd4 center no-repeat;
border-radius: 3px;
border: 1px solid #999;

.title {
font-weight: bold;
margin-bottom: 0.5em;
}

p {
margin-top: 0;
margin-bottom: 0.6em;
}

&.loading {
width: 32px;
height: 32px;
background-image: url(../images/ajax-loader.gif);

* {
display: none;
}
}
}

[data-rainbow-uri] {
cursor: help;
text-decoration: underline;
text-decoration-style: dotted;
}
4 changes: 1 addition & 3 deletions ogc/bblocks/templates/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

${bblock.abstract}

% if bblock.maturity:
[*Maturity*](https://github.com/cportele/ogcapi-building-blocks#building-block-maturity): ${bblock.maturity.capitalize()}
% endif
[*Status*](http://www.opengis.net/def/status): ${bblock.status.replace('-', ' ').capitalize()}

% if bblock.description:
${'##'} Description
Expand Down
5 changes: 4 additions & 1 deletion ogc/bblocks/templates/slate/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ ${'#'} ${bblock.name} `${bblock.identifier}`

${bblock.abstract}

[Maturity](https://github.com/cportele/ogcapi-building-blocks#building-block-maturity): ${bblock.maturity.capitalize()}
<p class="status">
<span data-rainbow-uri="http://www.opengis.net/def/status">Status</span>:
<a href="http://www.opengis.net/def/status/${bblock.status}" target="_blank" data-rainbow-uri>${bblock.status.replace('-', ' ').capitalize()}</a>
</p>

% if bblock.validationPassed:
<aside class="success">
Expand Down

0 comments on commit a3ec2e0

Please sign in to comment.