Skip to content

Commit

Permalink
minor upgrade for NASA-PDS/registry-api#227 and url with only major v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
thomas loubrieu committed Jan 23, 2023
1 parent f540de1 commit cba602a
Show file tree
Hide file tree
Showing 30 changed files with 764 additions and 2,629 deletions.
4 changes: 2 additions & 2 deletions _sources/guides/search.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Search API User Guide

.. note::

The current guide is based on the PDS Search API version |search_user_guide_api_version|
The current guide is based on the PDS Search API version |search_user_guide_api_spec_version|

.. Warning::
Since our servers are not fully populated with all PDS data sets, the examples presented in this user guide may return empty results or 404 (Not Found) errors. If there is a data set you would like added, please contact the `PDS Help Desk <mailto:[email protected]>`_ for assistance.
Expand All @@ -22,6 +22,6 @@ These pages provide a user guide for the PDS Search API.

search/quickstart
search/endpoints
search/response_formats
search/responses
search/tutorials
API Full Reference <https://nasa-pds.github.io/pds-api/specifications/search-v1.1.0-redoc.html>
16 changes: 15 additions & 1 deletion _sources/guides/search/cookbook.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Search For Product Versions
Recipes for searching for the latest version of a product, or all versions of a product, including superseded versions.

.. Warning::
Since our servers are not fully populated with all PDS data sets, the examples presented in this user guide may return empty results or 404 (Not Found) errors. If there is a data set you would like added, please contact the `PDS Help Desk <mailto:pds-operator@jpl.nasa.gov>`_ for assistance.
Since our servers are not fully populated with all PDS data sets, the examples presented in this user guide may return empty results or 404 (Not Found) errors. If there is a data set you would like added, please submit a request to the `PDS Help Desk <https://pds.nasa.gov/?feedback=true>`_ for assistance.


Search the Latest Version of a Product
Expand Down Expand Up @@ -87,6 +87,20 @@ Search for all Observational Products targeting Bennu:
curl --get 'https://pds.nasa.gov/api/search/|search_user_guide_api_version|/classes/collections' \
--data-urlencode 'q=(ref_lid_target eq "urn:nasa:pds:context:target:asteroid.101955_bennu")'
Search by reference
-------------------

Search all products which are referring to a given LID:

.. code-block:: bash
:caption: curl command
:substitutions:
curl --get 'https://pds.nasa.gov/api/search/|search_user_guide_api_version|//products' \
--data-urlencode 'limit=200' \
--data-urlencode 'q=((pds:Internal_Reference.pds:lid_reference eq "urn:nasa:pds:context:investigation:mission.orex") or (pds:Internal_Reference.pds:lid_reference like "urn:nasa:pds:context:investigation:mission.orex::*"))' | json_pp
----

Search for DOIs
Expand Down
13 changes: 7 additions & 6 deletions _sources/guides/search/endpoints.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ geo Geosciences
img Imaging
naif Navigation and Ancillary Information
ppi Planetary Plasma Interactions
psa ESA Planetary Science Archive
rms Ring-Moon Systems
sbnumd Small Bodies, Comets
sbnpsi Small Bodies, Asteroids/Dust
Expand Down Expand Up @@ -95,12 +96,12 @@ The query parameters are:
==================== =========================================================================================================================================================================================================================== ====================
**Query Parameter** **Description** **Example**
==================== =========================================================================================================================================================================================================================== ====================
q (Optional, string) Query string you wish to parse and use for search. See `query string syntax`_ q=target_name eq "Mars"
keyword (Optional, string) String used for text search on title and description of the PDS4 labels keyword=insight
fields (Optional, array of strings) Array of fields you wish to return. fields=lid,pds:Time_Coordinates.pds:start_date_time
start (Optional, integer, default=0) The search result to start with in the returned records. For instance, start=10 will return records 10-19. Useful for pagination of the results. start=100
limit (Optional, integer, default=100) The number of records/results to return. By specifying a value of 0 only the summary of the results is returned, not the individual results. limit=100
sort (Optional, string, default=LIDVID) Field to sort on and whether it should be sorted ascending (ASC) or descending (DESC). `fieldName asc` or `fieldName desc`. There can be several sort parameters (order is important). sort=lidvid asc, pds:Time_Coordinates.pds:start_date_time desc
q (Optional, string) Query string you wish to parse and use for search. See `query string syntax`_ q=target_name eq "Mars"
keywords (Optional, string) String used for text search on title and description of the PDS4 labels keyword=insight
fields (Optional, array of strings) Array of fields you wish to return. fields=pds:Time_Coordinates.pds:start_date_time
start (Optional, integer, default=0) The search result to start with in the returned records. For instance, start=10 will return records 10-19. Useful for pagination of the results. start=100
limit (Optional, integer, default=100) The number of records/results to return. By specifying a value of 0 only the summary of the results is returned, not the individual results. limit=100
sort (Optional, string, default=LIDVID) Field to sort on and whether it should be sorted ascending (ASC) or descending (DESC). `fieldName asc` or `fieldName desc`. There can be several sort parameters (order is important). sort=lidvid asc, pds:Time_Coordinates.pds:start_date_time desc
==================== =========================================================================================================================================================================================================================== ====================

