Tuesday, 21 August 2007
Feature: Status “badges” for Web pages
Completed implementation of ``Web badges'', which allow users to display
their most recent weight log entry and the energy balance and rate of
gain/loss for a specified trend interval. A new badge configuration page,
accessible from the main utility menu, allows enabling the badge and
selecting the trend interval, which is kept in a new \verb+badge_trend+
field in the {\tt user} object. When this field is nonzero, any operation
which modifies a log entry calls {\tt history::drawBadgeImage} to update
the {\tt BadgeImage.png} file in the user's directory. (This file is
swapped into place with a {\tt mv} command to avoid race conditions if
it is being retrieved at the time an update is in progress.)
The badge configuration page takes the user to a confirmation
page which, if badge generation is enabled, shows XHTML code the
user can copy and paste into a Web page to display the badge. This
code invokes a new stand-alone lightweight CGI program named
{\tt HackDietBadge}, which is called with an opaque argument which
is the user file name of the owner of the badge salted and encrypted
with the application's master key using AES in CBC mode. The
{\tt HackDietBadge} program is separate so as to avoid having to
load the full application and all of the modules it requires just
to display a badge image on a Web page which may be hit far more
frequently than full-fledged application transactions. The
{\tt HackDietBadge} program decrypts and validates the
argument and, if all is well, copies the badge image for
the specified user to standard output hacing specified a
{\tt Content-type} of {\tt image/png}. If the argument is
in error, or the specified user has disabled badge generation,
a canned ``Invalid request'' image is returned instead.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment