Mobile Shakespeare Tutorial Part 3
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
<get path="play/:id/act/:act/scene/:scene/speech/:speech"><to>play#scene</to></get> | |
<get path="search"><to>search#get</to></get> | |
<post path="search"><to>search#get</to></post> |
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
1.) | |
<div>... was <b>untimely</b> ripp'd. Accursed be ...</div> | |
2.) | |
<div><p>... was untimely ripp'd.</p><p>Accursed be ...</p> | |
3.) | |
<div>... was untimely | |
<annotation class="hidden tooltip">Awesome!</annotation> | |
ripp'd. Accursed b...</div> | |
4.) | |
<SPEECH> | |
<LINE>Tell thee, Macduff was from his mother's womb<LINE> | |
<LINE>Untimely ripp'd.</LINE> | |
</SPEECH> | |
<SPEECH> | |
<LINE>Accursed be the tongue ... |
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
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; |
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
(: Search API options :) | |
declare variable $options := | |
<options xmlns="http://marklogic.com/appservices/search"> | |
<concurrency-level>8</concurrency-level> | |
<debug>0</debug> | |
<page-length>10</page-length> | |
<search-option>score-logtfidf</search-option> | |
<quality-weight>1.0</quality-weight> | |
<return-constraints>false</return-constraints> | |
<!-- Turning off the things we don't use --> | |
<return-facets>false</return-facets> | |
<return-qtext>false</return-qtext> | |
<return-query>false</return-query> | |
<return-results>true</return-results> | |
<return-metrics>false</return-metrics> | |
<return-similar>false</return-similar> | |
<searchable-expression>//SPEECH</searchable-expression> | |
<sort-order direction="descending"> | |
<score/> | |
</sort-order> | |
<term apply="term"> | |
<!-- "" $term returns no results --> | |
<empty apply="no-results" /> | |
<!-- Not sure why this isn't a default --> | |
<term-option>case-insensitive</term-option> | |
</term> | |
<grammar> | |
<quotation>"</quotation> | |
<implicit> | |
<cts:and-query strength="20" xmlns:cts="http://marklogic.com/cts"/> | |
</implicit> | |
<starter strength="30" apply="grouping" delimiter=")">(</starter> | |
<starter strength="40" apply="prefix" element="cts:not-query">-</starter> | |
<joiner strength="10" apply="infix" element="cts:or-query" tokenize="word">OR</joiner> | |
<joiner strength="20" apply="infix" element="cts:and-query" tokenize="word">AND</joiner> | |
<joiner strength="30" apply="infix" element="cts:near-query" tokenize="word">NEAR</joiner> | |
<joiner strength="30" apply="near2" consume="2" element="cts:near-query">NEAR/</joiner> | |
<joiner strength="50" apply="constraint">:</joiner> | |
<joiner strength="50" apply="constraint" compare="LT" tokenize="word">LT</joiner> | |
<joiner strength="50" apply="constraint" compare="LE" tokenize="word">LE</joiner> | |
<joiner strength="50" apply="constraint" compare="GT" tokenize="word">GT</joiner> | |
<joiner strength="50" apply="constraint" compare="GE" tokenize="word">GE</joiner> | |
<joiner strength="50" apply="constraint" compare="NE" tokenize="word">NE</joiner> | |
</grammar> | |
<!-- Custom rendering code for "Snippet" --> | |
<transform-results apply="snippet" ns="http://framework/lib/l-util" at="/lib/l-util.xqy" /> | |
</options>; |
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
<!-- Search Form --> | |
<form action="/search" method="get" data-transition="fade" class="ui-body ui-body-b ui-corner-all"> | |
<fieldset > | |
<label for="search-basic">Search all lines:</label> | |
<input type="search" name="term" id="term" value="{$term}" data-theme="b" /> | |
</fieldset> | |
<div data-role="fieldcontain"> | |
<label for="slider2">Phrase search:</label> | |
<select name="phrase" id="phrase" data-role="slider" > | |
<option value="off"> | |
Off | |
</option> | |
<option value="on"> | |
{ | |
(: Dynamic inline attribute of the option element :) | |
if($phrase eq "on") then | |
attribute selected {"selected"} | |
else | |
() | |
} | |
On | |
</option> | |
</select> | |
</div> | |
<button type="submit" data-theme="b" data-transition="fade">Submit</button> | |
</form> |
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
<p> | |
{ | |
(: Search Results Area :) | |
(: | |
Modify the typed search term. | |
Add Quotes if the $phrase flag is "on" | |
If the term is empty sequence, use "" | |
:) | |
let $searchTerm := | |
if(fn:exists($term)) then | |
if($phrase eq "on" and fn:not( fn:starts-with($term,'"') and fn:ends-with($term,'"'))) then | |
fn:concat('"',$term,'"') | |
else | |
$term | |
else | |
"" | |
return | |
(: | |
Think Functionally ... | |
XQuery invokes passes the evaluation of search:search | |
to transform-results | |
:) | |
(: transform results into HTML5 :) | |
local:transform-results( | |
(: execute the search with the Search API :) | |
search:search($searchTerm, $options)//search:result | |
) | |
} | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment