Skip to content

Commit

Permalink
Merge branch 'main' of github.com:iodepo/oih-ui into feature/restyling
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/public/index.html
#	frontend/src/components/results/types/CreativeWork.json
#	frontend/src/components/results/types/Dataset.json
  • Loading branch information
[email protected] authored and [email protected] committed Sep 13, 2024
2 parents 88bb45e + 4848145 commit 64bfde0
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 100 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/check-crlf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout repository contents
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use action to check for CRLF endings
uses: erclu/[email protected]
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/irc_notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: irc push
uses: rectalogic/notify-irc@v1
uses: rectalogic/notify-irc@v2
if: github.event_name == 'push'
with:
channel: "#oih"
Expand All @@ -26,7 +26,7 @@ jobs:
${{ github.actor }} pushed ${{ github.event.ref }} ${{ github.event.compare }}
${{ join(github.event.commits.*.message) }}
- name: irc pull request
uses: rectalogic/notify-irc@v1
uses: rectalogic/notify-irc@v2
if: github.event_name == 'pull_request'
with:
channel: "#oih"
Expand All @@ -35,8 +35,9 @@ jobs:
notice: true
message: |
${{ github.actor }} opened PR ${{ github.event.pull_request.html_url }}
${{ github.event.pull_request.title }}
- name: irc tag created
uses: rectalogic/notify-irc@v1
uses: rectalogic/notify-irc@v2
if: github.event_name == 'create' && github.event.ref_type == 'tag'
with:
channel: "#oih"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Ocean InfoHub
Copyright (c) 2024 Ocean InfoHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ This repo contains the code for the Ocean Info Hub Global Search Portal.
* `/indexer` contains all of the code to ingest the OIH graph into the SOLR Instance
* `/solr` contains the configuration required for the solr instance, including the schema.
* `/frontend` contains the code for the static javascript app. This will produce a container in dev mode running a live server, and a static html/javascript site in production mode.
* `/regions` contains the QGIS file defining the gographical regions.
* `/regions` contains the QGIS file defining the geographical regions.

See the individual README files for more information.
127 changes: 47 additions & 80 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -1,82 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="OIH" content="OIH Global Search" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/maplibre-gl.css"
/>
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<script src="https://www.unpkg.com/[email protected]/turf.min.js"></script>
<script src="https://www.unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-draw.js"></script>
<link
rel="stylesheet"
href="https://www.unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-draw.css"
type="text/css"
/>
<title>OIH Global Search</title>
<style>
.oih-popover {
margin: auto;
width: 100%;
padding: 20px;
background-color: #012e6a;
color: white;
}
</style>
<!-- Matomo -->
<script>
var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
/* _paq.push(["trackPageView"]); */
_paq.push(["enableLinkTracking"]);
(function () {
var u = "//analytics.iode.org/";
_paq.push(["setTrackerUrl", u + "matomo.php"]);
_paq.push(["setSiteId", "1"]);
var d = document,
g = d.createElement("script"),
s = d.getElementsByTagName("script")[0];
g.async = true;
g.src = u + "matomo.js";
s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<!-- <script>
//open first popover available in your page
let popover = document.getElementById("popover");
popover.style.display = "block";
</script>
<div
class="oih-popover"
role="dialog"
id="popover"
data-scrollable-element="#scrollable-element"
>
<h1>This is still a beta version.</h1>
This page is the beta-version of the search interface for the OIH project
proof of concept.<br />
Please visit the
<a href="https://oceaninfohub.org">project's website</a> for more
information.<br />
<br />
<a
href="#"
onclick="let popover = document.getElementById('popover');popover.style.display = 'none';"
>
close this warning
</a>
</div> -->
<div id="root"></div>
</body>
</html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="OIH" content="OIH Global Search"/>
<title>OIH Global Search</title>
<style>
.oih-popover {
margin: auto;
width: 100%;
padding: 20px;
background-color: #012e6a;
color: white;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script>
//we don't want people to visit this page, redirect to the homepage
window.location.replace("https://oceaninfohub.org");

//all what follows is useless as we are redirecting to the homepage

//open first popover available in your page
//let popover = document.getElementById('popover');
//popover.style.display = "block";
</script>
<!--
<div
class="oih-popover"
role="dialog"
id="popover"
data-scrollable-element="#scrollable-element">
<h1>This is still a beta version.</h1>
This page is the beta-version of the search interface for the OIH project proof of concept.<br />
Please visit the <a href="https://oceaninfohub.org">project's website</a> for more information.<br />
<br />
<a
href="#"
onclick="let popover = document.getElementById('popover');popover.style.display = 'none';">
close this warning
</a>
</div>
-->
<div id="root"></div>
</body>
</html>
22 changes: 22 additions & 0 deletions frontend/src/components/results/types/CreativeWork.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"key": "id",
"type": ["truncated", "link"]
},
{
"key": "txt_author",
"type": "list",
"label": "Author(s)"
},
"txt_identifier",
{
"key": "txt_keywords",
"type": "keywords"
},
{
"key": "txt_contributor",
"type": "list",
"label": "Contributor(s)"
},
{ "key": "txt_distribution", "type": ["list", "link"] }
]
19 changes: 19 additions & 0 deletions frontend/src/components/results/types/Dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
"name",
{ "key": "txt_sameAs", "type": ["list", "truncated", "link"] },
{ "key": "txt_license", "type": "list", "label": "License" },
{ "key": "txt_citation", "type": "list", "label": "Related Works" },
{ "key": "txt_creditText", "type": "list", "label": "Recommended Citation" },
"txt_version",
{ "key": "txt_keywords", "type": "keywords" },
{
"key": "id_includedInDataCatalog",
"type": ["list", "link"],
"label": "Data Catalog"
},
"txt_temporalCoverage",
{ "key": "txt_distribution", "type": ["list", "link"] },
{ "key": "txt_region", "type": "list" },
{ "key": "id_provider", "type": ["list", "link"], "label": "Provider ID" },
{ "key": "txt_provider", "type": "list" }
]
17 changes: 16 additions & 1 deletion indexer/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ def GeoShape(geo):
raise UnhandledFormatException("Didn't handle %s in GeoShape" % json.dumps(geo))


