March distribution: Web::Library::UnderscoreJS
This neat module by Marcel GrĂ¼nauer is a wrapper for the Underscore JavaScript library, which itself provides over a 100 functional helpers and goodies for your frontend programming like function binding, JS templating, quick indexes, and much more.
The wrapper comes from Web::Library, a general manager for client-side dependencies. Say you have a web application. You spawn the Web::Library singleton and mount the libraries you want to use (Underscore in our case):
my $library_manager = Web::Library->instance;
$library_manager->mount_library({ name => 'UnderscoreJS' });
Then you set the include_paths() from the instance as directories to search for static files. In Catalyst, this can be achieved with Catalyst::Plugin::Static::Simple, like so:
__PACKAGE__->config(
'Plugin::Static::Simple' => {
include_path => [ $library_manager->include_paths ] },
...
);
Then pass the instance to your templates and call the appropriate methods to print the required CSS/JS lines:
<head>
...
[% web_library.css_link_tags_for('UnderscoreJS') %]
</head>
<body>
...
[% web_library.script_tags_for('UnderscoreJS') %]
</body>
My pull requests for this distribution involved bumping up the copyright year, some minor pod formatting issues, updating the UndescoreJS library versions (up to 1.8.2), and adding a Travis-CI code badge. I also investigated some CPAN Testers failure reports for this distribution on MS Windows, but they turned out to come from Web::Library itself. Nevertheless, I also send a PR with a fix and another one that reduced the minimum perl version to 5.6, which was asked in an open issue.
April distribution: Mojolicious::Plugin::ServerStatus
This is a plugin for Mojolicious that shows server status information, similar to Apache's mod_status. It is based on the general Plack::Middleware::ServerStatus::Lite middleware and works on multiprocess servers like morbo and hypnotoad. It's not able to monitor keepalive sessions and network I/O wait, but it still gives some nice output in different formats.
All you have to do is load the plugin and tell it which route path to render. Optionally, for security, you can set which IPs to allow:
plugin 'ServerStatus' => {
path => '/server-status',
allow => [ '127.0.0.1', '192.168.0.0/16' ],
};
That's it! After the server is up, all you have to do is query the proper path:
% curl http://server:port/server-status
Uptime: 1234567789
Total Accesses: 123
BusyWorkers: 2
IdleWorkers: 3
--
pid status remote_addr host method uri protocol ss
20060 A 127.0.0.1 localhost:10001 GET / HTTP/1.1 1
20061 .
20062 A 127.0.0.1 localhost:10001 GET /server-status HTTP/1.1 0
20063 .
20064 .
You can also ask for JSON output format:
% curl http://server:port/server-status?json
{"Uptime":"1332476669","BusyWorkers":"2",
"stats":[
{"protocol":null,"remote_addr":null,"pid":"78639",
"status":".","method":null,"uri":null,"host":null,"ss":null},
{"protocol":"HTTP/1.1","remote_addr":"127.0.0.1","pid":"78640",
"status":"A","method":"GET","uri":"/","host":"localhost:10226","ss":0},
...
],"IdleWorkers":"3"}
Unfortunately, this distribution didn't have any contents in the main github repository, so instead of making several branches off of master, I used my own master branch and made one commit per change in a single pull request. The first commit of course was just a sync between the repository and the version available on CPAN. Other commits included updating the README, setting up the proper dependencies (which should fix current failure reports from CPAN Testers), adding a Changes file which was missing from the dist, and some minor pod fixes.
That's it! Hopefully those commits and pull requests will be useful to the authors (and users too). And now I can't wait to see what Neil Bowers have picked for me next month :)