Example Apache Configs for domain based branding user/tsbere/apache_lib_urls
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 12 Mar 2013 13:41:25 +0000 (09:41 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Tue, 12 Mar 2013 13:52:07 +0000 (09:52 -0400)
The example in this commit assumes you have configured apache to serve
multiple domains or subdomains, either via multiple vhosts or wildcards.

The latter is easily possible with something like:

ServerAlias *.example.org

In your VirtualHost entries.

The apache configurations refer to four datafiles, though you can add more
fairly easily (MVLC has a Novelist file, for example, to hold Novelist codes
per library subdomain). The example files provided here are:

libcode.txt - This is for domain/subdomain to "code" mapping. The code is
    used as the lookup key on all the other files, as well as for looking
    up the logo file.
libname.txt - This is for the library name, for linking to the library in
    this example, but it could be used without that as well. Note that you
    need to use something like &#32; instead of spaces in the names.
libphysloc.txt - This is for the "physical location" that serves as the
    preferred library when patrons are not logged in. This triggers default
    search scoping and floating of copies to the top of lists in results.
liburl.txt - This is for the URL to the library's website, used for linking
    the logo and creating a link in the topnav links bar.

Note that the libcode lookup specifies a default value. If the domain isn't
found then "DEFAULT" is used as the code for other lookups.

The libcode is used for logo lookups by seeing if a replacement small/large
logo exists in /opac/images/LIBCODE/. This can be easily extended to other
files entirely.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/examples/apache/datafiles/README [new file with mode: 0644]
Open-ILS/examples/apache/datafiles/libcode.txt [new file with mode: 0644]
Open-ILS/examples/apache/datafiles/libname.txt [new file with mode: 0644]
Open-ILS/examples/apache/datafiles/libphysloc.txt [new file with mode: 0644]
Open-ILS/examples/apache/datafiles/liburl.txt [new file with mode: 0644]
Open-ILS/examples/apache/eg_vhost.conf.in
Open-ILS/src/templates/opac/parts/topnav_links.tt2
Open-ILS/src/templates/opac/parts/topnav_logo.tt2

diff --git a/Open-ILS/examples/apache/datafiles/README b/Open-ILS/examples/apache/datafiles/README
new file mode 100644 (file)
index 0000000..b108e37
--- /dev/null
@@ -0,0 +1,20 @@
+These files would go in /openils/conf/, where apache would then read them.
+
+libcode.txt - This is for domain/subdomain to "code" mapping. The code is
+    used as the lookup key on all the other files, as well as for looking
+    up the logo file.
+libname.txt - This is for the library name, for linking to the library in
+    this example, but it could be used without that as well. Note that you
+    need to use something like &#32; instead of spaces in the names.
+libphysloc.txt - This is for the "physical location" that serves as the
+    preferred library when patrons are not logged in. This triggers default
+    search scoping and floating of copies to the top of lists in results.
+liburl.txt - This is for the URL to the library's website, used for linking
+    the logo and creating a link in the topnav links bar.
+
+Note that the libcode lookup specifies a default value. If the domain isn't
+found then "DEFAULT" is used as the code for other lookups.
+
+The libcode is used for logo lookups by seeing if a replacement small/large
+logo exists in /opac/images/LIBCODE/. This can be easily extended to other
+files entirely.
diff --git a/Open-ILS/examples/apache/datafiles/libcode.txt b/Open-ILS/examples/apache/datafiles/libcode.txt
new file mode 100644 (file)
index 0000000..8bd7361
--- /dev/null
@@ -0,0 +1,3 @@
+domain1.toplevel.ext liba
+domain2.toplevel.ext libb
+domain3.toplevel.ext libc
diff --git a/Open-ILS/examples/apache/datafiles/libname.txt b/Open-ILS/examples/apache/datafiles/libname.txt
new file mode 100644 (file)
index 0000000..b53c5d3
--- /dev/null
@@ -0,0 +1,3 @@
+liba Library&#32;A
+libb Library&#32;B
+libc Library&#32;C
diff --git a/Open-ILS/examples/apache/datafiles/libphysloc.txt b/Open-ILS/examples/apache/datafiles/libphysloc.txt
new file mode 100644 (file)
index 0000000..ea7c29c
--- /dev/null
@@ -0,0 +1,4 @@
+liba 3
+libb 4
+libc 5
+DEFAULT 1
diff --git a/Open-ILS/examples/apache/datafiles/liburl.txt b/Open-ILS/examples/apache/datafiles/liburl.txt
new file mode 100644 (file)
index 0000000..c27910b
--- /dev/null
@@ -0,0 +1,3 @@
+liba http://liba-domain.ext
+libc http://libb-domain.ext
+libc http://libc-domain.ext
index 26b0485..79edc4d 100644 (file)
@@ -4,9 +4,9 @@
 # ----------------------------------------------------------------------------------
 
 # ----------------------------------------------------------------------------------
-# Point / to the opac - if you have a custom skin or locale, point at it here
+# Point / to the opac
 # ----------------------------------------------------------------------------------
-RedirectMatch 301 ^/$ /opac/en-US/skin/default/xml/index.xml
+RedirectMatch 301 ^/$ /eg/opac/home
 
 # ----------------------------------------------------------------------------------
 # Point / to the IP address redirector
@@ -92,6 +92,41 @@ RewriteRule . - [E=locale:%1]
 Options -Indexes
 
 # ----------------------------------------------------------------------------------
+# Library Branding
+# ----------------------------------------------------------------------------------
+
+RewriteMap lowercase    int:tolower
+RewriteMap libcode      txt:/openils/conf/libcode.txt
+RewriteMap liburl       txt:/openils/conf/liburl.txt
+RewriteMap libname      txt:/openils/conf/libname.txt
+RewriteMap libphysloc   txt:/openils/conf/libphysloc.txt
+RewriteRule . - [E=libcode:${libcode:${lowercase:%{HTTP_HOST}}|DEFAULT}]
+RewriteRule . - [E=liburl:${liburl:%{ENV:libcode}}]
+RewriteRule . - [E=libname:${libname:%{ENV:libcode}}]
+RewriteRule . - [E=physical_loc:${libphysloc:%{ENV:libcode}}]
+
+# Logo URLs
+RewriteCond %{REQUEST_URI} /opac//?images//?main_logo.jpg
+RewriteCond %{DOCUMENT_ROOT}/opac/images/%{ENV:libcode}/main_logo.jpg -f
+RewriteRule /opac//?images//?main_logo.jpg /opac/images/%{ENV:libcode}/main_logo.jpg
+
+RewriteCond %{REQUEST_URI} /opac//?images//?small_logo.jpg
+RewriteCond %{DOCUMENT_ROOT}/opac/images/%{ENV:libcode}/small_logo.jpg -f
+RewriteRule /opac//?images//?small_logo.jpg /opac/images/%{ENV:libcode}/small_logo.jpg
+
+# Keyword
+RewriteRule ^/search/keyword/(.*) /eg/opac/results?qtype=keyword&query=$1 [R]
+
+# DB ID (direct load)
+RewriteRule ^/search/id/(.*) /eg/opac/record/$1 [R]
+
+# ISBN
+RewriteRule ^/search/isbn/(.*) /eg/opac/results?_special=1&qtype=identifier|isbn&query=$1 [R]
+
+# My account
+RewriteRule ^/myaccount https://%{HTTP_HOST}/eg/opac/myopac/main [R]
+
+# ----------------------------------------------------------------------------------
 # Configure the OPAC
 # ----------------------------------------------------------------------------------
 <LocationMatch /opac/>
index e6f4169..e5364be 100644 (file)
@@ -1,6 +1,7 @@
 <div id="gold-links-holder">
     <div id="gold-links">
         <div id="header-links">
+            [% IF ENV.liburl && ENV.libname %]<a href="[% ENV.liburl %]">[% ENV.libname %]</a>[% END %]
             <a href="http://example.com">[% l('Link 1') %]</a>
             <a href="http://example.com">[% l('Link 2') %]</a>
             <a href="http://example.com">[% l('Link 3') %]</a>
index 0b55700..1564ad0 100644 (file)
@@ -1,2 +1,8 @@
-       <div id="topnav_logo"> <a href="http://evergreen-ils.org"><img alt="[% l('Evergreen Logo') %]" 
-            src="[% ctx.media_prefix %]/opac/images/small_logo.png" /></a></div>
+       <div id="topnav_logo">
+[% IF ENV.liburl && ENV.libname %]
+        <a href="[% ENV.liburl %]"><img alt="[% l(ENV.libname) %]"
+[% ELSE %]
+        <a href="http://www.evergreen-ils.org"><img alt="[% l('Evergreen Logo') %]"
+[% END %]
+            src="[% ctx.media_prefix %]/opac/images/small_logo.jpg" /></a>
+       </div>