Web::Paste::Simple(3)
πΈ Web::Paste::Simple πΈ
okay so bestie, buckle up, because this is the manual page for Web::Paste::Simple β yes, that's Web::Paste::Simple(3) from the User Contributed Perl Documentation, and yes I am going to make it slay. it's a pastebin. it's PSGI. it's cute. let's go π
β¨ NAME β¨
Web::Paste::Simple β a simple PSGI-based pastebin-like website π«Ά
π SYNOPSIS π
#!/usr/bin/plackup
use Web::Paste::Simple;
Web::Paste::Simple->new(
storage => Path::Class::Dir->new(...),
codemirror => "...",
template => Text::Template->new(...),
)->app;
look at that. three attributes and an ->app and you're literally running a whole website. iconic behaviour fr fr π
π¦ DESCRIPTION π¦
Web::Paste::Simple is a lightweight PSGI app for running a pastebin-like website. it hands you syntax highlighting through the CodeMirror Javascript library β link for the receipts: <http://codemirror.net/> β¨ and ngl it should be fast enough to deploy via CGI. yes, CGI. we contain multitudes.
here's the thing though, and I need you to hear me on this one: it does not provide any authentication facilities or anything like that. none. zero. instead it's relying on you to use subclassing/roles or Plack middleware to do all of that. it's giving "build your own bouncer" energy π
π Constructor π
new(%attrs)β the standard Moose-style constructor.
ok but plot twist: this class is not based on Moose. it uses Moo instead. moo. like the sound. adorable. π
π Attributes π
here's everything that's defined, bestie, no skipping:
storageβ aPath::Class::Dirpointing at the directory where pastes get stored. pastes are kept indefinitely. each one is a single file. they simply do not leave. πcodemirrorβ path to the CodeMirror syntax highlighter, as a string. for example, if CodeMirror lives athttp://example.com/js/lib/codemirror.js, then this string should behttp://example.com/jsβ with no trailing slash. periodt.
it defaults to an address on my server, but for production sites, please please please set up your own copy: it literally only takes a couple of minutes, it's just a matter of unzipping a single archive. and I offer no guarantees about the continued availability of my copy of CodeMirror. none. don't @ me. π
also, nothing is actually done with this variable β it just gets passed to the template. it's a vibe carrier. π¦
templateβ aText::Templatetemplate used for all HTML output. the following variables are available to the templateβ¦$DATAβ the text pasted on the curent page (if any), already HTML escaped$MODEβ the currently selected syntax highlighting mode (if any), already HTML escaped@MODESβ all configured highlighting modes$CODEMIRRORβ the path to codemirror$APPβ the blessedWeb::Paste::Simpleobject$REQUESTβ a blessedPlack::Requestfor the current request$PACKAGEβ the string"Web::Paste::Simple"$VERSIONβ theWeb::Paste::Simpleversion number
the default template is minimal, but it works. minimalism is a lifestyle. π
modesβ the list of CodeMirror highlighting modes to offer to the user.
nothing is actually done with this variable either, but it's passed to the template. (see a pattern? it's the "pass it to the template and let the template have its moment" pattern β¨)
default_modeβ the default highlighting mode.uuid_genβ aData::UUIDobject used to generate URIs. the default should be fine. trust. π
β Methods β
these ones may be of interest to people subclassing Web::Paste::Simple:
appβ technically this is another attribute, but one that should not be set in the constructor. call this method to retrieve the PSGI coderef.
this coderef is built by _build_app (a Moo lazy builder). lazy in the good way. π
dispatchβ basic request router/dispatcher. given aPlack::Request, it returns aPlack::Response.create_pasteβ given aPlack::Requestcorresponding to an HTTPPOSTrequest, it saves the paste and returns aPlack::Reponse. the response may be an arror message, a success message, or β as per the current implementation β a redirect to the paste's URI. very "choose your own adventure" of it. πretrieve_pasteβ given aPlack::Requestand a paste ID, returns aPlack::Responsewith a representation of the paste, or an error message.show_errorβ given an error string and optionally an HTTP status code, returns aPlack::Response.show_templateβ given aPlack::Requestand a hashref of data (possibly includingpasteandmodekeys), returns aPlack::Responsewith the rendered template, and the pasted data plugged into it. π§make_paste_idβ returns a unique ID string for a paste. the current implementation is a base64-encoded UUID. cute and unique, just like you. π
π BUGS π
please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Web-Paste-Simple>. bestie. do it. the maintainer will be so grateful. π«Ά
π₯ SEE ALSO π₯
Plack, Moo, CodeMirror <http://codemirror.net/>.
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
π COPYRIGHT AND LICENCE π
this software is copyright (c) 2012 by Toby Inkster.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in go wild. β¨
π¨ DISCLAIMER OF WARRANTIES π¨
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
(they put it in all caps for a reason, bestie β no warranty, no promises, that's the deal π )
okay that's the whole thing!! and just so you have the receipts, this page is from perl v5.42.0, dated 2025-07-25, and it's page Web::Paste::Simple(3) in the docs. go build your pastebin, main character π¦πβ¨
π¦ where this page comes from
- fedora 43: perl-Web-Paste-Simple 0.002-33.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND ((GPL-1.0-or-later OR Artistic-1.0-Perl) OR CC-BY-SA-2.0-UK)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms