Turning Scripture References into Bible Text Pop-ups with Drupal

Oct
10

An example of a scripture pop-up on the cai.org website, where hovering your mouse over a scripture reference brings up the bible text.Recently a chap named certain Walton contacted me to ask how how we got the bible text to pop up when you hover your mouse over scripture references on the Christian Assemblies International website:

I was just checking out the feature on the website you helped create for Christian Assemblies International (Drupal.org case study).

I was especially interested in your implementation of the scripture pop-ups. I am helping a friend with their church website here in Korea and I was hoping you could be more specific with how you converted the text Bibles into database entries, how you created the input filter that detects them, and how you "beautified" your pop-ups. I am really interested in being able to do this with multiple languages too.

Advice or even code would be much appreciated.

In fact these scripture pop-ups are the one thing I'm most proud of about the entire cai.org website. Mainly because it's such a logical thing to have, I've never seen it on any other church website, and if I do say so myself we executed it rather well (thanks in large part to Drupal and some other free tools).

Here are a few lines my mate Craig put together to answer the question, with a few additions from myself:

Craig Steps Up to the Mic

Thanks for your questions about how our scripture popups work. In a nut shell it works like this:

  1. The Bibles were converted from various sources into SQL database tables. In the case of the KJV English Bible, I think we found a SQL or perhaps a CSV version on the net which we could use quite easily and it seems good. We wrote various scripts to convert Bibles from web pages etc into CSVs which can be imported into SQL. We also managed to use the text from some Bible Software (we used E-Sword quite a bit) to some degree of success. But we do need to address some errors in the SQL. At the moment, some of the foreign language databases have some commentary in them that should not be there as it is not part of the Bible text. Another stumbling block is that some languages have different verse numbering and yet often the online versions will use English verse numbering which is a problem. We use UTF-8 character encoding. That was also a bit of a mission at time as often there is other encodings which need to be converted. (Short version: Doing anything multilingual is always be more complicated).
  2. Also in the SQL database is a table of book names for each language
  3. Then there is a Drupal filter which according to the language of the web page being viewed, pulls the book names from the database and does regex pattern matching to find scriptures, for example <Bookname> <number>:<number>. There are a number of tricky regexs to find ranges of scriptures e.g. ACTS 2:37-39, or ACTS 2:38,40 etc. All the pattern matching is done with regular expressions.
  4. Once the filter finds a scripture reference (that is to say, the regex matches), it then pulls the scripture from the database and inserts it into the webpage inside <cite class="bibleref"></cite> tags. Note that:
    • cite is the semantically correct tag to use for bible references (as you are citing a source, which happens to be the Bible).
    • Our use of class "bibleref" means that this more or less fits the growing Bibleref Markup standard. We directly address these references with a CSS rule for cite.bibleref.
    • The full scripture text is injected by the filter into the title attribute of the cite tag. This allows the next part to work...
  5. We then use a Drupal module which implements Javascript jToolTips to renders the actual popup box in a fancy way when you mouse over.
  6. The server has to work reasonably hard with all the database transactions, but because Drupal caches the pages, the performance hit is only on the first page load after a change has been made.

Lastly: Copyright and the Bible

Lastly I (John again) should mention that in all the languages we did this for, we only used Bible translations that are in the public domain. If you want to do this with a copyrighted translation, you should first check out whether it's legal to store their entire work in your own database and then use it in the way you're intending.

However I recommend you save yourself the effort and just use a public domain Bible, in English the best one is the King James Version. We actually didn't choose to use it because it's in the public domain, but rather because it's the best translation and the one that has been used by God as the basis of all true revivals in the English speaking world throughout history. It seems that the translations that God has ordained in every language around the world tend to be in the public domain - you can store, quote, print, sell them, whatever you like without fear or restriction (more detailed info from the Christian Assemblies website: Why Christians Should Use the King James Bible and Modern Translations Are Not Trustworthy!).

Which, when you think about it, makes a lot of sense. Would God bless a translation of his Word which you have to ask permission to print or distribute? Revelation 22:17And the Spirit and the bride say, Come. And let him that heareth say, Come. And let him that is athirst come. And whosoever will, let him take the water of life freely.

No comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
D
A
q
2
Enter the code without spaces and pay attention to upper/lower case.