-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-autocomplete-dropdown'
- Loading branch information
Showing
21 changed files
with
1,504 additions
and
611 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
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,37 @@ | ||
const fs = require("fs-extra"); | ||
const spawn = require("child_process").spawnSync; | ||
const inquirer = require("inquirer"); | ||
|
||
// copy a source file into index.html | ||
const copyAndRun = source => { | ||
try { | ||
fs.copySync("public/" + source + ".html", "public/index.html"); | ||
} catch (e) { | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
spawn("react-scripts", ["start"], { stdio: "inherit" }); | ||
process.exit(0); | ||
}; | ||
|
||
const choices = ["inline", "searchbox", "overlay", "dynamic-content"]; | ||
const choice = process.argv[2]; | ||
|
||
// if the user has supplied an action run it without prompting | ||
if (choices.indexOf(choice) !== -1) { | ||
copyAndRun(choice); | ||
} | ||
|
||
// prompt the user for which action to run | ||
inquirer | ||
.prompt([ | ||
{ | ||
type: "list", | ||
name: "choice", | ||
message: "Which integration would you like to run?", | ||
choices | ||
} | ||
]) | ||
.then(answers => { | ||
copyAndRun(answers.choice); | ||
}); |
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,86 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sajari: Dynamic Content Example UI</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
|
||
<h2>Dynamic Content</h2> | ||
<div id="dynamic-content"></div> | ||
|
||
|
||
<!-- This script sets up the config for the search interface --> | ||
<script> | ||
var getUrlParam = function (e) { var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"), a = t.exec(window.location.href); return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" }; | ||
|
||
var setup = function (u, r, n, t, a, s) { s = []; var e = function () { s.push(arguments) }, i = "ui"; return e.arr = s, u[t] = u[t] || [], u[t][i] = u[t][i] || [], u[t][i].push(e), e }; | ||
|
||
dynamicContent = setup(window, document, "script", "sajari"); | ||
dynamicContent({ | ||
mode: "dynamic-content", | ||
project: "sajariptyltd", // Set this to your project. | ||
collection: "sajari-com", // Set this to your collection. | ||
values: { resultsPerPage: "3", "q": getUrlParam("q") }, | ||
attachDynamicContent: document.getElementById("dynamic-content"), | ||
results: { showImages: false }, // Show images in results. | ||
pipeline: "raw", | ||
tracking: false, | ||
searchOnLoad: true, | ||
}); | ||
</script> | ||
|
||
<style> | ||
/** | ||
* Page styling | ||
*/ | ||
|
||
html { | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; | ||
background-color: #f7f7f7 | ||
} | ||
|
||
body { | ||
margin: 20px; | ||
line-height: 24px | ||
} | ||
|
||
code, | ||
pre { | ||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; | ||
background-color: #eee; | ||
border: 1px solid #999; | ||
padding: 2px; | ||
border-radius: 4px; | ||
font-size: 14px | ||
} | ||
|
||
pre { | ||
padding: 10px | ||
} | ||
|
||
input, | ||
button { | ||
font-size: 16px; | ||
} | ||
|
||
div#search-box, | ||
div#search-response, | ||
div#content-block-response { | ||
border: 2px dashed #ddd; | ||
padding: 20px; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
margin: 10px; | ||
} | ||
|
||
ul li { | ||
padding: 10px | ||
} | ||
</style> | ||
</body> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +0,0 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sajari: Website Search Example UI</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
|
||
<h2>Overlay</h2> | ||
<!-- This input box will launch the interface when the user presses enter --> | ||
<input id="input-box" placeholder="Enter search query" onkeydown="inputKeyDown(event)"> | ||
<script> | ||
function inputKeyDown(e) { | ||
if (e.keyCode === 13 /* Enter key */) { | ||
overlay("pub", "overlay-show"); | ||
overlay("pub", "values-set", { q: e.target.value }); | ||
overlay("pub", "search-send"); | ||
} | ||
} | ||
</script> | ||
<br> | ||
|
||
<!-- This input box will launch the interface when the user clicks it --> | ||
<input onfocus="overlay('pub', 'overlay-show');" placeholder="Focus me to launch"> | ||
<!-- This button will launch the interface when the user clicks it --> | ||
<button onclick="overlay('pub', 'overlay-show');">Launch Interface</button> | ||
|
||
<h2>In Page</h2> | ||
<div id="search-box"></div> | ||
<div id="search-response"></div> | ||
|
||
<h2>Content Block</h2> | ||
<div id="content-block-response"></div> | ||
|
||
<!-- This script sets up the config for the search interface --> | ||
<script> | ||
var getUrlParam = function (e) { var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"), a = t.exec(window.location.href); return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" }; | ||
|
||
var setup = function (u, r, n, t, a, s) { s = []; var e = function () { s.push(arguments) }, i = "ui"; return e.arr = s, u[t] = u[t] || [], u[t][i] = u[t][i] || [], u[t][i].push(e), e }; | ||
|
||
inPage = setup(window, document, "script", "sajari", "//address.js"); | ||
inPage("config", { | ||
project: "etstestest", // Set this to your project. | ||
collection: "trent-kiwi", // Set this to your collection. | ||
values: { resultsPerPage: "10", "q": getUrlParam("q") }, | ||
attachSearchBox: document.getElementById("search-box"), | ||
attachSearchResponse: document.getElementById("search-response"), | ||
pipeline: "website", // Run the website pipeline. | ||
searchBoxPlaceHolder: "Type to search", // Placeholder text in search box. | ||
results: { showImages: false }, // Show images in results. | ||
tabFilters: { // Tabs configuration. | ||
defaultTab: 'All', // Title of the default tab. | ||
tabs: [{ title: 'All', filter: '' }, { title: 'Blog', filter: "dir1='blog'" }, { title: 'Other', filter: "dir1!='blog'" }], // Ordered list of tabs to show. | ||
}, | ||
}); | ||
|
||
overlay = setup(window, document, "script", "sajari"); | ||
overlay("config", { | ||
project: "etstestest", // Set this to your project. | ||
collection: "trent-kiwi", // Set this to your collection. | ||
values: { resultsPerPage: "10", "q": getUrlParam("q") }, | ||
overlay: true, | ||
pipeline: "website", // Run the website pipeline. | ||
searchBoxPlaceHolder: "Type to search", // Placeholder text in search box. | ||
results: { showImages: false }, // Show images in results. | ||
tabFilters: { // Tabs configuration. | ||
defaultTab: 'All', // Title of the default tab. | ||
tabs: [{ title: 'All', filter: '' }, { title: 'Blog', filter: "dir1='blog'" }, { title: 'Other', filter: "dir1!='blog'" }], // Ordered list of tabs to show. | ||
}, | ||
}); | ||
|
||
contentBlock = setup(window, document, "script", "sajari"); | ||
contentBlock("config", { | ||
project: "etstestest", // Set this to your project. | ||
collection: "trent-kiwi", // Set this to your collection. | ||
values: {}, | ||
attachContentBlock: document.getElementById("content-block-response"), | ||
pipeline: "recent", // Run the website pipeline. | ||
results: { showImages: false } // Show images in results. | ||
}); | ||
contentBlock("pub", "search-send"); | ||
</script> | ||
|
||
<style> | ||
/** | ||
* Page styling | ||
*/ | ||
|
||
html { | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; | ||
background-color: #f7f7f7 | ||
} | ||
|
||
body { | ||
margin: 20px; | ||
line-height: 24px | ||
} | ||
|
||
code, | ||
pre { | ||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; | ||
background-color: #eee; | ||
border: 1px solid #999; | ||
padding: 2px; | ||
border-radius: 4px; | ||
font-size: 14px | ||
} | ||
|
||
pre { | ||
padding: 10px | ||
} | ||
|
||
input, | ||
button { | ||
font-size: 16px; | ||
} | ||
|
||
div#search-box, | ||
div#search-response, | ||
div#content-block-response { | ||
border: 2px dashed #ddd; | ||
padding: 20px; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
margin: 10px; | ||
} | ||
|
||
ul li { | ||
padding: 10px | ||
} | ||
</style> | ||
</body> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sajari: Inline Website Search Example UI</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
|
||
<h2>Inline</h2> | ||
<div id="search-box"></div> | ||
<div id="search-response"></div> | ||
|
||
|
||
<!-- This script sets up the config for the search interface --> | ||
<script> | ||
var getUrlParam = function (e) { var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"), a = t.exec(window.location.href); return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" }; | ||
|
||
var setup = function (u, r, n, t, a, s) { s = []; var e = function () { s.push(arguments) }, i = "ui"; return e.arr = s, u[t] = u[t] || [], u[t][i] = u[t][i] || [], u[t][i].push(e), e }; | ||
|
||
inline = setup(window, document, "script", "sajari"); | ||
inline({ | ||
mode: "inline", | ||
project: "sajariptyltd", // Set this to your project. | ||
collection: "sajari-com", // Set this to your collection. | ||
values: { resultsPerPage: "10", "q": getUrlParam("q") }, | ||
attachSearchBox: document.getElementById("search-box"), | ||
attachSearchResponse: document.getElementById("search-response"), | ||
results: { showImages: false }, // Show images in results. | ||
pipeline: "website", | ||
instantPipeline: "autocomplete", | ||
inputPlaceholder: "Search", | ||
maxSuggestions: 5, | ||
tabFilters: { // Tabs configuration. | ||
defaultTab: 'All', // Title of the default tab. | ||
tabs: [{ title: 'All', filter: '' }, { title: 'Blog', filter: "dir1='blog'" }, { title: 'Other', filter: "dir1!='blog'" }], // Ordered list of tabs to show. | ||
}, | ||
}); | ||
</script> | ||
|
||
<style> | ||
/** | ||
* Page styling | ||
*/ | ||
|
||
html { | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; | ||
background-color: #f7f7f7 | ||
} | ||
|
||
body { | ||
margin: 20px; | ||
line-height: 24px | ||
} | ||
|
||
code, | ||
pre { | ||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; | ||
background-color: #eee; | ||
border: 1px solid #999; | ||
padding: 2px; | ||
border-radius: 4px; | ||
font-size: 14px | ||
} | ||
|
||
pre { | ||
padding: 10px | ||
} | ||
|
||
input, | ||
button { | ||
font-size: 16px; | ||
} | ||
|
||
div#search-box, | ||
div#search-response, | ||
div#content-block-response { | ||
border: 2px dashed #ddd; | ||
padding: 20px; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
margin: 10px; | ||
} | ||
|
||
ul li { | ||
padding: 10px | ||
} | ||
</style> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.