The global configuration file is an XML file that can have any name and can be placed anywhere in your web site, but you need to tell JPBlog about its location when adding the main servlet in the web.xml deployment descriptor:
<servlet> <servlet-name> MainServlet </servlet-name> <servlet-class>org.jpblog.process.MainServlet</servlet-class><init-param> <param-name>config</param-name> <param-value>/WEB-INF/jpblogconfig.xml</param-value> </init-param></servlet>
Although you can check the DTD of the file for a formal definition of its structure, let's examin a sample configuration (line numbers are included for clarity, they are not part of the file):
0001<?xml version="1.0" encoding="iso-8859-1"?> 0002<!DOCTYPE jpblog-config PUBLIC "http://www.ahristov.com/uri/jpblog-config/1.0" "jpblog-config.dtd" > 0003<jpblog-config> 0004 0005 <data-dir> /viajes/data </data-dir> 0006 <jsp-dir> /viajes </jsp-dir> 0007 <messages> /viajes/data/msg </messages> 0008 <skin-dir> /viajes/skins </skin-dir> 0009 <default-skin> pirate </default-skin> 0010 0011 <google 0012 ad-client="pub-XXXXX" 0013 ad-channel="NNNNNNN" 0014 map-key="KEY" 0015 /> 0016 0017 <index-page> /index.jsp </index-page> 0018 <trip-page> /trip.jsp </trip-page> 0019 <leg-page> /leg.jsp </leg-page> 0020 <photo-page> /photo.jsp </photo-page> 0021 <available-locales>es,en</available-locales> 0022 0023 <photos-per-page>12</photos-per-page> 0024 0025 <thumbnail 0026 name="thumbnail-small" 0027 max-size="100" 0028 store="true" 0029 prefix="thumbnail-small-"/> 0030 0031 <thumbnail 0032 name="thumbnail-medium" 0033 max-size="200" 0034 store="true" 0035 default="true" 0036 prefix="thumbnail-med-"/> 0037 <photo max-size="800" store="true" prefix="photo-"/> 0038 0039 0040 <url lang="es">/viaje</url> 0041 <url lang="en">/travel</url> 0042 0043 <default-locale>es</default-locale> 0044</jpblog-config> 0045
As you can see, the root element of the file is jpblog-config. Inside this element we find the following elements:
The google element above configures google specific options:
The names of the JSP pages used by the system are configured by the following elements. Each element requires a full path relative to the context root of your web site.
The available-locales element specifies a comma-delimited list of languages that are going to be supported. This is used in order to know how many language flags to display on the top menu:
For each of the languages defined, a locale-??.gif image must exist in the skin directory, where ?? is the two-character code of the supported language. The image must contain a suitable representation of the language (usually it is a country flag, as above). In the example configuration file, since the "es" and "en" locales are supported, this means that "locale-es.gif" and "locale-en.gif" must exist.
The default-locale element specifies which is the default locale to be used when none of the languages requested by the user is available OR when a description in the supported language is not available.
The url element specifies, for each of the supported languages, which is the root url for accessing the jpblog. For a description of how jpblog handles urls, please see the "URL Handling" section of this manual. In the above example, the "/travel" url is configured for english, and "/viaje" is configured for Spanish. This means that when a user types http://www.yoursite.com/travel/... he will automatically see the site in english, and if he instead types http://www.yoursite.com/viaje/... he will automatically see the site in spanish.
Why derive the language to use from the URL instead of simply checking the Accept-Language HTTP header? Because in this way, a crawler can crawl ALL localized versions of the site.
If you add/remove/modify options of this configuration you MUST also modify the web.xml file to alter the URLS to which the main servlet is mapped. One mapping must exist for each of the urls:
<servlet-mapping> <servlet-name>MainServlet</servlet-name><url-pattern>/viaje/*</url-pattern></servlet-mapping> <servlet-mapping> <servlet-name>MainServlet</servlet-name><url-pattern>/travel/*</url-pattern></servlet-mapping>
The thumbnail elements configure the different available thumbnails. For a description of what each parameter means, please see the "Thumbnails" section of this manual. You must define at least one thumbnail configuration.
Sometimes you don't want the visitors to access the full-resolution images of your photographs. This could be the case if your images are too big and you want to save bandwith. In these cases, you can include a single photo element. If present, this element tells jpblog that when a user clicks on a photograph in order to view the full-size image, a resized version should be presented instead.
Finally, the photos-per-page element specifies how many photographs are shown per page, in the leg (location) pages.