`q` and `fields` use PDS4 `Fields Dot Notation`_
Expand Down
7 changes: 6 additions & 1 deletion _sources/guides/search/tutorials.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ https://github.com/NASA-PDS/pds-api-notebook/

Web Search Interface Tutorial (HTML/Javascript)
-----------------------------------------------
TO BE IMPLEMENTED

When developing a web client to the API, if you are not from JPL, contact us ([email protected]) so that we can set the CORS attributes for you.

If you are on JPL's network, develop your application locally on port 80 on your laptop connected to the VPN and test your application with URL http://localhost.jpl.nasa.gov/....

TO BE COMPLETED


Search Examples
Expand Down
2 changes: 1 addition & 1 deletion _sources/support/contact.rst.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contact Us
==========

Feel free to post a question on the `PDS API Discussion Board <https://github.com/NASA-PDS/pds-api/discussions>`_ or contact the `PDS Help Desk <mailto:pds-operator@jpl.nasa.gov>`_ directly for any additional questions, comments or concerns.
Feel free to post a question on the `PDS API Discussion Board <https://github.com/NASA-PDS/pds-api/discussions>`_ or submit a request to the `PDS Help Desk <https://pds.nasa.gov/?feedback=true>`_ for any additional questions, comments or concerns.
31 changes: 30 additions & 1 deletion _static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ ol.simple p,
ul.simple p {
margin-bottom: 0;
}

/* Docutils 0.17 and older (footnotes & citations) */
dl.footnote > dt,
dl.citation > dt {
float: left;
Expand All @@ -625,6 +627,33 @@ dl.citation > dd:after {
clear: both;
}

/* Docutils 0.18+ (footnotes & citations) */
aside.footnote > span,
div.citation > span {
float: left;
}
aside.footnote > span:last-of-type,
div.citation > span:last-of-type {
padding-right: 0.5em;
}
aside.footnote > p {
margin-left: 2em;
}
div.citation > p {
margin-left: 4em;
}
aside.footnote > p:last-of-type,
div.citation > p:last-of-type {
margin-bottom: 0em;
}
aside.footnote > p:last-of-type:after,
div.citation > p:last-of-type:after {
content: "";
clear: both;
}

/* Footnotes & citations ends */

dl.field-list {
display: grid;
grid-template-columns: fit-content(30%) auto;
Expand All @@ -636,11 +665,11 @@ dl.field-list > dt {
padding-left: 0.5em;
padding-right: 5px;
}

dl.field-list > dt:after {
content: ":";
}


dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
Expand Down
4 changes: 2 additions & 2 deletions _static/css/theme.css

Large diffs are not rendered by default.

130 changes: 119 additions & 11 deletions _static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
*/
"use strict";

const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
"TEXTAREA",
"INPUT",
"SELECT",
"BUTTON",
]);

const _ready = (callback) => {
if (document.readyState !== "loading") {
callback();
Expand All @@ -25,11 +18,73 @@ const _ready = (callback) => {
}
};

/**
* highlight a given string on a node by wrapping it in
* span elements with the given class name.
*/
const _highlight = (node, addItems, text, className) => {
if (node.nodeType === Node.TEXT_NODE) {
const val = node.nodeValue;
const parent = node.parentNode;
const pos = val.toLowerCase().indexOf(text);
if (
pos >= 0 &&
!parent.classList.contains(className) &&
!parent.classList.contains("nohighlight")
) {
let span;

const closestNode = parent.closest("body, svg, foreignObject");
const isInSVG = closestNode && closestNode.matches("svg");
if (isInSVG) {
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
} else {
span = document.createElement("span");
span.classList.add(className);
}

span.appendChild(document.createTextNode(val.substr(pos, text.length)));
parent.insertBefore(
span,
parent.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling
)
);
node.nodeValue = val.substr(0, pos);

if (isInSVG) {
const rect = document.createElementNS(
"http://www.w3.org/2000/svg",
"rect"
);
const bbox = parent.getBBox();
rect.x.baseVal.value = bbox.x;
rect.y.baseVal.value = bbox.y;
rect.width.baseVal.value = bbox.width;
rect.height.baseVal.value = bbox.height;
rect.setAttribute("class", className);
addItems.push({ parent: parent, target: rect });
}
}
} else if (node.matches && !node.matches("button, select, textarea")) {
node.childNodes.forEach((el) => _highlight(el, addItems, text, className));
}
};
const _highlightText = (thisNode, text, className) => {
let addItems = [];
_highlight(thisNode, addItems, text, className);
addItems.forEach((obj) =>
obj.parent.insertAdjacentElement("beforebegin", obj.target)
);
};

/**
* Small JavaScript module for the documentation.
*/
const Documentation = {
init: () => {
Documentation.highlightSearchWords();
Documentation.initDomainIndexTable();
Documentation.initOnKeyListeners();
},
Expand Down Expand Up @@ -71,6 +126,51 @@ const Documentation = {
Documentation.LOCALE = catalog.locale;
},

/**
* highlight the search words provided in the url in the text
*/
highlightSearchWords: () => {
const highlight =
new URLSearchParams(window.location.search).get("highlight") || "";
const terms = highlight.toLowerCase().split(/\s+/).filter(x => x);
if (terms.length === 0) return; // nothing to do

// There should never be more than one element matching "div.body"
const divBody = document.querySelectorAll("div.body");
const body = divBody.length ? divBody[0] : document.querySelector("body");
window.setTimeout(() => {
terms.forEach((term) => _highlightText(body, term, "highlighted"));
}, 10);

const searchBox = document.getElementById("searchbox");
if (searchBox === null) return;
searchBox.appendChild(
document
.createRange()
.createContextualFragment(
'<p class="highlight-link">' +
'<a href="javascript:Documentation.hideSearchWords()">' +
Documentation.gettext("Hide Search Matches") +
"</a></p>"
)
);
},

/**
* helper function to hide the search marks again
*/
hideSearchWords: () => {
document
.querySelectorAll("#searchbox .highlight-link")
.forEach((el) => el.remove());
document
.querySelectorAll("span.highlighted")
.forEach((el) => el.classList.remove("highlighted"));
const url = new URL(window.location);
url.searchParams.delete("highlight");
window.history.replaceState({}, "", url);
},

/**
* helper function to focus on search bar
*/
Expand Down Expand Up @@ -110,11 +210,15 @@ const Documentation = {
)
return;

const blacklistedElements = new Set([
"TEXTAREA",
"INPUT",
"SELECT",
"BUTTON",
]);
document.addEventListener("keydown", (event) => {
// bail for input elements
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
// bail with special keys
if (event.altKey || event.ctrlKey || event.metaKey) return;
if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements
if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys

if (!event.shiftKey) {
switch (event.key) {
Expand All @@ -136,6 +240,10 @@ const Documentation = {
event.preventDefault();
}
break;
case "Escape":
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
Documentation.hideSearchWords();
event.preventDefault();
}
}

Expand Down
2 changes: 1 addition & 1 deletion _static/documentation_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ var DOCUMENTATION_OPTIONS = {
SOURCELINK_SUFFIX: '.txt',
NAVIGATION_WITH_KEYS: false,
SHOW_SEARCH_SUMMARY: true,
ENABLE_SEARCH_SHORTCUTS: true,
ENABLE_SEARCH_SHORTCUTS: false,
};
Loading

0 comments on commit cba602a

Please sign in to comment.