Simple Parallel Bible (PHP/MySQL)

URL: http://jesus.com.au/html/page/parallel, Accessed: Fri, 08 Aug 2008 10:37:46 +1000, Copyright: ©2000-07, Nigel Chapman

The Simple Parallel Bible is a search and lookup tool that can be easily added to any PHP/MySQL website. It lets you link to multiple passages, in parallel (for side-by-side comparison) or in a list, with a single link, without leaving your website.

2007-02-19 -- The 0.6.0 release (a) corrects two bugs which caused abbreviated sequential references to display incorrectly (thanks, Matthew V. for the bug report), (b) simplifies search results, and (c) adds virtual paths. So instead of /bible/index.php?q=john+3.16, or even /bible/?q=john+3.16, you can now link to /bible/john+3.16, IF your Apache configuration supports mod_rewrite and .htaccess (see below).

Email me with any questions, or Add feedback to this page.

Page Contents

  1. License (GPL)
  2. Screenshots and overview
  3. Promotion
  4. Installation: FTP
  5. Installation: Linux shell
  6. Upgrading to version 0.6.0.
  7. Virtual paths in Apache2 with mod_rewrite and .htaccess
  8. Known Issues
  9. A note to Bible copyright holders
  10. Similar programs
  11. Future developments

1. License (GPL)

The Simple Parallel Bible is distributed under the GNU General Public License. Take it, use it, change it, enjoy.

GNU General Public License (GPL) — From OpenSource.org, the text of the leading open source software license. The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
http://www.opensource.org/licenses/gpl-license.php
World English Bible — Modern English, no copyright -- perfect for web use! The Simple Parallel Bible presently uses the World English Bible.
http://www.ebible.org/

2. Screenshots and overview

Some screenshots of version 0.5.2; almost the same as the current version.

Figure 1. Simple

The Simple Parallel Bible, as the name suggests, is mainly designed for simplicity. Thus there are no radio buttons or checkboxes to complicate the interface. The program determines from the nature of each query whether a search or a lookup is being performed. It correctly handles terms like 'Philemon', which it recognizes as a passage reference rather than a search term.

.

Figure 2. Parallels

When queries are separated by pipe '|' characters, they are displayed in parallel, for side-by-side comparison. A maximum of four parallel queries can be shown for the sake of readability.

Figure 3. Ranges

Passages references can include dashes and commas to indicate ranges. In the results, an ellipsis (...) will indicate any omitted text. Passages separated by slashes will be shown in sequence, and book names, if omitted will carry on from the prededing term.. A maximum of ten sequential queries can be shown.

Figure 4. Search

The search facility is primarily designed for ease of use. Terms are combined with an AND, so adding terms narrows a query. Terms will match any part of a word. Lowercase queries search the New Testament, while uppercase queries search the Old Testament. One of the quirks of the World English Bible, the fact that the word church never appears, is illustrated in this example.

3. Promotion

To plug the Simple Parallel Bible in an email newsletter, or some such forum, you might use the following text:

The Simple Parallel Bible is a search and lookup tool that can be
freely added to any PHP/MySQL website. It lets you link to multiple
passages, in parallel (for side-by-side comparison) or in a list,
all with a single link and without leaving your own site.

http://jesus.com.au/demo/bible/index.php
http://jesus.com.au/demo/bible/index.php?q=matt+19.16-30|mark+10.17-31|luke+18.18-30
http://jesus.com.au/demo/bible/index.php?q=matt+5.43-48/6.5-8,19-21/7.24-28

In HTML you might say —

The Simple Parallel Bible is a search and lookup tool that can be freely added to any PHP/MySQL website. It lets you link to multiple passages, in parallel (for side-by-side comparison) or in a list, all with a single link and without leaving your own site.

The <a href="http://jesus.com.au/demo/bible/index.php">Simple Parallel Bible</a> is a search and lookup tool that can be freely added to any PHP/MySQL website. It lets you link to multiple passages, <a href="http://jesus.com.au/demo/bible/index.php?q=matt+19.16-30|mark+10.17-31|luke+18.18-30">in parallel</a> (for side-by-side comparison) or <a href="http://jesus.com.au/demo/bible/index.php?q=matt+5.43-48/6.5-8,19-21/7.24-28">in a list</a>, all with a single link and without leaving your own site.

