Skip to content

Instantly share code, notes, and snippets.

@adamfowleruk
Created April 22, 2013 22:43
Show Gist options
  • Save adamfowleruk/5439227 to your computer and use it in GitHub Desktop.
Save adamfowleruk/5439227 to your computer and use it in GitHub Desktop.
mldb-02-integrate-with-roxy tutorial http://adamfowlerml.wordpress.com/2013/04/24/mldb-roxy-install/
<link rel="stylesheet" type="text/css" href="/css/widgets.css" />
<script type="text/javascript" src="/js/mldb.js"></script>
<script type="text/javascript" src="/js/mldb-jquery.js"></script>
<script type="text/javascript" src="/js/widgets.js"></script>
<script type="text/javascript" src="/js/widget-search.js"></script>
<script type="text/javascript" src="/js/page-search-main.js"></script>
<div id="search-content">Search content goes here</div>
declare function c:main() as item()*
{
ch:add-value("message", "This is a test message."),
ch:add-value("title", "Search"),
ch:use-view((), "xml"),
ch:use-layout("one-column", "html")
};
$(document).ready(function() {
var db = new mldb();
var wgt = new com.marklogic.widgets.searchpage("search-content");
var ob = db.options();
ob.collectionConstraint();
var options = ob.toJson();
wgt.setOptions("mldbtest-page-search-options",options);
wgt.execute();
});
<div xmlns="http://www.w3.org/1999/xhtml" class="search load">
<link rel="stylesheet" type="text/css" href="/css/widgets.css" />
<script type="text/javascript" src="/js/mldb.js"></script>
<script type="text/javascript" src="/js/mldb-jquery.js"></script>
<script type="text/javascript" src="/js/page-search-load.js"></script>
</div>
$(document).ready(function() {
var db = new mldb();
var docs = [
{title: "The Goonies",actor: "Sean Astin", genre: "Comedy", year: "1985"},
{title: "50 First Dates",actor: "Sean Astin", genre: "Comedy", year: "2004"},
{title: "Kingdom Hearts",actor: "Sean Astin", genre: "Comedy", year: "2002"},
{title: "The Sky Is Falling",actor: "Sean Astin", genre: "Comedy", year: "2001"},
{title: "Dorothy and the Witches of Oz",actor: "Sean Astin", genre: "Fantasy", year: "2012"},
{title: "The Lord of the Rings: The Return of the King",actor: "Sean Astin", genre: "Fantasy", year: "2003"},
{title: "The Lord of the Rings: The Two Towers",actor: "Sean Astin", genre: "Fantasy", year: "2002"},
{title: "The Lord of the Rings: The Fellowship of the Ring",actor: "Sean Astin", genre: "Fantasy", year: "2001"},
{title: "Teenage Mutant Ninja Turtles",actor: "Sean Astin", genre: "Adventure", year: "2013"},
{title: "Dumb and Dumber To",actor: "Jim Carrey", genre: "Comedy", year: "2014"},
{title: "Kick-Ass 2",actor: "Jim Carrey", genre: "Comedy", year: "2013"},
{title: "Mr. Popper's Penguins",actor: "Jim Carrey", genre: "Comedy", year: "2011"},
{title: "I Love You Philip Morris",actor: "Jim Carrey", genre: "Comedy", year: "2009"},
{title: "Ace Ventura: When Nature Calls",actor: "Jim Carrey", genre: "Comedy", year: "1995"},
{title: "Ace Ventura: Pet Detective",actor: "Jim Carrey", genre: "Comedy", year: "1994"},
{title: "A Christmas Carol",actor: "Jim Carrey", genre: "Drama", year: "2009"},
{title: "The Number 23",actor: "Jim Carrey", genre: "Drama", year: "2007"}
];
for (var i = 0;i < docs.length;i++) {
db.save(docs[i],"/movies/" + i,{collection: "movies"}, function(result) {
// do nothing - assume it works
});
}
});
declare function c:load() as item()*
{
ch:add-value("message", "This is a test message."),
ch:add-value("title", "Search"),
ch:use-view((), "xml"),
ch:use-layout("one-column", "html")
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment