-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1831 from folio-org/FOLIO-4165-search-endpoints
FOLIO-4165 Add search-endpoints
- Loading branch information
Showing
16 changed files
with
282 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ _site | |
.bundle | ||
tmp/ | ||
vendor | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
<!-- include tertiary-column.html --> | ||
{%- comment -%}<!-- This widget separator will only show up when the tertiary column content is merged into the secondary column-->{%- endcomment %} | ||
<div class="tertiary-widget-separator"></div> | ||
<div> | ||
<p>Search terms are combined with 'AND'.</p> | ||
<p>Using <a href="https://github.com/bvaughn/js-search">js-search</a>.</p> | ||
<p>See its <a href="https://github.com/bvaughn/js-search">assistance notes</a>.</p> | ||
<p> | ||
Using its "AllSubstringsIndexStrategy". | ||
So "c", "ca", "cat", "a", "at", and "t" will all match the term "cat". | ||
</p> | ||
<p> | ||
This search is constrained to the | ||
<a href="https://github.com/folio-org/folio-org.github.io/tree/master/_data/config-api-endpoints.json">list</a> | ||
of API documentation endpoints. | ||
</p> | ||
</div> | ||
<!-- end of include tertiary-column.html --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
|
||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
{files: ["**/*.js"], languageOptions: {sourceType: "script"}}, | ||
{languageOptions: { globals: globals.browser }}, | ||
pluginJs.configs.recommended, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@eslint/js": "^9.18.0", | ||
"eslint": "^8.57.1", | ||
"eslint-config-airbnb-base": "latest", | ||
"eslint-config-jquery": "^3.0.2", | ||
"eslint-plugin-import": "^2.25.2", | ||
"globals": "^15.14.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,55 @@ | ||
var debug = false; | ||
jQuery(function() { | ||
window.data = $.getJSON('/search_data.json', function() { | ||
if (debug) { console.log('Okay'); } | ||
}) | ||
.done(function(searchData) { | ||
if (debug) { console.log('Got JSON data'); } | ||
window.idx = new JsSearch.Search('id'); | ||
window.idx.addIndex('id'); | ||
window.idx.addIndex('title'); | ||
window.idx.addIndex('content'); | ||
window.idx.addIndex('categories'); | ||
if (debug) { console.log('Processing'); } | ||
if (debug) { console.time('Build index'); } | ||
window.idx.addDocuments(searchData); | ||
if (debug) { console.timeEnd('Build index'); } | ||
var idxCount = searchData.length; | ||
if (debug) { console.log('Ready: idx: ' + idxCount); } | ||
JsSearch.StopWordsMap.issue = false; | ||
JsSearch.StopWordsMap.environment = false; | ||
}) | ||
.fail(function() { | ||
console.log('Error with getting search data'); | ||
}) | ||
.always(function() { | ||
if (debug) { console.log('Complete'); } | ||
}); | ||
let idx = []; | ||
$( (searchDev) => { | ||
window.data = $.getJSON( "/search_data.json", () => { | ||
if ( debug ) { console.log( "Setup okay." ); } | ||
} ) | ||
.done( ( searchData ) => { | ||
if ( debug ) { console.log( "Loaded JSON data." ); } | ||
idx = new JsSearch.Search( "id" ); | ||
idx.indexStrategy = new JsSearch.PrefixIndexStrategy(); | ||
idx.addIndex( "title" ); | ||
idx.addIndex( "content" ); | ||
idx.addIndex( "categories" ); | ||
if ( debug ) { console.log( "Processing ..." ); } | ||
if ( debug ) { console.time( "Build index" ); } | ||
idx.addDocuments( searchData ); | ||
if ( debug ) { console.timeEnd( "Build index" ); } | ||
const idxCount = searchData.length; | ||
if ( debug ) { console.log( `Ready: idx: ${ idxCount } items` ); } | ||
JsSearch.StopWordsMap.issue = false; | ||
JsSearch.StopWordsMap.environment = false; | ||
} ) | ||
.fail( () => { | ||
console.log( "Error with getting search data." ); | ||
} ) | ||
.always( () => { | ||
if ( debug ) { console.log( "Complete." ); } | ||
} ); | ||
|
||
$('#searchDev').submit(function(event) { | ||
event.preventDefault(); | ||
var query = $('#searchInput').val(); | ||
if (debug) { console.log('Query: ' + query); } | ||
var results = window.idx.search(query); | ||
displayResults(results); | ||
}); | ||
|
||
function displayResults(results) { | ||
var $searchResults = $('#searchResults'); | ||
if (debug) { console.log('Hits: ' + results.length); } | ||
if (results.length) { | ||
$searchResults.empty(); | ||
results.forEach(function(result) { | ||
if (debug) { console.log('Result: ' + result.url); } | ||
var appendString = '<li><a href="' + result.url + '">' + result.title + '</a></li>'; | ||
$searchResults.append(appendString); | ||
}); | ||
function displayResults( results ) { | ||
const searchResults = $( "#searchResults" ); | ||
const hits = $( "#hits" ); | ||
if ( debug ) { console.log( `Hits: ${ results.length }` ); } | ||
if ( results.length ) { | ||
searchResults.empty(); | ||
hits.html( `Hits: ${ results.length }` ); | ||
results.forEach( ( result ) => { | ||
if ( debug ) { console.log( `Result: ${ result.url }` ); } | ||
const appendString = `<li><a href="${ result.url }">${ result.title }</a></li>`; | ||
searchResults.append(appendString); | ||
} ); | ||
} else { | ||
$searchResults.html('<li>No results found.</li>'); | ||
hits.html( `Hits: 0` ); | ||
searchResults.html( "<li>No results found.</li>" ); | ||
} | ||
} | ||
}); | ||
|
||
$( "#searchDev" ).submit( ( event ) => { | ||
event.preventDefault(); | ||
const query = $( "#searchInput" ).val(); | ||
if ( debug ) { console.log( `Query: ${ query }` ); } | ||
const results = idx.search( query ); | ||
displayResults( results ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const debug = true; | ||
let idx = []; | ||
$( (searchEndpoints) => { | ||
window.data = $.getJSON( "/search_endpoints.json", () => { | ||
if ( debug ) { console.log( "Setup okay." ); } | ||
} ) | ||
.done( ( searchData ) => { | ||
if ( debug ) { console.log( "Loaded JSON data." ); } | ||
idx = new JsSearch.Search( "id" ); | ||
idx.indexStrategy = new JsSearch.AllSubstringsIndexStrategy(); | ||
idx.addIndex( "id" ); | ||
idx.addIndex( "moduleName" ); | ||
idx.addIndex( "path" ); | ||
idx.addIndex( "interface" ); | ||
idx.addIndex( "methods" ); | ||
idx.addIndex( "apiDescription" ); | ||
idx.addIndex( "apiType" ); | ||
if ( debug ) { console.log( "Processing ..." ); } | ||
if ( debug ) { console.time( "Build index" ); } | ||
idx.addDocuments( searchData ); | ||
if ( debug ) { console.timeEnd( "Build index" ); } | ||
const idxCount = searchData.length; | ||
if ( debug ) { console.log( `Ready: idx: ${ idxCount } items` ); } | ||
JsSearch.StopWordsMap.issue = false; | ||
JsSearch.StopWordsMap.environment = false; | ||
} ) | ||
.fail( () => { | ||
console.log( "Error with getting search data." ); | ||
} ) | ||
.always( () => { | ||
if ( debug ) { console.log( "Complete." ); } | ||
} ); | ||
|
||
function displayResults( results ) { | ||
const searchResults = $( "#searchResults" ); | ||
const hits = $( "#hits" ); | ||
const urlRepoBase = "https://github.com/folio-org/"; | ||
const urlS3Base = "https://s3.amazonaws.com/foliodocs/api/"; | ||
if ( debug ) { console.log( `Hits: ${ results.length }` ); } | ||
if ( results.length ) { | ||
searchResults.empty(); | ||
hits.html( `Hits: ${ results.length }` ); | ||
results.forEach( ( result ) => { | ||
if ( debug ) { console.log( `Result: ${ result.path }` ); } | ||
const urlRepo = `${ urlRepoBase }${ result.moduleName }`; | ||
const urlS3Repo = `${ urlS3Base }${ result.moduleName }`; | ||
const apath = result.apiDescription; | ||
const filenameDoc = apath.substring( apath.lastIndexOf( "/" ) + 1 ); | ||
const basenameDoc = filenameDoc.replace( /\.[^/.]+$/, "" ); | ||
const urlApiDesc = `${ urlRepo }/blob/master/${ result.apiDescription }`; | ||
const methods = result.methods.split( " " ); | ||
let methodsList = ""; | ||
methods.forEach( ( method ) => { | ||
const opParts = method.split( ":" ); | ||
let nullNote = ""; | ||
if ( opParts[ 1 ] === "null" ) { | ||
nullNote = " (missing operationId)" | ||
} | ||
let urlS3 = `${ urlS3Repo }/`; | ||
if ( result.apiType === "RAML" ) { | ||
urlS3 += "p/"; | ||
} | ||
urlS3 += `${ basenameDoc }.html#${ opParts[ 1 ] }`; | ||
methodsList += `<li><a href="${ urlS3 }">${ opParts[ 0 ] }</a> ${nullNote}</li>`; | ||
} ); | ||
const appendString = ` | ||
<li> ${ result.path } | ||
<ul> | ||
<li>module: <a href="${ urlRepo }">${ result.moduleName }</a></li> | ||
<li>interface: ${ result.interface } </li> | ||
<li>path: ${ result.path } </li> | ||
<li>methods: | ||
<ul>${ methodsList }</ul> | ||
</li> | ||
<li>api description: <a href="${ urlApiDesc }">${ result.apiDescription }</a></li> | ||
<li>api type: ${ result.apiType } </li> | ||
</ul> | ||
</li> | ||
`; | ||
searchResults.append( appendString ); | ||
} ); | ||
} else { | ||
hits.html( `Hits: 0` ); | ||
searchResults.html( "<li>No results found.</li>" ); | ||
} | ||
} | ||
|
||
$( "#searchEndpoints" ).submit( ( event ) => { | ||
event.preventDefault(); | ||
const query = $( "#searchInput" ).val(); | ||
if ( debug ) { console.log( `Query: ${ query }` ); } | ||
const results = idx.search( query ); | ||
displayResults( results ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
layout: page | ||
title: Search API endpoints | ||
titleLeader: "Search |" | ||
permalink: /search-endpoints/ | ||
menuInclude: yes | ||
menuLink: yes | ||
menuTopTitle: Search | ||
menuSubTitle: "Search API endpoints" | ||
menuSubIndex: 3 | ||
tertiary-column: present | ||
tertiary-column-content: column-2-search-endpoints.html | ||
--- | ||
|
||
<div class="form"> | ||
<form action="get" id="searchEndpoints"> | ||
<input type="text" size="25" id="searchInput" autofocus> | ||
<input type="submit" value="Search"> | ||
</form> | ||
</div> | ||
|
||
<div id="hits"></div> | ||
|
||
<ul id="searchResults"></ul> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/js-search.min.js"></script> | ||
<script src="/assets/js/search-endpoints.js"></script> | ||
|
||
## Other information | ||
|
||
### Some missing method links | ||
|
||
As [explained](/reference/api/endpoints/#some-missing-method-links) at the Endpoints documentation, a small set of OpenAPI-based modules are missing links for the "Methods". | ||
These will be marked in the search results with "(missing operationId)". | ||
|
||
Some of these are unimplemented "stub" endpoints (do a search for "stub" to find them). | ||
|
||
Others are actual endpoints, but their API description has omitted the "operationId" property for that method. | ||
|
||
### Interfaces | ||
|
||
Some "interface" properties might be missing. See the [explanation](/reference/api/endpoints/#interfaces) at the Endpoints documentation. | ||
|
||
### Other documentation | ||
|
||
* [API documentation](/reference/api/) | ||
* [API documentation endpoints](/reference/api/endpoints/) | ||
|
||
<div class="folio-spacer-content"></div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.