AmphetaDesk::Utilities - A potpourri of minor utilities for AmphetaDesk
# generic stuff. $modified = encode_to_dec($data); # encodes to decimal equivalents. $modified = strip_newlines_and_tabs($data); # what do you think? $modified = add_link_targets($data, $target); # add <a target="">'s. $modified = remove_utf_bom($data); # stops older expats from crashing. # logging routines. set_logfile($filepath); note("this is a note to our log"); note("this is a note to our log and OS GUI", 1); note("this is a note to our log, our OS GUI, and the browser", 1, 1); error("this is a note everywhere, that then dies"); # webpage communication set_response("add a message to the web page note buffer"); my @responses = get_response; # gets/deletes all messages in buffer.
This package contains all the minor utilities needed through out AmphetaDesk, like logging, newline and tab removal, decimal encoding, HTML removal, and so on. It's really a dumping ground of routines that didn't fit anywhere else.
add_link_targets($data, $target)
$data
, looking for HTML links and then adding targets to them, to focus the link into a new (or existing) window. The target name to add is defined by $target
. AmphetaDesk calls this routine automatically for every item in the user's subscribed feeds. It returns the modified $data
.encode_to_dec($data)
URI::Escape
(we used to homebrew this, but felt more comfortable blaming another module instead of our own code).get_response
and set_response($msg)
get_response
returns an array of the current batch of responses, created by the set_response
routine. Responses are like log file lines, but are used only for displaying diagnostic messages in the browser window (either in normal template pages, or in a javascript popup window). get_response
will remove the saved response(s) once retrieved. One possible way of handling responses is with my $response = join("<br>", get_response())
.note
and error
note
to write a note to the GUI window, AmphetaDesk.log, or the web page (see get_reponse
) - it'll always return with a 1. What happens to the GUI window is controlled by one of the various OS libraries, located under AmphetaDesk::OS. If you use error
, we note
and then die
. Example usage demonstrating the possible output locations:note("this is a note to our log"); note("this is a note to our log and OS GUI", 1); note("this is a note to our log, our OS GUI, and the browser", 1, 1); error("this is a note everywhere, that then dies");
set_logfile
has been configured.remove_utf8_bom
set_logfile($logfile)
$logfile
. All note
and error
routines will use this LOG filehandle when logging, and STDERR will be redirected there. If the current $logfile
exists, it will be deleted after 250k so we don't go squirrels with evil. This routine returns 1 if the log was opened successfully, and dies if it wasn't.strip_newlines_and_tabs($data)
Morbus Iff, <morbus@disobey.com>
Copyright 2000-2004 Morbus Iff <morbus@disobey.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.