Skip to content

Commit

Permalink
Results count added to search interface on Explore page
Browse files Browse the repository at this point in the history
Proper subject labels used on biographies list
  • Loading branch information
JaseMK committed May 25, 2023
1 parent b682fbb commit 1691bec
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 14 deletions.
7 changes: 2 additions & 5 deletions website/biographies.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<th>Name</th>
<th>Born</th>
<th>Died</th>
<th>Publish date</th>
</tr>
</thead>
<tfoot>
Expand All @@ -74,7 +73,6 @@
<th>Name</th>
<th>Born</th>
<th>Died</th>
<th>Publish date</th>
</tr>
</tfoot>
<tbody>
Expand All @@ -83,7 +81,6 @@
<td>loading...</td>
<td>loading...</td>
<td>loading...</td>
<td>loading...</td>
</tr>

</tbody>
Expand Down Expand Up @@ -161,8 +158,8 @@
$.getJSON("services/biographies.php", function(result){
$.each(result, function(i, field){
html = '<tr><td>' ;
html += '<a href="biography.php?id=' + field + '">' + field + '</a></td>';
html += '<td> - </td><td> - </td><td> - </td></tr>';
html += '<a href="biography.php?id=' + field.subject + '">' + field.subject_label + '</a></td>';
html += '<td>' + field.dob + '</td><td>' + field.dod + '</td></tr>';
$('#dataTable tr:last').after(html);
});
$('#dataTable').DataTable();
Expand Down
17 changes: 14 additions & 3 deletions website/explore.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function createGeoJson(inputData) {
"when": inputData[i].when,
"purpose": inputData[i].purpose,
"subject": inputData[i].subject,
"subject_label": inputData[i].subject_label,
"location": inputData[i].location,
"index": i
},
Expand Down Expand Up @@ -256,7 +257,7 @@ function onEachFeature(feature, layer) {
if (feature.properties) {
//console.log(feature.properties);
html = "";
html += "<p><strong>Subject: </strong>" + feature.properties.subject + "</p>";
html += "<p><strong>Subject: </strong>" + feature.properties.subject_label + "</p>";
html += "<p><strong>Participants: </strong>" + feature.properties.participants + "</p>";
html += "<p><strong>Purpose: </strong>" + feature.properties.purpose + "</p>";
html += "<p><strong>Location: </strong>" + feature.properties.location + "</p>";
Expand Down Expand Up @@ -286,6 +287,7 @@ function populateDetailsPanel(index) {
html = '';
html += '<p><strong>When</strong>: ...</p>';
html += '<p><strong>Where</strong>: ' + meetupDetails.location;
html += '<p><strong>Subject</strong>: ' + meetupDetails.subject_label;
html += '<p><strong>Participants</strong>: ' + meetupDetails.participants + '</p>';
html += '<p><strong>Purpose</strong>: ' + meetupDetails.purpose + '</p>';
html += '<p><strong>Evidence</strong>: ' + meetupDetails.evidence_text + '</p>';
Expand All @@ -301,7 +303,7 @@ function populateDetailsPanel(index) {
const map = L.map('map').setView([52, -0.7], 8);

const tiles = L.tileLayer('https://osm.gs.mil/tiles/humanitarian/{z}/{x}/{y}.png', {
maxZoom: 19,
maxZoom: 14,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var pointsLayer = L.geoJSON().addTo(map);
Expand All @@ -319,20 +321,29 @@ function populateDetailsPanel(index) {
//console.log(result);
$("#tbodyid").empty();
meetupsData = result;
resultsCount = 0;
$('#resultsCount').text(resultsCount);
$("#resultsCountWarning").addClass("d-none");
$.each(result, function(i, field){
resultsCount ++;
buttonHtml = '<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#meetupModal" onclick="populateDetailsPanel('+i+');"><i class="fas fa-search-plus"></i></button> ';

html = '<tr>';

html += '<td>' + buttonHtml + '...</td>';
html += '<td>' + field.subject + '</td>';
html += '<td>' + field.subject_label + '</td>';
html += '<td>' + field.participants + '</td>';
html += '<td>' + field.location + '</td>';
html += '<td>' + field.purpose + '</td>';

html += '</tr>';
$("#meetupsTable tbody").append(html);
});

$('#resultsCount').text(resultsCount);
if (resultsCount >= 500) {
$("#resultsCountWarning").removeClass("d-none");
}
$('#meetupsTable').DataTable();

/*
Expand Down
27 changes: 25 additions & 2 deletions website/services/biographies.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<?php
header('Content-Type: application/json; charset=utf-8');

//$sparql = "prefix mtp: <http://w3id.org/polifonia/ontology/meetups-ontology#> select distinct ?biography from <http://data.open.ac.uk/context/meetups> where { ?s mtp:hasSubject ?biography }";
$sparql = 'PREFIX mtp: <http://w3id.org/polifonia/ontology/meetups-ontology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
$sparql = "prefix mtp: <http://w3id.org/polifonia/ontology/meetups-ontology#> select distinct ?biography from <http://data.open.ac.uk/context/meetups> where { ?s mtp:hasSubject ?biography }";
SELECT DISTINCT ?subject ?subject_label ?dob ?dod
FROM <http://data.open.ac.uk/context/meetups>
WHERE {
?meetup mtp:hasSubject ?subject .
?subject rdfs:label ?subject_label ;
mtp:hasdob ?dob ;
mtp:hasdod ?dod
}';
$sparql_encoded = urlencode($sparql);
$curl = curl_init();

Expand Down Expand Up @@ -29,8 +42,18 @@
//print_r($responseObj->results->bindings);
$bindings = $responseObj->results->bindings;
$outputObj = [];
/*
foreach ($bindings as $binding) {
$outputObj[] = $binding->biography->value;
}
header('Content-Type: application/json; charset=utf-8');
*/
foreach ($bindings as $binding) {
$tempObject = [
'subject' => $binding->subject->value,
'subject_label' => $binding->subject_label->value,
'dob' => $binding->dob->value,
'dod' => $binding->dod->value
];
$outputObj[] = $tempObject;
}
echo(json_encode($outputObj));
6 changes: 4 additions & 2 deletions website/services/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo: <https://www.w3.org/2003/01/geo/wgs84_pos>
SELECT ?subject ?meetup ?evidence_text ?purpose
SELECT ?subject_label ?subject ?meetup ?evidence_text ?purpose
(GROUP_CONCAT( DISTINCT ?participant; separator=", " ) as ?participants_URI )
(GROUP_CONCAT( DISTINCT ?participant_label; separator=", " ) as ?participants_label )
(GROUP_CONCAT( DISTINCT ?location_uri; separator=", " ) as ?locations_URI )
Expand All @@ -26,6 +26,7 @@
mtp:hasAPurpose ?purpose_uri ;
mtp:hasEvidenceText ?evidence_text ;
mtp:hasPlace ?location_uri .
?subject rdfs:label ?subject_label .
'.$purposeFilter.'
'.$subjectFilter.'
'.$participantFilter.'
Expand All @@ -45,7 +46,7 @@
LIMIT 1
}
}
GROUP BY ?subject ?meetup ?evidence_text ?purpose ?time_expression_URI ?lat ?long
GROUP BY ?subject_label ?subject ?meetup ?evidence_text ?purpose ?time_expression_URI ?lat ?long
LIMIT 500';

//echo($sparql);
Expand Down Expand Up @@ -85,6 +86,7 @@
'when' => $binding->time_expression_URI->value,
'purpose' => $binding->purpose->value,
'subject' => $binding->subject->value,
'subject_label' => $binding->subject_label->value,
'evidence_text' => $binding->evidence_text->value,
'participants' => $binding->participants_label->value,
'location' => $binding->locations_label->value,
Expand Down
11 changes: 9 additions & 2 deletions website/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
<!-- Nav Item - Pages Collapse Menu -->

<li class="nav-item">
<a class="nav-link " href="#" data-toggle="collapse" data-target="#collapseTwo"
<a class="nav-link" href="#" data-toggle="collapse" data-target="#collapseTwo"
aria-expanded="true" aria-controls="collapseTwo">
<i class="fas fa-filter"></i>
<span>Filters</span>
</a>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
<div class="bg-white py-2 collapse-inner rounded">

<form id="searchForm">
Expand All @@ -82,6 +82,13 @@
<input type="text" class="form-control sidebar-search" id="place">
</div>
<hr />
<div class="text-center">
Results: <span id="resultsCount">0</span>
<a id="resultsCountWarning" href="#" class="btn btn-warning btn-circle btn-sm d-none" data-toggle="tooltip" data-placement="top" title="Max search limit reached">
<i class="fas fa-exclamation-triangle"></i>
</a>
</div>
<hr />
<div class="text-center">
<button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-sync"></i> Reload</button>
</div>
Expand Down

0 comments on commit 1691bec

Please sign in to comment.