Skip to content

Commit

Permalink
Merge pull request #35 from netwerk-digitaal-erfgoed/feat-newest-data…
Browse files Browse the repository at this point in the history
…sets

Feature recently added datasetdescriptions
  • Loading branch information
coret authored Dec 23, 2023
2 parents 12abb15 + 54993cd commit 44449a6
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 3 deletions.
10 changes: 10 additions & 0 deletions web/.well-known/api-catalog/linkset.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"title": "SPARQL 1.1 Query Language"
}
]
},
{
"anchor": "https://datasetregister.coret.org/dataset-newest-rss.php",
"service-doc": [
{
"href": "https://www.rssboard.org/rss-specification",
"type": "text/html",
"title": "RSS 2.0 Specification"
}
]
}
]
}
Binary file added web/assets/beeldmerk-social-small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions web/dataset-newest-rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

include("includes/search.php");
include("includes/language.php");

header('Content-Type: application/rss+xml; charset=utf-8');
echo "<"."?xml version=\"1.0\" encoding='UTF-8'?".">\n";

echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
echo '<channel>';
echo '<title>'.t('Datasetregister').'</title>';
echo '<link>https://'.$_SERVER['HTTP_HOST'].'/</link>';
echo '<language>';
if(isset($_GET["lang"]) && $_GET["lang"]=="en") { echo "en"; } else { echo "nl"; }
echo '</language>';
echo '<description>'.t('De meest recent toegevoegde datasets aan het NDE Datasetregister').'</description>';
echo '<pubDate>'.date("r").'</pubDate>'."\n";
echo '<image>'."\n";
echo '<url>https://'.$_SERVER['HTTP_HOST'].'/assets/beeldmerk-social-small.jpg</url>'."\n";
echo '<title>'.t('Datasetregister').'</title>'."\n";
echo '<link>https://'.$_SERVER['HTTP_HOST'].'/</link>'."\n";
echo '</image>'."\n";
echo '<atom:link href="https://'.$_SERVER['HTTP_HOST'].'/dataset-newest-rss.php" rel="self" type="application/rss+xml" />'."\n";

$newests=getNewest();

foreach($newests as $newest) {
print '<item>';
print '<title>'.$newest["title"].' ('.$newest["publisherName"].')</title>';
$url='https://'.$_SERVER['HTTP_HOST'].'/show.php?';
if(isset($_GET["lang"]) && $_GET["lang"]=="en") { $url.='lang=en&'; }
$url.='uri='.urlencode($newest["dataset"]);
print '<link>'.$url.'</link>';
print '<guid>'.$url.'</guid>';
print '<pubDate>'.date('r', strtotime($newest["postedDate"])).'</pubDate>';
print '</item>';
}

echo '</channel>';
echo '</rss>';
55 changes: 55 additions & 0 deletions web/dataset-newest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

include("includes/search.php");
include("includes/header.php");

?>

<main>
<section class="text m-t-space m-b-space m-theme--blue">
<div class="o-container o-container__small m-t-space">
<h1 class="title--l"><?= t('Recent aangemelde databeschrijvingen') ?></h1>
<p><?= t('Onderstaande lijst toont de').' '.SHOW_NEWEST.t('meest recent aangemelde datasetbeschrijvingen via de <a href="viaurl.php">Meld aan</a> pagina of de <a href="https://datasetregister.netwerkdigitaalerfgoed.nl/api/static/index.html">Dataset Register API</a>.') ?> <?= t('Deze lijst is ook beschikbaar als <a href="dataset-newest-rss.php">RSS feed</a>.') ?></p>
<p><br></p>
<ul id="newest_list"></ul>
</div>
</section>

<section class="text m-t-space m-b-space">
<div class="o-container o-container__small m-t-space">
<a href="search.php<?= l() ?>"><span class="btn btn--arrow m-t-half-space"><?= t('Doorzoek het Dataset Register') ?> <svg class="rect"> <rect class="svgrect" width="100%" height="100%" style="stroke-width: 3; fill: transparent; stroke-dasharray: 578; stroke-dashoffset: 578;"></rect> </svg> <svg class="icon icon-arrow-right"> <use xlink:href="#icon-arrow-right"></use> </svg> </span></a>
</div>
</section>
</main>
<script>

