Web::Paste::Simple(3)

πŸ“¦
version 0.002 Β· 2 versions
, in fedora 43

🌸 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 β€” a Path::Class::Dir pointing 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 at http://example.com/js/lib/codemirror.js, then this string should be http://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 β€” a Text::Template template 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 blessed Web::Paste::Simple object
    • $REQUEST β€” a blessed Plack::Request for the current request
    • $PACKAGE β€” the string "Web::Paste::Simple"
    • $VERSION β€” the Web::Paste::Simple version 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 β€” a Data::UUID object 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 a Plack::Request, it returns a Plack::Response.
  • create_paste β€” given a Plack::Request corresponding to an HTTP POST request, it saves the paste and returns a Plack::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 a Plack::Request and a paste ID, returns a Plack::Response with a representation of the paste, or an error message.
  • show_error β€” given an error string and optionally an HTTP status code, returns a Plack::Response.
  • show_template β€” given a Plack::Request and a hashref of data (possibly including paste and mode keys), returns a Plack::Response with 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>.


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