4. Installation: FTP

If you have shell access on a Linux/UNIX server see the second install guide, below. This is a general guide to installing the Simple Parallel Bible by FTP. Let me know if you have any trouble.

  1. Make sure you have your FTP details and your MySQL user name, password and database name, and the URL of your MySQL Web Admin Service. Contact your web hosting service if you do not know any of these details.
  2. Download the following two files to your PC: bible.tar.gz and web.sql.gz
  3. unzip and untar bible.tar.gz with WinZip, Powerarchiver, StuffIt, gunzip or whatever you happen to use on your computer.
  4. in the new bible subdirectory, edit the setup.inc.php file, so that it contains your MySQL username, password and database name
  5. Upload the bible directory to your website using your FTP client
  6. Open a web browser, point it at your web host's MySQL Web Admin service, and log in. You should see an option to upload and execute an SQL file. If this handles gzipped files (most do), you can upload the web.sql.gz file as it is. (Otherwise unzip it first, this means a roughly 10 Meg upload, however, which may not be possible or practical.)
  7. Click 'Browse', and choose the web.sql.gz file, then hit submit in the web form. Unless you have a really fast connection, go make a cup of coffee or something at this point. The script, when it has run will produce two new tables in your database: bible_books and bible_verses, containing the World English Bible.
  8. Now point your browser at the bible directory you have just created on your website. You should see something looking exactly the same as our demo site. Click some of the demo links to check that everything works.

And there you go. Once again, Contact me if you have any technical problems or any comments, good or bad. Don't contact me if you're having trouble with basic concepts like FTP. There are hundreds of tutorials online for FTP, MySQL, unzipping, etc. Google is your friend.

Google Search Engine — The world's most popular search engine.
Http://www.google.com

5. Installation: Linux shell

Move to your website's root directory, then get the two files you need via http. wget is simplest, though lynx --source does much the same thing once you pipe it to a file, and is available on more servers.

wget http://jesus.com.au/demo/bible.tar.gz
wget http://jesus.com.au/demo/web.sql.gz

Untar the bible/ directory.

$ tar -xzf bible.tar.gz

Create the database containing two tables: bible_books and bible_verses. It may take half a minute to add the 30,000 verses and then create their indexes.

$ gunzip web.sql.gz
$ mysql -u {username} -p {databasename} < web.sql > sql.log
Password: {userpassword}

Obviously, insert the appropriate {value} between the curly brackets. I recommend either running SQL in quiet mode, or piping the output to a logfile -- as I have done here -- unless you want a few thousand screenfuls of line-by-line INSERT confirmations.

Edit bible/setup.inc.php so that it contains your database access details:

$database_host = '';
$database_user = '{username}';
$database_pass = '{userpassword}';
$database_name = '{databasename}';

Point a browser at the front-end, and away you go.

http://yoursite.com/bible/?q=luke+15

6. Upgrading to version 0.6.0.

To upgrade to the latest version, you only need the new version of bible.tar.gz. The database is unchanged. The following instructions assume the Simple Parallel Bible is located at http://{your-web-site.org}/bible/; adjust if necessary.

First, rename your old directory from /bible to /bible2 (so you still have a working copy, whatever happens). Then unpack the new bible.tar.gz to create the new bible directory, and add your database details to setup.inc.php -- i.e. proceed as you would with a new installation of the files. Then view /bible/ on your server, and test that the example links work.

What you will need to check is whether your system supports virtual paths (see below), i.e. whether it has .htaccess and mod_rewrite enabled. If the default install returns a 'file not found' error when you try to view a verse, say /bible/luke+15, then set the $virtual_paths variable to false in setup.inc.php. You will need to link to verses or searches using the 'q' variable, e.g. /bible/index.php?q=luke+15.

7. Virtual paths in Apache2 with mod_rewrite and .htaccess

