BusyBird::Main::PSGI::View - view renderer for BusyBird::Main
This is a view renderer object for BusyBird::Main.
This module is rather for internal use. End-users should not use this module directly. Specification in this document may be changed in the future.
The constructor.
Fields in %args are:
%args
main_obj
Returns a simple "404 Not Found" page.
$message is the message body, which is optional.
$message
Return value $psgi_response is a PSGI response object.
$psgi_response
Returns an HTTP error response in HTML.
$http_code is HTTP response code, which should be 4** or 5**. $message is a human-readable error message.
$http_code
Returns a response object whose content is a JSON-fomatted object.
$http_code is the HTTP response code such as "200", "404" and "500". $response_object is a reference to an object.
$response_object
Return value $psgi_response is a PSGI response object. Its content is $response_object formatted in JSON.
$response_object must be encodable by JSON. Otherwise, it returns a PSGI response with HTTP code of 500 (Internal Server Error).
If $http_code is 200, $response_object is a hash-ref and $response_object->{error} does not exist, $response_object->{error} is automatically set to undef, indicating the response is successful.
$response_object->{error}
undef
Returns a PSGI response object for given status objects.
statuses
Array-ref of statuses to be rendered. You must set either statuses field or error field. If not, it croaks.
error
Error string to be rendered. This field must be set when you don't have statuses due to some error.
http_code
HTTP response code.
format
A string specifying rendering format. Possible formats are: "html", "json". If unknown format is given, it returns "400 Bad Request" error response.
"html"
"json"
timeline_name
A string of timeline name for the statuses.
Returns a PSGI response object of the top view for a timeline.
$timeline_name is a string of timeline name to be rendered. If the timeline does not exist in $view's BusyBird::Main object, it returns "404 Not Found" response.
$timeline_name
$view
$script_name is the base path for internal hyperlinks. It should be SCRIPT_NAME of the PSGI environment.
$script_name
SCRIPT_NAME
Returns a PSGI response object of the view of timeline list.
script_name
The base path for internal hyperlinks known as SCRIPT_NAME.
timeline_unacked_counts
The data structure keeping the initial unacked counts for timelines. Its structure is like
[ {name => "first timeline name", counts => {total => 0}}, {name => "second timeline name", counts => { total => 10, 0 => 5, 1 => 3 2 => 2 }} ]
total_page_num
Total number of pages for listing all timelines.
cur_page
The current page number of the timeline list. The page number starts with 0.
Returns a hash-ref of subroutine references for template rendering. They are supposed to be called from Text::Xslate templates.
$functions contain the following keys. All of their values are subroutine references.
$functions
js
Escapes JavaScript value.
link
Linkifies $text with <a> tag with %attr attributes. $text will be HTML-escaped. If $attr{href} does not look like a valid link URL, it returns the escaped $text only.
$text
<a>
%attr
$attr{href}
image
Returns <img> tag with %attr attributes. If $attr{src} does not look like a valid image URL, it returns an empty string.
<img>
$attr{src}
bb_level
Formats status level. $level may be undef, in which case the level is assumed to be 0.
$level
$timeline_name is the name of a timeline. $functions is the set of functions that are dependent on the timeline's configuration.
bb_timestamp
Returns a timestamp string formatted with the timeline's configuration. $timestamp_str is the timestamp in status objects such as $status->{created_at}.
$timestamp_str
$status->{created_at}
bb_status_permalink
Returns the permalink URL for the status.
bb_text
Returns the HTML text for the status.
Toshio Ito <toshioito [at] cpan.org>
<toshioito [at] cpan.org>
To install BusyBird, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BusyBird
CPAN shell
perl -MCPAN -e shell install BusyBird
For more information on module installation, please visit the detailed CPAN module installation guide.