Somehow, somewhere, someone clicks a link or types in a browser the following:
http://www.live365.com/stations/live365premiumThis URL is first encountered by a "thin-layer" Apache webserver, which employs a Rewrite Rule to shift the request to one of our "FAT3" webservers (which, incidentally, are running Mason 1.28 vs. 1.0x running on the normal servers):
Note that the page request is internally redirected via Apache to# # overrides to 5003 # RewriteRule ^/stations/(.*) http://10.10.11.173:5003/stations/$1 [P,L]
http://10.10.11.173:5003/stations/$1
-- this means that our original URL gets mapped to someting like
http://10.10.11.173:5003/stations/live365premiumAnother Apache configuration directive within the FAT3 webserver tells it to treat any file within the
/stations
directory as a Mason file to be parsed by the Mason engine (READ: don't put anything else but Mason files in this directory, else your GIFS and JPEGS will be interpreted by the Mason engine -- BAD THINGS WILL HAPPEN!):
<Location /stations> SetHandler perl-script PerlHandler Live365::Mason PerlSetVar MasonDeclineDirs 0 DefaultType text/html </Location>
/stations
directory
at the webroot level, and then also a /live365premium
subdirectory within that. This is not the case, since we'd then need a subdirectory for every single station on Live365. Well then, how does this work, you ask? If you look into the /stations
directory, you'll see a single file called and named dhandler. This is a special type of Mason file that gets triggered when a non-existing file is requested. So, although the URL asks for /stations/live365premium
, only /stations
actually exists, and the dhandler file gets executed. Aha!
Here's a secret debugging tip: If you append "?dddebug=1" onto the original URL, you can see what the dhandler is calculating. In a nutshell, it parses the station name ("live365premium") from the URL, and also gets the value of the optional "site" parameter (the default value of which is "live365"), and uses those to formulate a new internal URL:
http://[FAT3 WEBSERVER]/scp/live365["live365" IS THE DEFAULT SITE VALUE]/station_info.live?station_name=live365premiumThe SCP dhandler performs an internal redirect to this new URL. The rest of the Mason functionality within the template system works off of this secondary internal URL. Note that the URL in the browser window doesn't change, however -- this preserves our legacy "friendly" public URLs for station pages.
/scp/live365/station_info.live?station_name=live365premium
You're probably thinking that there's a file called station_info.live
in the
/scp/live365
directory -- and I don't blame you. However, it's a little more complicated than that. In fact, there isn't a file at that location. During the design-phase of the templating system, we thought it'd be efficient to contain the station-page-related files within a single subdirectory within the SCP heirarchy, seperating them from, say, player-window files in /mini
...so the station-page files are in a /stn
directory: /scp/live365/stn
in this case. So ultimately, that's where our station_info.live
file actually lives.
Again we're employing a dhandler file to map the /scp/live365/station_info.live?station_name=live365premium
URL to the actual file in the /scp/live365/stn
directory. The dhandler lives in the /scp
directory, and parses the PATH from the URL and also grabs the station_name parameter value. It builds another internal URL (/scp/live365/stn/station_info.live
) and performs a subrequest -- we use a subrequest here instead of an internal redirect because we want the subsequent page to inherit properly. If you append "?ddebug=1" (2 'd's this time) onto the original URL, you can see what's going on.
/scp/live365/stn/station_info.live?station_name=live365premium
At this point, Mason's object-oriented inheritance features come into play, through the use of autohandlers. There's a top-level autohandler file in the /scp
directory, which controls the inclusion of page headers and footers, plus it contains methods and attributes for controlling (among other things) the web-page title, CSS includes, and Javascript includes. You can view some debugging information for this autohandler by appending "?debug=1" onto the URL.
local.css
exists in our /scp/SITE
directory, it is included into the web page in the proper cascading order for this and all similar pages.
header.mc
exists in our /scp/SITE/stn
directory, it is included as the web page header for this an all similar pages.
footer.mc
exists in our /scp/SITE/stn
directory, it is included as the web page footer for this and all similar pages.
/scp/SITE/stn
directory to apply further customization across the set of skinned pages for that SCP.
/stations
directory.
/stations
directory that parses the friendly URL into a template-system-friendly format.
/scp
directory that controls which page-template file is used.
/scp
directory that lays the foundation for object-oriented inheritance and HTML content-wrapping.
http://www.live365.com/stations/live365premium?site=pro/green01When you click on the link, you'll notice that the page is green and is missing a header and footer, plus the content of the page is slightly different. This, of course, is controlled by the template system. All of the previously-discussed Apache processes happen exactly the same way in this skinned case. The first difference we encounter occurs in the "friendly URL" dhandler. If you again append "&dddebug=1" onto the URL you'll notice that now our SITE value is "pro/green01" whereas before it was "live365". This parameter instructs the "friendly URL" dhandler (which lives in the
/stations
directory, remember) to internally redirect to /scp/pro/green01/station_info.live?station_name=live365
. Again, there's no station_info.live
file in that directory. The SCP dhandler comes into play here, and as before, checks into the /stn
subdirectory for the proper file. However, in this case, this file doesn't exist. The SCP dhandler is intelligent enough to walk up the SCP directory tree (currently only 2 layers) looking in each successive /stn
directory until it finds the requested file. For our example, this means that the dhandler finds and uses the file /scp/pro/stn/station_info.live
. Note also that, although the template file comes from the /scp/pro/stn
directory, /scp/pro/green01/local.css
is still being used to define the colors and fonts used on the page. Additionally, if any pro/green01 headers and footers existed, those would be picked up, too. This functionality, based on the nested SCP arrangement, allows us to customize headers, footers, and CSS files but still use a single (set of) page template(s).
DJ Profile: http://www.live365.com/profiles/live365premiumThe mechanism supporting the DJ Profile URL works in much the same way as the Station Page URL -- the main differences are a second set of Apache config parameters to support theBroadcast Schedule: http://www.live365.com/stations/live365premium/schedule
/profiles
directory, another Mason dhandler in the /profiles
directory, and instead of redirecting to "station_info.live" we switch to "dj_profile.live"
The dhandler within the /scp
directory executes as before, but now looks for "dj_profile.live" in the various /stn
directories.
The functionality behind the Broadcast Schedule URL is contained within the /stations
dhandler -- if "/schedule" exists in the URL, the dhandler redirects to the scheduler page vs. the normal station page. This can be expanded to handle additional pages as the need arises.