Skip to content

Commit

Permalink
Search can handle results from different repositories
Browse files Browse the repository at this point in the history
Adapted implementation of the search that can handle (future) search results coming from a separate repo (e.g. https://github.com/SkylineCommunications/dataminer-docs-connectors).
  • Loading branch information
stanley-skyline committed Sep 12, 2024
1 parent d6c82ea commit 4aeed44
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions templates/skyline/public/search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function initSearch() {
const BASE_DOCS_URL = "https://docs.dataminer.services";
const BASE_STORAGE_ACCOUNT_URL = "https://docshelp.blob.core.windows.net";
const BLOB_CONTAINER_NAMES = [
"docs-connectors", // https://docs.dataminer.services/connector (connectors)
"docs", // https://docs.dataminer.services/* (main)
];

createSearchResultsNewHtml();
initEventHandlersCloseOpenSearch();

Expand Down Expand Up @@ -35,14 +42,27 @@ function initSearch() {
return str;
}

function getUrlBlobStorageContainer(storageAccountUrl, blobContainerName) {
return `${storageAccountUrl}/${blobContainerName}/`;
}

function composeDocsUrlWithoutBeginPart(blobUri, beginPartUrl) {
return `${BASE_DOCS_URL}/${blobUri.substring(beginPartUrl.length)}`;
}

function getDocsUrlFromBlobStoragePathUri(blobUri) {
// example url: "https://docshelp.blob.core.windows.net/docs/user-guide/Advanced_Functionality/DataMiner_Systems/DataminerSystems.html"
const startsWith = "https://docshelp.blob.core.windows.net/docs/"
// example url docs main: https://docshelp.blob.core.windows.net/docs/user-guide/Getting_started/Creating_a_DataMiner_System.html
// example url docs connectors: https://docshelp.blob.core.windows.net/docs-connectors/connector/doc/Skyline_Regression_Test_Result_Collector.html

for (const blobContainerName of BLOB_CONTAINER_NAMES) {
const beginPartUrl = getUrlBlobStorageContainer(BASE_STORAGE_ACCOUNT_URL, blobContainerName);

if (blobUri.startsWith(startsWith)) {
return `https://docs.dataminer.services/${blobUri.substring(startsWith.length)}`;
if (blobUri.startsWith(beginPartUrl)) {
return composeDocsUrlWithoutBeginPart(blobUri, beginPartUrl);
}
}
return blobUri;

return '';
}

function initEventHandlersCloseOpenSearch() {
Expand Down

0 comments on commit 4aeed44

Please sign in to comment.