Yet another pastebin project, but implemented on top of Mojolicious::Lite. The codebase is actually very simple but shows the best Mojolicious features.

File-based model

All pastes are saved on the hard disk, thus no database is required. Each paste has unique SHA-1 hex name. Pastes can be private and thus only you know the url and only you can delete them. This way no password protection is required.

JSON configuration

Mojo::JSON parser makes app configuration trivial to implement. In Pastelicious loading plugins and including Perl libraries paths (soon languages and syntax highlighting) is done via configuration file.

    "perl5lib" : "/home/vti/local/lib/perl5",
    "plugins_namespaces" : ["Bootylicious::Plugin"],
    "plugins" : [ 
        "google_analytics", {"urchin" : "UA-1234567-8"}

Static dispatcher

MojoX::Dispatcher::Static can be used not only while developing but also when you want to serve a static file from your application. This way in Pastelicious I serve the source code.

$self->render_static('../' . basename($0));


Routes is a readable and customizable way to match application urls to controllers. Stash is automatically populated by captures and everything else is just trivial.

get '/source' => sub {
    my $self = shift;

    $self->stash(rendered => 1); 
    $self->app->static->serve($self, '../' . basename($0));
} => 'source';


Having format support in MojoX::Renderer it is easy to have different formats in which you give a user the data. Based on url it is possible to render an appropriate template.
# Render view.html.ep
# Render view.raw.ep


Perlish Mojo::Template templates are powerful and don't require learning anything new. In Pastelicious I've used new ep templates that have stash variables auto initializition, helpers etc.

% if (my $author = $metadata->{author}) {
<td class="label">Author:</td><td><%= $author %></td>
% }  

Renderer helpers

MojoX::Renderer helpers introduce Perl callback subroutines that can be used in templates. In Pastelicious I use them to get last pastes and available languages.

% foreach my $id (get_last_pastes) {
  <a href="<%= url_for view => id => $id %>"><%= $id %></a><br />
% }


Mojolicious::Plugins hook model being very customizable gives you ability to use third party modules without changing application code. For example, at I use Bootylicous::Plugin::GoogleAnalytics for collecting statistics.


Deployment of Mojo application is not hard, since Mojo has no dependencies and supports CGI, FastCGI, mod_perl, embedded daemon and daemon_prefork servers.

Source code and Demonstration

You can find Pastelicious source code at and see it in action at

Welcome   |


blog comments powered by Disqus