async function fetchData(url) {
try {
const response = await fetch(url);
const jsonData = await response.json();
return jsonData;
} catch (error) {
console.error('Error fetching data:', error);
}
}

fetchData('get-list.php?list=newest').then(data => {
const ul = document.getElementById("newest_list");
ul.innerHTML = "";

for (const key in data) {
const li = document.createElement('li');
li.setAttribute("class", "linkprop");
var link = document.createElement("a");
var linkText = document.createTextNode(data[key].title);
link.setAttribute("href", "show.php?<?php if(isset($_GET["lang"]) && $_GET["lang"]=="en") { echo "lang=en&"; } ?>uri="+encodeURIComponent(data[key].dataset));
link.setAttribute("title", "<?= t('Aangemeld op') ?> "+data[key].postedDate.substr(8,2)+"-"+data[key].postedDate.substr(5,2)+"-"+data[key].postedDate.substr(0,4)+" ("+data[key].postedDate.substr(11,5)+")");
link.appendChild(linkText);
li.appendChild(link);
li.appendChild(document.createTextNode(" ("+data[key].publisherName+")"));
ul.appendChild(li);
}
});

</script>
<?php include("includes/footer.php") ?>
11 changes: 10 additions & 1 deletion web/includes/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,16 @@
'Welke musea bieden linked data?'=>'Which museums offer linked data?',
'Het volgende overzicht laat de linked data datasets zien van musea:'=>'The following overview shows the linked data datasets of museums:',
'Welke data bevatten informatie uit bevolkingsregisters?'=>'Which data contain information from population registers?',
'Het volgende overzicht laat datasets zien die als keyword "bevolkingsregister" hebben:'=>'The following overview shows datasets with the Dutch keyword "bevolkingsregister" (=population register):'
'Het volgende overzicht laat datasets zien die als keyword "bevolkingsregister" hebben:'=>'The following overview shows datasets with the Dutch keyword "bevolkingsregister" (=population register):',

# dataset-newest.php
'Recent aangemelde databeschrijvingen'=>'Recently submitted data descriptions',
'Onderstaande lijst toont de'=>'The list below shows the',
'meest recent aangemelde datasetbeschrijvingen via de <a href="viaurl.php">Meld aan</a> pagina of de <a href="https://datasetregister.netwerkdigitaalerfgoed.nl/api/static/index.html">Dataset Register API</a>.'=>'most recently registered dataset descriptions via the <a href="viaurl.php">Submit</a> page or the <a href="https://datasetregister.netwerkdigitaalerfgoed.nl /api/static/index.html">Dataset Register API</a>.',
'Aangemeld op'=>'Registered on',
'De meest recent toegevoegde datasets aan het NDE Datasetregister'=>'The most recently added datasets to the NDE Dataset Register',
'Deze lijst is ook beschikbaar als <a href="dataset-newest-rss.php">RSS feed</a>.'=>'This list is also available as <a href="dataset-newest-rss.php?lang=en">RSS feed</a>.',
'Er is ook een overzicht beschikbaar van <a href="dataset-newest.php">recent aangemelde datasetbeschrijvingen</a>.'=>'An overview of <a href="dataset-newest.php?lang=en">recently submitted dataset descriptions</a> is also available.'

);

Expand Down
38 changes: 38 additions & 0 deletions web/includes/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
define('SPARQL_ENDPOINT', 'https://triplestore.netwerkdigitaalerfgoed.nl/repositories/registry');
define('SPARQL_CACHE_DURATION_HOURS',1);
define('CACHE_DIRECTORY','/tmp/');
define('SHOW_NEWEST',25);

