OPAC Enhancer for Aleph
Tags: aleph
, opac
, customization
, translation
Last Updated: Apr 29, 2011 11:34
- Description
OPAC Enhancer is a daemon written in Perl that sits between Aleph www server and Apache. It can be used to modify requests before they reach the www server and responses before they reach the client (browser).
By default it is possible to do "translations" (either language-specific or global) of the results, but it is also possible to add custom processing to enable customized functions or server-side amending of the response with results from an external source eliminating the need to use client-side JavaScript.
OPAC Enhancer will also fix HTTP headers Aleph sends in case they contain only LF as the end-of-line marker. Resulting headers will contain CR LF markers to make the responses conform to RFC 2616 (this problem should be fixed in Aleph v19 rep_ver #14191).
- Author: Ere Maijala
- Additional author(s):
- Institution: None
- Year: 2008
- License: MPL 1.1 / GPL 2.0
- Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
- Link to terms: MPL 1.1, GPL 2.0
- Skill required for using this code: intermediate
- State
- Programming language
- Software requirements
- Screen captures
- Author(s) homepage
- Download
- Working example
- Using the following Ex Libris open interfaces
- Changes
- Version 1.06 - 28 Oct 2010
- Version 1.05 - 10 Mar 2010
- Version 1.03
- Version 1.02
- Version 1.01
- Version 1.0
- Release notes
- Installation instructions
- Configuration
- TO DO list
- Comments
State
Stable (in production use)
Programming language
Perl
Software requirements
Tested with Aleph 18 under Solaris. Should work in different environments too. Requires the following Perl modules (nothing extraordinary):
- Getopt::Long;
- IO::Socket;
- Net::hostent;
- CGI
- POSIX
- Cwd
- File::Basename
Screen captures
-
Author(s) homepage
Download
Working example
-
Using the following Ex Libris open interfaces
None so far.
Changes
Version 1.06 - 28 Oct 2010
- Safeguard counter for the child process handler. Needed for robust handling and to avoid occasional delays in the main process.
Version 1.05 - 10 Mar 2010
- More robust child process handling in busy environments.
Version 1.03
- Dies harder. Tries to log problems rather than die whenever the smallest hint of trouble shows up.
- Fixed HTTP Headers Aleph sends to properly use CR LF instead of just LF as the end-of-line marker.
Version 1.02
- Fixed relaying responses (or requests) larger than 64 kilobytes.
Version 1.01
- Fixed reaping of child processes (no more defunct/zombie processes).
Version 1.0
- Initial release.
Release notes
Version 1.0 is an initial release. It should be stable but has not been tested in a busy live environment yet.
Installation instructions
- Log in to the server as aleph user
- Download the tar file to the server and unpack it into /exlibris/opac_enhancer directory. If any other path is used, change paths in opac_enhancer.sh and opac_enhancer.config accordingly.
- Verify that opac_enhancer.sh and opac_enhancer.pl are executable (chmod +x ... if necessary)
- Add opac_enhancer daemon to aleph_startup (e.g. /exlibris/aleph/u18_1/alephe/aleph_startup) before the end:
This allows the daemon to start up when Aleph starts. It can be added to system startup (init.d) instead if desired.
- Add opac_enhancer daemon to aleph_shutdown (e.g. /exlibris/aleph/u18_1/alephe/aleph_shutdown) before shutdown of servers:
This allows the daemon to stop when Aleph shuts down. It can be added to system shutdown (init.d) instead if desired.
- Start the daemon by running ./opac_enhancer start
- Verify that the log says something like:
This means that the daemon was able to start successfully. If it fails, you can run it manually:
This makes is run non-detached and you can e.g. possible compilation errors.
- Modify Apache's httpd.conf (e.g. /exlibris/aleph/u18_1/alephe/apache/conf/httpd.conf).
Find the lines that say:and change the port to 4191:

It is assumed that you have Aleph www server in port 4991. If that is not the case, please change the port in opac_enhancer.config. See below for configuration options. - Restart Apache by running apache/bin/apachectl restart, e.g.
- Check to see if the OPAC still works.
- If the OPAC doesn't work, check the log for error messages
Configuration
Main configuration is done in the configuration file, by default opac_enhancer.config. Here are the configuration directives:
General
| Directive | Description |
|---|---|
| working directory | The directory where all the files reside and where log and pid file are written |
| log file | Name of the log file. Created in the working directory |
| pid file | Name of the pid file that tells the process id of the running instance. Must be the same as in opac_enhancer.sh. Created in the working directory |
| listening address | The address where the daemon listens for connections from Apache. Normally loopback address, 127.0.0.1, but can be set to another address if Apache is on a different server |
| listening port | The TCP port where the daemon listens for connections from Apache. Can be changed to anything desired. Needs to be the same as the port in Apache httpd.conf |
| debug | Level of debugging information written into log (0 = none, 1 = normal, 2 = data dumps of incoming and outgoing data to dump.dat too |
Aleph
| Directive | Description |
|---|---|
| www server address | The address of Aleph www server. Normally 127.0.0.1 if opac_enhancer and www server are on the same server |
| www server port | The TCP port of Aleph www server |
Translation
Translations can be used to change any content in the HTML pages, for instance to extend texts that have a limited length in Aleph configuration tables.
| Be careful not to change something that might exist in displayed record data unless that's what you want. |
| Directive | Description |
|---|---|
| global | Name of a file containing translations done regardless of the used language |
| [Aleph:language code] | Name of a file containing translations done only for the specified language code |
The translation files can contain simple text to text translations or regular expressions. Simple texts are entered like this (separator is space dash dash space):
Regular expressions can be entered like this:
opac_enhancer_local.pm
opac_enhancer_local.pm is a module where local customizations and advanced functionality can be added.
local_preprocess function is called before the request is passed to the www server. If local_preprocess returns a non-zero value, the request is not passed to Aleph at all.
local_postprocess function is called before the response is sent to the client. It can be used to more advanced stuff than the simple translations can, e.g. function-specific things, database lookups etc.
TO DO list
- Caching of translations
- Automatic reload of configuration when it's changed
- More features
- Testing on different platforms


2 Comments
comments.show.hideMar 03, 2009
Christoph Krempe
Nice tool, but I get problems when I use it together with https.
Christoph
Apr 08, 2009
Ere Maijala
What kind of problems?
Would it be possible to get a a data dump? Set debug=2 in the config, restart and do something. Then email me (ere.maijala at helsinki.fi) dump.dat.
Thanks,
Ere