def GeoCoordinates(geo):
#print('here [GeoCoordinates]')

lat = geo.get("latitude",None)
long = geo.get("longitude",None)
if lat is not None and long is not None:
print ("Generating a Point from the GeoCoordinates...")
newPoint = "POINT (" + str(long) + " " + str(lat) + ")"
print(newPoint)
return _geo('point', newPoint)

raise UnhandledFormatException("Didn't handle %s in GeoCoordinates" % json.dumps(geo))



def CourseInstance(data):
atts = [_dispatch(field, data.get(field, None)) for field in ('startDate', 'endDate')]
if 'location' in data:
Expand Down Expand Up @@ -239,7 +254,7 @@ def _parseDate(field, d):
try:
dt = isoparse(d)
return [
Att('dt', dt.isoformat(), field),
Att('dt', dt.isoformat(timespec='seconds').replace('+00:00', 'Z'), field),
Att('n', dt.year, field.replace('Date', 'Year')),
]
except ValueError:
Expand Down
89 changes: 89 additions & 0 deletions indexer/indexer-graph-solr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env python3

"""
Purpose: Load a directory of JSON files, generated from the ODIS graph->Solr
process (mdp2solr.sh), into an existing Solr core.
Steps: 1) set your Solr core endpoint variable at the commandline by:
export SOLR_URL=http://127.0.0.1:8983/solr/cioos
2) set the path to the directory of JSON files, at the commandline by:
export DATA_DIR=/home/apps/oih-ui-jmckenna/indexer/data/test
3) python indexer-graph-solr.py
Output: Records indexed into the Solr core. Look for the "added resource" message
in the command window (which means it successfully indexed into Solr) such as:
***Processing filename: /home/apps/oih-ui-jmckenna/indexer/data/test/ttt1.json
added resource https://catalogue.cioos.ca/dataset/00863729-b5a8-4ac6-b73a-523d463f9963.jsonld: schema:Dataset to index
***Processing filename: /home/apps/oih-ui-jmckenna/indexer/data/test/ttt2.json
added resource https://catalogue.cioos.ca/dataset/d1391e91-1ed2-4600-901a-5a5408fd1a6f.jsonld: schema:Dataset to index
Requires: Python 3.x
Notes:
Input files are JSON (not JSON-LD that the orginal "indexer.py" required)
"""

import requests
import json
import os
from pathlib import Path
from test_utils import test_generation, dump_exception

#set urls
BASE_SOLR_URL=os.environ.get('SOLR_URL', '')
solr_url = BASE_SOLR_URL + "/update/json/docs"
delete_url = BASE_SOLR_URL + "/update"
query_url = BASE_SOLR_URL + "/select"

DATA_DIR=os.environ.get('DATA_DIR')
BASE_DIR=Path(DATA_DIR)

session = requests.Session()

# set Solr params
solr_params = {
'commit': 'true',
# echo implies a dry run
# 'echo': 'true',
}

#loop through directory
def import_file(file):
with open(file, 'rb') as f:
print ("***Processing filename: " + f.name)
try:
orig = json.load(f)
except UnicodeDecodeError:
f.seek(0)
file_bytes= f.read()
try:
file_string = file_bytes.decode('latin1')
orig = json.loads(file_string)
except Exception as msg:
print ("Issue decoding %s, continuing" % filename)
shutil.copy(src, os.path.join('exceptions', filename.split('/')[-1]))
return

data = orig
data['keys'] = list(data.keys())
# print (json.dumps(data, indent=2))
data['json_source'] = json.dumps(data)
solr_post = session.post(solr_url, params=solr_params, json=data)
try:
solr_post.raise_for_status()
print("added resource %s: %s to index" % (data['id'], data['type']))
except:
dump_exception(orig, solr_post.text)
return
#print(solr_post.text)

for item in os.scandir(BASE_DIR):
import_file(item)

Loading

0 comments on commit 64bfde0

Please sign in to comment.