In earlier posts, I describe the background to the decision to use staticSearch and my experience of getting it to work. In this post, I describe how we are winding staticSearch into our editions.
By default, staticSearch places everything it uses into a <div id="staticSearch"> element. So your core search page, typically the "index.html" file at the root of your document collection, has to contain a <div id="staticSearch"> </div> element. When you run the Ant process, as described in https://scholarlydigitaleditions.blogspot.com/2023/07/staticsearch-and-me.html, the <div id="staticSearch"> gets populated with multiple javascript and html statements. Here is the beginning of what staticSearch pastes in, as of version 1.4.4:
<div id="staticSearch">
<script xmlns="http://www.w3.org/1999/xhtml" src="staticSearch/ssSearch-debug.js"></script>
<script xmlns="http://www.w3.org/1999/xhtml" src="staticSearch/ssInitialize.js"></script>
<noscript xmlns="http://www.w3.org/1999/xhtml">This page requires JavaScript.</noscript>
<form xmlns="http://www.w3.org/1999/xhtml" accept-charset="UTF-8" id="ssForm"
data-allowphrasal="yes" data-allowwildcards="yes" data-minwordlength="2"
data-scrolltotextfragment="no" data-maxkwicstoshow="5" data-resultsperpage="5"
onsubmit="return false;" data-versionstring="" data-ssfolder="../../../staticSearch"
data-kwictruncatestring="..." data-resultslimit="2000">
<span class="ssQueryAndButton">
<input type="text" id="ssQuery" aria-label="Search"/>
<button id="ssDoSearch">Search</button>
</span>
</form>
This fragment sets up the search form, which will appear where-ever you have put <div id="staticSearch"> in your document. In our implementation, we place it in the document header, where we want this to take up very little space. In the default implementation, the <form id="ssForm"> is followed by two other elements, thus:
<div xmlns="http://www.w3.org/1999/xhtml" id="ssSearching" >Searching...</div>
<div xmlns="http://www.w3.org/1999/xhtml" id="ssResults"></div>
<div xmlns="http://www.w3.org/1999/xhtml" id="ssPoweredBy"> //ssLogo etc
If we keep this as is, here is what the top of our page looks like:
This is rather ugly, as "ssSearching" and ""ssPoweredBy" elements intrude on our very clear header. So we can suppress those by adding 'style="display:none"' to those elements. We will also add 'style="display:none"' to the "ssResults" element: more on that in a moment. Thus:
<div xmlns="http://www.w3.org/1999/xhtml" id="ssSearching"
style="display:none" >Searching...</div>
Now, this is how it looks once those elements have been hidden:
This could be better yet. Space in the header is at a premium: every letter counts. Instead of "Search", taking up rather a large box, we might have just a "?" or, even better, a search icon.S So we adjust the appearance of the "Search" button with this bit of css:
#ssDoSearch {
background-image: url("../../common/images/searchicon.png");
background-size: 15px;
height: 24px;
width: 23px;
background-position: 50%;
background-repeat: no-repeat;
position: relative;
top: 5px;
}
#ssQuery {
width: 100px;
}
The #ssQuery also makes the search box a bit narrower. So now it looks so:
This is beginning to look fine. Now, let's see what the search results look like in the next post.
No comments:
Post a Comment