Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bible-Gateway Ubiquity command
// converted for the Ubiquity Parser 2 by Duncan Johnson on 1/22/2010
// Response to conversation here http://bit.ly/6TO8Xg
noun_version_name = new CmdUtils.NounType("version", ["nkjv", "kjv", "niv"]);
CmdUtils.CreateCommand(
{
names: ['bible-search'],
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'passage'},
{role: 'format', nountype: noun_version_name, label: 'version'}],
//icon: "http://www.zenorsoft.com/ubiquity/Bible_Search.jpg", //looks like a copy of the Logos logo, so I commented it out because I'm not sure about licensing
//homepage: "http://www.zenorsoft.com",
homepage: "http://gist.github.com/gists/283936/edit",
author: { name: "Jon Zenor", email: "Jon@ZenorSoft.com" },
license: "GPL",
description: "Search for a Bible Passage",
help: "Give a bible passage to look up the text. Optionally you can give a version by specifying \'in kjv\' (or niv, nkjv).",
preview: function(pblock, args)
{
var versions = {
"niv" : "31",
"nkjv" : "50",
"kjv" : "9"
};
var version = versions[args.format.text];
if(version == "" || version == null)
{
version = versions.nkjv;
}
var passageUrl = "http://www.biblegateway.com/passage/?search=" + args.object.text + ";&version=" + version;
CmdUtils.previewAjax(pblock,
{
url: passageUrl,
dataType: "html",
success: function(data)
{
var passageRegex = new RegExp('<div class=\\"result-text-style-normal\\">\\n.+[\\n|</div>]', 'mgi');
var match = passageRegex.exec(data);
if(match != null)
{
var msg = '${passage}';
pblock.innerHTML = CmdUtils.renderTemplate(msg, { passage: match[0]});
}
else
{
pblock.innerHTML = "No match found for passage: " + args.object.text ;
}
}
});
},
execute: function(args)
{
var versions = {
"niv" : "31",
"nkjv" : "50",
"kjv" : "9"
};
var version = versions[args.format.text];
if(version == "" || version == null)
{
version = versions.nkjv;
}
Utils.openUrlInBrowser("http://www.biblegateway.com/passage/?search=" + args.object.text + ";&version=" + version);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.