1Web::Paste::Simple(3) User Contributed Perl DocumentationWeb::Paste::Simple(3)
2
3
4

NAME

6       Web::Paste::Simple - simple PSGI-based pastebin-like website
7

SYNOPSIS

9               #!/usr/bin/plackup
10               use Web::Paste::Simple;
11               Web::Paste::Simple->new(
12                       storage    => Path::Class::Dir->new(...),
13                       codemirror => "...",
14                       template   => Text::Template->new(...),
15               )->app;
16

DESCRIPTION

18       Web::Paste::Simple is a lightweight PSGI app for operating a pastebin-
19       like website. It provides syntax highlighting via the CodeMirror
20       <http://codemirror.net/> Javascript library. It should be fast enough
21       for deployment via CGI.
22
23       It does not provide any authentication facilities or similar, instead
24       relying on you to use subclassing/roles or Plack middleware to
25       accomplish such things.
26
27   Constructor
28       "new(%attrs)"
29           Standard Moose-style constructor.
30
31           This class is not based on Moose though; instead it uses Moo.
32
33   Attributes
34       The following attributes are defined:
35
36       "storage"
37           A Path::Class::Dir indicating the directory where pastes should be
38           stored. Pastes are kept indefinitely. Each is a single file.
39
40       "codemirror"
41           Path to the CodeMirror syntax highlighter as a string. For example,
42           if CodeMirror is available at
43           "http://example.com/js/lib/codemirror.js" then this string should
44           be "http://example.com/js" with no trailing slash.
45
46           This defaults to an address on my server, but for production sites,
47           please set up your own copy: it only takes a couple of minutes;
48           just a matter of unzipping a single archive. I offer no guarantees
49           about the continued availability of my copy of CodeMirror.
50
51           Nothing is actually done with this variable, but it's passed to the
52           template.
53
54       "template"
55           A Text::Template template which will be used for all HTML output.
56           The following variables are available to the template...
57
58           •   $DATA - the text pasted on the curent page (if any), already
59               HTML escaped
60
61           •   $MODE - the currently selected syntax highlighting mode (if
62               any), already HTML escaped
63
64           •   @MODES - all configured highlighting modes
65
66           •   $CODEMIRROR - the path to codemirror
67
68           •   $APP - the blessed Web::Paste::Simple object
69
70           •   $REQUEST - a blessed Plack::Request for the current request
71
72           •   $PACKAGE - the string "Web::Paste::Simple"
73
74           •   $VERSION - the Web::Paste::Simple version number
75
76           The default template is minimal, but works.
77
78       "modes"
79           The list of CodeMirror highlighting modes to offer to the user.
80
81           Nothing is actually done with this variable, but it's passed to the
82           template.
83
84       "default_mode"
85           The default highlighting mode.
86
87       "uuid_gen"
88           A Data::UUID object used to generate URIs. The default should be
89           fine.
90
91   Methods
92       The following methods may be of interest to people subclassing
93       Web::Paste::Simple.
94
95       "app"
96           Technically this is another attribute, but one that should not be
97           set in the constructor. Call this method to retrieve the PSGI
98           coderef.
99
100           This coderef is built by "_build_app" (a Moo lazy builder).
101
102       "dispatch"
103           Basic request router/dispatcher. Given a Plack::Request, returns a
104           Plack::Response.
105
106       "create_paste"
107           Given a Plack::Request corresponding to an HTTP "POST" request,
108           saves the paste and returns a Plack::Reponse. The response may be
109           an arror message, success message, or (as per the current
110           implementation) a redirect to the paste's URI.
111
112       "retrieve_paste"
113           Given a Plack::Request and a paste ID, returns a Plack::Response
114           with a representation of the paste, or an error message.
115
116       "show_error"
117           Given an error string and optionally an HTTP status code, returns a
118           Plack::Response.
119
120       "show_template"
121           Given a Plack::Request and a hashref of data (possibly including
122           "paste" and "mode" keys) returns a Plack::Response with the
123           rendered template, and the pasted data plugged into it.
124
125       "make_paste_id"
126           Returns a unique ID string for a paste. The current implementation
127           is a base64-encoded UUID.
128

BUGS

130       Please report any bugs to
131       <http://rt.cpan.org/Dist/Display.html?Queue=Web-Paste-Simple>.
132

SEE ALSO

134       Plack, Moo, CodeMirror <http://codemirror.net/>.
135

AUTHOR

137       Toby Inkster <tobyink@cpan.org>.
138
140       This software is copyright (c) 2012 by Toby Inkster.
141
142       This is free software; you can redistribute it and/or modify it under
143       the same terms as the Perl 5 programming language system itself.
144

DISCLAIMER OF WARRANTIES

146       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
147       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
148       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
149
150
151
152perl v5.32.1                      2021-01-27             Web::Paste::Simple(3)
Impressum