org.locomotive.module.pub
Class PublisherHandler

java.lang.Object
  |
  +--org.locomotive.loco.handler.GenericHandler
        |
        +--org.locomotive.module.pub.PublisherHandler

public class PublisherHandler
extends GenericHandler

This class is the main handler for the Locomotive Personal Website Publisher. This example module of the Locomotive allows users to create and design their own website by filling out text fields, inserting images, and arranging all of the HTML elements in a pre-arranged lay-out determined by the template selected by the user. The Locomotive stores all of the necessary information (text strings, images, which template is used, etc.) and automatically dynamically creates the page for viewing when the handler string is parsed to determine the specific user's page. This module also displays an index of published webpages, beginning with the most recent. NOTE: The image path (image_path) variable below must be modified All templates for the Publisher Module are in the templates/pub dir. The tokens and their corresponding methods are:

 Token          Method              Template
 [no token]     showMain()          pub/main.tmpl
 index          showDefaultIndex()  pub/index.tmpl
 approve        showApprove()       pub/approve.tmpl
 censor         showCensor()        pub/censor.tmpl
 create         showCreate()        pub/create.tmpl
 preview        showPreview()       pub/preview.tmpl 
 final          showFinal()         pub/final.tmpl
 


Field Summary
static int num_listings_per_index_page
          Constant used to determine how many page listings to show per index page.
static java.lang.String PUB_ADMIN
          Permission that allows a user to allow or censor newly user-created web pages.
 
Fields inherited from class org.locomotive.loco.handler.GenericHandler
already_displayed_page, conn, DEBUG, ERROR, form_data, handler_uri, hd, NORMAL, session, steam_vars, url_tokens, user, WARNING
 
Constructor Summary
PublisherHandler()
           
 
Method Summary
protected  void getPermissions()
          Prepares the PermissionSet object for permission checking.
 void handleRequest(HandlerData hd_in)
          main entry point called by RequestManager for each new request.
 boolean init(Log log)
          The required init method, as defined in org.locomotive.loco.Handler.
protected  void showApprove()
          Displays a page showing the list of not-yet-approved published pages.
protected  void showCensor()
          Displays a page showing the list of censored published pages.
protected  void showCreate()
          Displays the page used to create a web page.
protected  void showDefaultIndex()
          Shows the index of published pages that are not-yet-approved and approved.
protected  void showFinal()
          Displays the final published version of a page.
protected  boolean showIndex(int status)
          Displays a page showing a list of published pages.
protected  void showMain()
          Displays the main start page for this module.
protected  void showOwn()
          Shows the index of published pages owned by a user.
protected  void showPreview()
          Displays a preview of a published page.
 boolean shutdown(Log log)
          The required shutdown method, as defined in org.locomotive.loco.Handler.
 
Methods inherited from class org.locomotive.loco.handler.GenericHandler
displayPage, displayString, handleException, log, logEvent, sayBadURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

num_listings_per_index_page

public static final int num_listings_per_index_page
Constant used to determine how many page listings to show per index page.

PUB_ADMIN

public static final java.lang.String PUB_ADMIN
Permission that allows a user to allow or censor newly user-created web pages.
Constructor Detail

PublisherHandler

public PublisherHandler()
Method Detail

handleRequest

public void handleRequest(HandlerData hd_in)
main entry point called by RequestManager for each new request.
Overrides:
handleRequest in class GenericHandler

showMain

protected void showMain()
Displays the main start page for this module. If the user has the PUB_ADMIN permission, then they are given links to the approval and censored index pages.

showIndex

protected boolean showIndex(int status)
Displays a page showing a list of published pages. The number token represents which range of pages to display. No number token will simply default to the first page of indexes.
Parameters:
status - status of pages we want to see an index for
Returns:
true if no error occurs and the index is not empty

showOwn

protected void showOwn()
Shows the index of published pages owned by a user.

showDefaultIndex

protected void showDefaultIndex()
Shows the index of published pages that are not-yet-approved and approved. This is to be viewed by all.

showApprove

protected void showApprove()
Displays a page showing the list of not-yet-approved published pages. User must have the "PUB_ADMIN" permission to see this index. Token number decides which page of the index to display.

showCensor

protected void showCensor()
Displays a page showing the list of censored published pages. User must have the "PUB_ADMIN" permission to see this index. Token number decides which page of the index to display.

showCreate

protected void showCreate()
Displays the page used to create a web page.

showPreview

protected void showPreview()
Displays a preview of a published page. Essentially the same as showing the final version of the page, except with the addition of 'Modify' and 'Publish' buttons so that the user has the option to do more editing before actually publishing the page for public viewing.

showFinal

protected void showFinal()
Displays the final published version of a page. If the page is censored, only users with PUB_ADMIN permission can see the page. The token indicates the id of the page to display.

getPermissions

protected void getPermissions()
Prepares the PermissionSet object for permission checking.

init

public boolean init(Log log)
The required init method, as defined in org.locomotive.loco.Handler. Here we check to see if the Properties object for this Handler exists, and if it does, then we get the image_path variable out of it.
Overrides:
init in class GenericHandler

shutdown

public boolean shutdown(Log log)
The required shutdown method, as defined in org.locomotive.loco.Handler. In this example, we don't actually need to do anything.
Overrides:
shutdown in class GenericHandler
See Also:
org.locomotive.loco.Handler#shutdown