From: Thomas Berezansky Date: Tue, 12 Mar 2013 13:41:25 +0000 (-0400) Subject: Example Apache Configs for domain based branding X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Ftsbere%2Fapache_lib_urls;p=working%2FEvergreen.git Example Apache Configs for domain based branding 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 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 --- diff --git a/Open-ILS/examples/apache/datafiles/README b/Open-ILS/examples/apache/datafiles/README new file mode 100644 index 0000000000..b108e37b4b --- /dev/null +++ b/Open-ILS/examples/apache/datafiles/README @@ -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 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 index 0000000000..8bd7361089 --- /dev/null +++ b/Open-ILS/examples/apache/datafiles/libcode.txt @@ -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 index 0000000000..b53c5d3de5 --- /dev/null +++ b/Open-ILS/examples/apache/datafiles/libname.txt @@ -0,0 +1,3 @@ +liba Library A +libb Library B +libc Library C diff --git a/Open-ILS/examples/apache/datafiles/libphysloc.txt b/Open-ILS/examples/apache/datafiles/libphysloc.txt new file mode 100644 index 0000000000..ea7c29c988 --- /dev/null +++ b/Open-ILS/examples/apache/datafiles/libphysloc.txt @@ -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 index 0000000000..c27910b834 --- /dev/null +++ b/Open-ILS/examples/apache/datafiles/liburl.txt @@ -0,0 +1,3 @@ +liba http://liba-domain.ext +libc http://libb-domain.ext +libc http://libc-domain.ext diff --git a/Open-ILS/examples/apache/eg_vhost.conf.in b/Open-ILS/examples/apache/eg_vhost.conf.in index 26b0485d01..79edc4dfd2 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf.in +++ b/Open-ILS/examples/apache/eg_vhost.conf.in @@ -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 # ---------------------------------------------------------------------------------- diff --git a/Open-ILS/src/templates/opac/parts/topnav_links.tt2 b/Open-ILS/src/templates/opac/parts/topnav_links.tt2 index e6f4169799..e5364be23b 100644 --- a/Open-ILS/src/templates/opac/parts/topnav_links.tt2 +++ b/Open-ILS/src/templates/opac/parts/topnav_links.tt2 @@ -1,6 +1,7 @@