function getFormats() {
$sparqlGetPublishers='PREFIX dct: <http://purl.org/dc/terms/>
Expand Down Expand Up @@ -77,6 +78,43 @@ function getPublishers() {
return $publishers;
}

function getNewest() {

if(isset($_GET["lang"]) && $_GET["lang"]=="en") {
$lang="en"; $bilang="nl";
} else {
$lang="nl"; $bilang="en";
}

$sparqlGetPublishers='PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?dataset ?title ?publisherName ?postedDate WHERE {
?postedURL <http://schema.org/about> ?dataset ;
<http://schema.org/datePosted> ?postedDate .
?dataset dct:publisher ?publisher .
OPTIONAL { ?dataset dct:title ?title FILTER(langMatches(lang(?title), "'.$lang.'")) }
OPTIONAL { ?dataset dct:title ?title FILTER(langMatches(lang(?title), "'.$bilang.'")) }
OPTIONAL { ?dataset dct:title ?title }
OPTIONAL { ?publisher foaf:name ?publisherName FILTER(langMatches(lang(?publisherName), "'.$lang.'")) }
OPTIONAL { ?publisher foaf:name ?publisherName FILTER(langMatches(lang(?publisherName), "'.$bilang.'")) }
OPTIONAL { ?publisher foaf:name ?publisherName }
} ORDER BY DESC(?postedDate) LIMIT '.SHOW_NEWEST;

$sparqlResults=getSPARQLresults($sparqlGetPublishers,$lang);

$newest=array();
if (isset($sparqlResults)) {
foreach ($sparqlResults["results"]["bindings"] as $item) {
$newest[]=array("dataset"=>$item["dataset"]["value"],
"title"=>$item["title"]["value"],
"publisherName"=>$item["publisherName"]["value"],
"postedDate"=>$item["postedDate"]["value"]);
}
}
return $newest;
}

function getSPARQLresults($sparqlQueryString,$lang) {
$cacheFile=CACHE_DIRECTORY.md5($sparqlQueryString).".".$lang.".json";
if (file_exists($cacheFile) && filesize($cacheFile)>0 && (time() - filectime($cacheFile))/3600<SPARQL_CACHE_DURATION_HOURS && !isset($_GET["nocache"])) {
Expand Down
4 changes: 2 additions & 2 deletions web/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<section class="text m-t-space m-b-space m-theme--blue">
<div class="o-container o-container__small m-t-space">
<h1 class="title--l"><?= t('Doorzoek alle datasetbeschrijvingen') ?></h1>
<p><?= t('Door erfgoedinstellingen aangemelde datasetbeschrijvingen worden opgeslagen in een openbare <a target="triplestore" href="https://triplestore.netwerkdigitaalerfgoed.nl/">triplestore</a> op basis van het DCAT <a href="datamodel.php">datamodel</a>. Via de <a href="datastory.php">datastory</a> leer je hoe te zoeken middels SPARQL. Deze pagina toont een zoekinterface op het datasetregister. Ook is dit een hulpmiddel voor het maken van SPARQL queries om de datasetbeschrijvingen te doorzoeken.')?></p>
<p><?= t('Door erfgoedinstellingen aangemelde datasetbeschrijvingen worden opgeslagen in een openbare <a target="triplestore" href="https://triplestore.netwerkdigitaalerfgoed.nl/">triplestore</a> op basis van het DCAT <a href="datamodel.php">datamodel</a>. Via de <a href="datastory.php">datastory</a> leer je hoe te zoeken middels SPARQL. Deze pagina toont een zoekinterface op het datasetregister. Ook is dit een hulpmiddel voor het maken van SPARQL queries om de datasetbeschrijvingen te doorzoeken.')?> <?= t('Er is ook een overzicht beschikbaar van <a href="dataset-newest.php">recent aangemelde datasetbeschrijvingen</a>.') ?></p>
</div>
</section>
<section id="" class="m-t-quarter-space m-theme-bg m-theme--teal search-div">
Expand Down Expand Up @@ -108,7 +108,7 @@ function updateSparql() {
.join('" || ?format="') + "\")\n";
}

sparqlQuery += "} ORDER BY ?title";
sparqlQuery += "} ORDER BY ?title LIMIT 200";

document.getElementById('sparql-query')
.innerHTML = sparqlQuery;
Expand Down

0 comments on commit 44449a6

Please sign in to comment.