💾 Archived View for h2903872.stratoserver.net › cgi-bin › pod2gmi › GGI captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-02)
-=-=-=-=-=-=-
GGI.pm - Gemini Gateway Interface: Support perl-programs on Gemini servers.
GGI handles the accumulation of multiple parameters in the path-component of the URL through automatic redirects and offers a simple method to access those parameters from the perl program.
GGI supports the generation of all Gemini line types: responses, headers, text, quotes, links and pre-formatted, as well as some convenient methods to generate menus and to print tables with and without ASCII or UniCode frames.
More about the Gemini protocol: https://gemini.circumlunar.space/
GGI.pm Version from 2021-03-26
GGI by Frank Jüdes, http://www.linux4specialists.com
This pod text by Frank Jüdes, Perl by Larry Wall and the perl5-porters.
The GGI module is Copyright (c) 2021 Frank Jüdes, West Virginia, U.S.A. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl 5.10.0 README file.
The GGI is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.
#!/bin/perl use warnings; use strict; use utf8::all; use GGI; my $ggi = new GGI; # Create a new GGI object and print SUCCESS header $ggi->H1('ps test'); # Print a header my @output=`ps -fA`; # Run ps and catch all the output chomp @output; # Remove EOLs $ggi->Pre(@output); # Print the output as preformatted text
#!/bin/perl use warnings; use strict; use utf8::all; use GGI; my $ggi = GGI->new(1); # New GGI object without writing any header if (not defined $ggi->Param) { # No parameter present: Get the amount of parameters wanted $ggi->ResponseHeader('INPUT',qq(GGI-Test, ParamTest: How many parameters do you want to test?)); } # END if my $Current = $ggi->Param+1; # How many parameters are there my $Wanted = $ggi->Param(0); # How many parameters are wanted? if ($Current <= $Wanted) { # Get the next parameter $ggi->ResponseHeader('INPUT',qq(GGI-Test, Paramtest: Please enter a value for Parameter $Current of $Wanted)); } # END if # Done with parameters! - Main program $ggi->H1("Hello World!"); if (defined $ggi->Param) { $ggi->H2("The parameters"); $ggi->List(@{$ggi->Param('*')}); } else { $ggi->H1("No Parameters."); } # END if $ggi->Link(qq(gemini://h2903872.stratoserver.net/ Go back to the server's home.));
The following paragraphs explain the implemented methods of this package in great detail.
Create a new GGI object:
Returns the current request URL without the parameters
Returns the current request URL - Basically a shortcut for $ENV{GEMINI_URL}.
Returns the current request's servername - Basically a shortcut for $ENV{SERVER_NAME}.
Returns the current request's script-name - Basically a shortcut for $ENV{SCRIPT_NAME}.
Removes potentialy dangerous stuff from the parameters, currently for Linux
Access to the GGI-parameters:
Print an array of lines with CR/LF at the end
Print the response header with the meta-information, if present. The following response status-codes are defined, according to the Gemini protocol documentation:
- INPUT, SENSITIVE_INPUT - SUCCESS - REDIRECT_TEMPORARY, REDIRECT_PERMANENT - FAILURE_TEMPORARY, SERVER_UNAVAILABLE, CGI_ERROR, PROXY_ERROR, SLOW_DOWN - FAILURE_PERMANENT, NOT_FOUND, PROXY_REQUEST_REFUSED, BAD_REQUEST - CLIENT_CERTIFICATE_REQUIRED, CERTIFICATE_NOT_AUTHORIZED, CERTIFICATE_NOT_VALID
Print an Input response header with prompt. This is basically a shortcut for ResponseHeader('INPUT',[Prompttext]);
Print headerline 1-3
Print an array of lines as a preformatted block
Print an array of lines as a labeled preformatted block
Print an array of lines as an unsorted list.
Print an array of lines as links
Print an array of lines as quotes
Print the value of Title as an H1-title if defined. Then print the content of the Description below if defined, followed by the link-menu itself.
Menu is a simple perl-hash with the prompts as keys and the values as content. These values will be appended to the BaseURL as link-targets and the keys will become the link description-texts.
Print the content of a two-dimensional table into a pre-formatted block. The Table parameter is a reference to a two-dimensional array.
It is vital that all cells of the table are defined and that there are no holes in the table structure!
This code will center the column headers and pad all other table-cells to equal length in their column with the content left aligned. If you want other formatting, you need to pre-format the content of your table.
Valid values for the FrameType are ASCII, SINGLE, DOUBLE, SHADOW, FLOAT and NONE. Invalid values will default to NONE and no frames will be printed.
The Header and Summary parameters define weather the first line of the table contains column-headers and the last line contains a summary and should be separated from the rest of the table with a horizontal line.
With the Compact parameter the output of horizontal lines between the table data-rows can be supressed. (Compact design).
Print the content of a simple perl-hash or a perl-hash of arrays into a pre-formatted block. The Hash parameter is a reference to a simple pearl-hash or a pearl-has of one-dimensional arrays. The hash-keys will be printed, filled to equal length with the value of the Filler character, followed by the value of the Colon parameter, followed by either the hash-value or a list of values should the content of the hash be an array. If the Quote parameter is given, values will be encapulated in this quout character.
Unicode contains the code-block `Mathematical Alphanumeric Symbols' [U+1D400..U+1D7FF], containing styled letters and digits that look like normal characters from the latin alphabet, just styled in bold, italic, script, outline or gothic.
However those characters will not be recognized as ordinary text by most computer programs, like search engine crawlers for example.
Note that the digits are only available in bold-style.
Warning: This might not be supported by all Gemini clients! Especially terminal-clients might not have the necessary Unicode characterset installed, it will definitely screw up the terminal window of the amphora client on windows.
Transform the passed string into pseudo-bold Unicode characters.
Transform the passed string into pseudo-italic Unicode characters.
Transform the passed string into pseudo-bold-italic Unicode characters.
Transform the passed string into pseudo-script Unicode characters.
Transform the passed string into pseudo-bold-script Unicode characters.
Transform the passed string into pseudo-outline Unicode characters.
Transform the passed string into pseudo-gothic Unicode characters.
Transform the passed string into pseudo-bold-gothic Unicode characters.
🕸 http://www.linux4specialists.com