Menu

#39 Configurable URLs

v3.0
open
5
2003-05-13
2003-05-13
Rajiv Pant
No

Allow the Cofax URL pattern to be configurable. (We
had envisioned this back in 1999 when we started
Cofax.)

These configurable URLs would define how Cofax CDS
should parse the URL. i.e. where to get the publication
name from, which part is the date, which part is the
section name, which part is the article name, etc.

Some benefits of being able to pick up the publication
name from different places in the URL (part of
host/domain name, part of folder path, etc.)

* Some sites may use an internal URL for development,
staging, etc. This URL may be something like
www.inquirer-dev.realcities.com. The system would need
to be configurable to read the pattern "inquirer" from
such URLs.

* On a developer's local PC, a developer may want to
get the publication name form the folder path. Some
production sites with multiple publications under the
same domain name may prefer this too.

Some other benefits:

* Future benefit: Dates may be specified in patterns
other than 2003/05/13.

Suggestions for implementation:

This configuration should be stored in a config file
(web.xml) or maybe in the database.

Using regular expressions to define the pattern
matching would be a good way to go.

For example, the config file may specify multiple URL
patterns in order as shown below. Cofax CDS would
match the current URL one by one for a full match with
these patterns until a match is found. Once a match is
found, it would populate the fields as specified in the
config file.

This is similar to how the CDS servlet works today
except that it is in the Java code and not in a config file.

In the two examples below, for simplicity, I have not
included the full URL with host/domain name. It should
be obvious how to include that and I will also add more
examples to this item later as we determine the best
xml config format.

<urls>

<url name="pubAndDateAndSection">

<pattern>
^/([\w\-]+)/(\d{4})/(\d{2})/(\d{2})/([\w\-]+)/$
</pattern>

<item name="publication" value="$1">
<item name="year" value="$2">
<item name="month" value="$3">
<item name="day" value="$4">
<item name="section" value="$5">

</url>

<url name="pubAndDateAndSectionAndArticle">

<pattern>
^/([\w\-]+)/(\d{4})/(\d{2})/(\d{2})/([\w\-]+)/([\w\-]+)\.([\w\-]+)$
</pattern>

<item name="publication" value="$1">
<item name="year" value="$2">
<item name="month" value="$3">
<item name="day" value="$4">
<item name="section" value="$5">
<item name="filename" value="$6">
<item name="extension" value="$7">
</url>

</urls>

Discussion


Log in to post a comment.