UNL UCBCN Frontend

From Web Developer Network Wiki
Jump to: navigation, search

The Frontend is the main public interface to the UC Berkeley Calendar Network event publishing system server UNL_UCBCN.

This frontend provides many 'views' for clients to view upcoming and past events from the event system.

To install, use:

Requirements:


This is still in the alpha stages, to test it out use:

pear install unl/UNL_UCBCN_Frontend-beta
pear run-scripts unl/UNL_UCBCN_Frontend


The frontend is not complete - to see what is left to do, see:


URL Structure

The URL structure is somewhat complex, but fairly simple to understand, and very extensible:

Basic REST formatted URL structure:
http://events.example.com/[calendar.shortname][[[/YYYY/[MM/][DD/][event.title|event.id]]]

Examples:
http://events.example.com/                                 (Current date day view of all calendar events)
http://events.example.com/2006/05/                         (Month view of events for May 2006)
http://events.example.com/2006/01/01/                      (January 1st, 2006 day view of all calendar events)
http://events.example.com/2006/01/01/546123                (Details for the event with event.id=546123 on January 1st, 2006)
http://events.example.com/2006/01/01/Fishing%20Expedition  (Details for the Fishing Expedition event on January 1st, 2006 Ice Fishing? brr)
http://events.example.com/math/                            (Current date day view events for Math Department)
http://events.example.com/svcaa/2006/                      (Year calendar for SVCAA)
http://events.example.com/journalism/2006/06/02/           (Journalism calendar for the day June 2nd 2006)
http://events.example.com/cityunion/2006/07/08/53245       (Details for the event in the City Union on July 8th, 2006 with event.id=53245)
http://events.example.com/ianr/2006/06/02/Shrieb%20Lecture (Details for the IANR Shrieb lecture on June 2nd, 2006)

http://events.unl.edu/upcoming/                            (Upcoming Events)
http://events.unl.edu/math/upcoming/                       (Upcoming Math Events)
http://events.unl.edu/search/                              (Search Results)
http://events.unl.edu/math/search/                         (Search Math Results)

If no calendar shortname is provided the default calendar (calender.id == 1 or whatever is set in the frontend index.php) will be shown.

In addition, the frontend supports various output formats for each of the REST based URLs by appending a format querystring value:

Optional Output Format Parameters:
http://events.unl.edu/?format=hcalendar                    (Returns a snippet of hcalendar formatted xhtml)
http://events.unl.edu/?format=rss                          (RSS subscribe-able feed of today's events)
http://events.unl.edu/?format=ics                          (.ics iCalendar formatted file of today's events)
http://events.unl.edu/?format=xml                          (XML output using UC Berkeley events schema)
http://events.unl.edu/?format=html                         (Full HTML webpage [default])

As well as various view modes:
http://events.unl.edu/math/upcoming/                       (upcoming events for Math Department)
http://events.unl.edu/math/?month                          (current month view for Math Department)
http://events.unl.edu/?s=0                                 (week view starting with Sunday[0])

Search Results:
http://events.unl.edu/search/                              (search view)
http://events.unl.edu/search/music/                        (search results for upcoming music events)
http://events.unl.edu/search/music/?format=hcalendar       (search results for 'music' in hcalendar format)


Now for something fun:
http://events.unl.edu/search/football/?format=rss          (an rss feed of upcoming football events)

Sample mod_rewrite rules

The following are provided for site administrators interested in seeing how the REST based URL structure can be handled by using mod_rewrite with Apache:

RewriteEngine On

RewriteBase   /events

RewriteRule ^upcoming/$ ?upcoming=upcoming&%{QUERY_STRING} [L]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/upcoming/$ $1/?upcoming=upcoming&%{QUERY_STRING} [L]

RewriteRule ^search/$ ?search=search&%{QUERY_STRING} [L]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/search/$ $1/?search=search&%{QUERY_STRING} [L]

RewriteRule ^search/(.+)/$ ?search=search&q=$1&%{QUERY_STRING} [L]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/search/(.+)/$ $1/?search=search&q=$4&%{QUERY_STRING} [L]

# Account rewrite
RewriteRule ^(([a-zA-Z]([0-9]+)?)+)$ $1/ [R]
RewriteCond %{REQUEST_URI} !^/events/manager/
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/$ ?calendar_shortname=$1&%{QUERY_STRING}

# year rewrite
RewriteRule ^([0-9]{4})$ $1/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})$ $1/$4/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/$ ?calendar_shortname=$1&y=$4&%{QUERY_STRING} [L]

# month rewrite
RewriteRule ^([0-9]{4})/(([0-1])?[0-9])$ $1/$2/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/(([0-1])?[0-9])$ $1/$4/$5/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/(([0-1])?[0-9])/$ ?calendar_shortname=$1&y=$4&m=$5&%{QUERY_STRING} [L]

# day rewrite
RewriteRule ^([0-9]{4})/(([0-1])?[0-9])/(([0-3])?[0-9])$ $1/$2/$4/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/(([0-1])?[0-9])/(([0-3])?[0-9])$ $1/$4/$7/ [R]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/(([0-1])?[0-9])/(([0-3])?[0-9])/$ ?calendar_shortname=$1&y=$4&m=$5&d=$7&%{QUERY_STRING} [L]

# single eventinstance rewrite
RewriteRule ^([0-9]{4})/(([0-1]?[0-9])/)?(([0-3]?[0-9])/)?(([0-9]+)/)?$ ?y=$1&m=$3&d=$5&eventdatetime_id=$7&%{QUERY_STRING} [L]
RewriteRule ^(([a-zA-Z-_]([0-9]+)?)+)/([0-9]{4})/(([0-1]?[0-9])/)?(([0-3]?[0-9])/)?(([0-9]+)/)?$ ?calendar_shortname=$1&y=$4&m=$5&d=$7&eventdatetime_id=$9&%{QUERY_STRING} [L]

API Documentation

API Documentation is available at http://pear.unl.edu/docs/UNL_UCBCN_Frontend/

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox