source of gemini capsule gemini://when.willgemini.support/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.5 KiB

#!/usr/bin/perl
# Copyright René Wagner 2020
# licenced under BSD 3-Clause licence
# https://src.clttr.info/rwa/willgemini.support
use strict;
no warnings 'experimental';
use URI::Escape;
use v5.10;
# enable UTF-8 mode for everything
use utf8;
binmode STDOUT, ':utf8';
binmode STDERR, ':utf8';
# define return codes
our %RC = (
'INPUT', 10,
'SENSITIVE_INPUT', 11,
'SUCCESS', 20,
'TEMPORARY_REDIRECT', 30,
'PERMANENT_REDIRECT', 31,
'TEMPORARY_FAILURE', 40,
'SERVER_UNAVAILABLE', 41,
'CGI_ERROR', 42,
'PROXY_ERROR', 43,
'SLOW_DOWN', 44,
'PERMANENT_FAILURE', 50,
'NOT_FOUND', 51,
'GONE', 52,
'PROXY_REQUEST_REFUSE', 53,
'BAD_REQUEST', 59,
'CLIENT_CERT_REQUIRED', 60,
'CERT_NOT_AUTHORISED', 61,
'CERT_NOT_VALID', 62
);
if (!defined($ENV{'SERVER_PROTOCOL'}) || $ENV{'SERVER_PROTOCOL'} ne 'GEMINI') {
write_response('CGI_ERROR', '', undef);
}
if ($ENV{'PATH_INFO'} ne '') {
write_response('NOT_FOUND', 'File not found', undef);
}
my $query = lc(uri_unescape($ENV{'QUERY_STRING'}));
if ($query eq '') {
write_response('INPUT', 'Which feature do you most urgently need in gemini?', undef);
}
write_response('SUCCESS', 'text/gemini', create_response($query));
exit;
sub create_response
{
my ( $qs ) = @_;
my @body = ();
push @body, '# When will gemini support ' . $qs .'?';
push @body, '';
given ($qs) {
when (/faq.*/) {
push @body, '=> https://src.clttr.info/rwa/gmnifaq Soon.';
}
when (/metadata.*/) {
push @body, ('SEO-again? Maybe a good idea to get all the big ad corps into gemini and make it widespread.', '', '=> https://people.well.com/user/doctorow/metacrap.htm Here are some arguments why metadata probably won\'t work well in large scale.');
}
when (/favicon.*/) {
push @body, '🤦';
}
when (/web.*/) {
push @body, 'We want to escape the web, not support it!';
}
when (/escaping/) {
push @body, ('Never.', '', '', '', 'Seriously.');
}
when (/.*length.*/) {
push @body, ('Why should we?', '', '', 'So: Never.');
}
when (/head.*/) {
push @body, 'It already does, just look at the question you asked me!';
}
when (/itali.*/) {
push @body, 'Although considered essential for "serious writing" by some, gemini will most likely never support special markup for italics.';
}
when (/feed.*/) {
push @body, '=> gemini://gemini.circumlunar.space/docs/companion/subscription.gmi Do it the easy way.';
}
when (/table.*/) {
push @body, 'Seriously?';
}
default {
push @body, ('I don\'t exactly understand what you mean. Anyway the answer is:', 'Most probably never.');
}
}
push @body, ('', '', '', '=> . check another "feature"', '');
push @body, ('This capsule is a sarcastic response to the various "proposals" of new features that pop up on the mailing list again and again. It has absolutely no authority about the gemini protocol and just reflects the very personal opinion of its author.', '', 'gemini is fine the way it is now, just stop trying to push every idea you have in your head into it and create content.', '=> gemini://gemini.circumlunar.space/docs/specification.gmi See the spec for more details what is already there to be creative.');
push @body, ('', '=> https://src.clttr.info/rwa/willgemini.support Open an issue or a PR for additional stuff.');
return @body;
}
sub write_response
{
my ($returncode, $meta, @content) = @_;
if (!defined($RC{$returncode})) { die "Unknown response code!"; }
printf("%d %s\r\n", $RC{$returncode}, ($meta eq '') ? $returncode : $meta);
foreach (@content) {
print("$_\r\n");
}
exit;
}