The Perl Advent Calendar needs more articles for 2022. Submit your idea today!

NAME

App::Phoebe::Capsules - provide every visitor with a writeable capsule

DESCRIPTION

By default, Phoebe creates a wiki editable by all. With this extension, the /capsule space turns into a special site: if you have a client certificate, you automatically get an editable capsule with an assigned fantasy name.

Simply add it to your config file. If you are virtual hosting, name the host or hosts for your capsules.

    package App::Phoebe::Capsules;
    use Modern::Perl;
    our @capsule_hosts = qw(transjovian.org);
    use App::Phoebe::Capsules;

Every client certificate gets assigned a capsule name.

You can provide a link with some documentation, if you want:

    our $capsule_help = '//transjovian.org/phoebe/page/Capsules';

NO MIME TYPES

When uploading to a capsule, the MIME type is ignored. Instead, it is determined from the filename extension.

TROUBLESHOOTING

🔥 In the wiki directory, you can have a file called fingerprint_equivalents. Its main use is to allow people to add more fingerprints for their site, such as from other devices or friends. The file format is line oriented, each line containing two fingerprints, FROM and TO.

🔥 The capsule name login is reserved.

🔥 The file names archive, backup, and upload are reserved.

NO WIKI, ONLY CAPSULES

Here's how to disable all wiki functions of Phoebe and just use capsules. The nothing_else function comes right after capsules as an extension and always returns 1, so Phoebe considers this request handled. Therefore, the regular request handlers won't get used. Make sure that any extensions you do want to have are prepended to @extensions after setting it (using unshift).

    # tested by t/example-capsules-only.t
    package App::Phoebe::Capsules;
    use Modern::Perl;
    use App::Phoebe qw($log @request_handlers @extensions);
    use App::Phoebe::Capsules;
    our $capsule_help = '//transjovian.org/phoebe/page/Capsules';
    our $capsule_space;
    @extensions = (\&capsules, \&nothing_else);
    sub nothing_else {
      my ($stream, $url) = @_;
      $log->info("No handler for $url: only capsules!");
      result($stream, "30", "/$capsule_space");
      1;
    }
    $log->info('Only capsules!');
    1;