When you add your database connection details to the setup.inc.php file, you will notice a line that reads $virtual_paths = true;. This enables the most intuitive linking, by allowing you to omit the 'index.php?q=' part of any links. It lets you link directly to /bible/matt+28, for example.

This depends on your web server being Apache, and being configured to support both .htaccess and mod_rewrite. These allow the index.php file to handle ALL paths which start with /bible/ (or whatever your directory path is).

If the example links on the help page return 'file not found' errors, you need to EITHER set this variable to false, OR activate these two services, OR get your web hosting service to do so. If in doubt, take the first or third options.

If you administer your own server, then you will probably understand the following instructions, which cover the default Debian Linux install of Apache2, and may be able to adapt them to your needs. Note that while this is what works on my systems, yours may do things differently, so consult your usual sources for more information.

  1. .htaccess is enabled by removing any line that says 'AllowOverride None' in the Directory section of the appropriate VirtualHosts file in /etc/apache2/sites-available.
  2. mod_rewrite is enabled by executing the command sudo a2enmod rewrite.
  3. Neither change takes effect until you restart the web server, e.g. with sudo apache2ctl restart.

8. Known Issues

These will be corrected in the next round of changes. Surprisingly, people who offer feedback or suggest improvements never seem to notice that:

While I'm discussing the database, if anyone wishes to put any other freely distributable Bible translations into the following database format I'm happy to host the SQL files.

mysql> desc bible_verses;
+-------+--------+------+-----+---------+-------+
| Field | Type   | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------+
| b     | int(4) | YES  | MUL | NULL    |       |
| c     | int(4) | YES  |     | NULL    |       |
| v     | int(4) | YES  |     | NULL    |       |
| t     | text   | YES  | MUL | NULL    |       |
+-------+--------+------+-----+---------+-------+
5 rows in set (0.00 sec)

Thats book, chapter, verse and text columns (in HTML), respectively. Use the existing WEB database as a guide if unsure. I'll add the indexing.

9. A note to Bible copyright holders

Many good quality English-language Bible translations presently benefit almost no-one, least of all their copyright holders, having negligible market share.

Distribution licenses exist, however, which could give such translations a new lease of life. They would allow copyright holders to increase the distribution and usability of their texts, at little or no cost, while preserving their ownership and publication rights. The best known of these licenses, which cost nothing to use, are published by Creative Commons, and generally indicated by the phrase Some Rights Reserved.

For example, a copyright holder might allow:

Under such a license, anyone who distributed the text of a translation without observing its license conditions would forfeit any right at all to use it, and could be prosecuted in the normal manner for copyright violation.

From several perspectives, there are good reasons to consider this kind of licensing for Bible texts that would otherwise be declining, or those for which print editions are increasingly unviable.

If you represent the copyright holder for a modern English translation, and are potentially interested in this, but think that downloads from your website would be a cost issue, please contact me; I can probably arrange hosting with no such limitations.

Similarly, I would be happy to provide, or help you find, any further information you require on this subject. But the best source of information is probably the Creative Commons website.

Creative Commons — Creative commons licenses allow copyright holders to release their work for free distribution, under specific conditions, without losing copyright control. Such licenses cost nothing to use.
http://creativecommons.org/

10. Similar programs

I'm not aware of anything quite like the Simple Parallel Bible elsewhere. The following links may assist you if you're looking for something similar, however.

Freshmeat.net / Simple Parallel Bible — The Freshmeat site collects open source projects for Linux and related operating systems. As you can see, the Simple Parallel Bible is listed in the 'Religion' category.
http://freshmeat.net/projects/simple_parallel_bible/
SourceForge.net — SourceForge is probably the largest repository of open source software projects in the world.
http://sourceforge.net/

11. Future developments

Someone asked where I see this project going over time -- Well:

Creating Multilingual Web Pages — Subitled: Unicode Support in HTML, HTML Editors and Web Browsers. For anyone interested in creating new second-language editions of the Simple Parallel Bible.
http://www.alanwood.net/unicode/htmlunicode.html