App-Phoebe
view release on metacpan or search on metacpan
contrib/README.md view on Meta::CPAN
=> https://alexschroeder.ch/cgit/oddmuse/about/
Example:
=> gemini://alexschroeder.ch/
## toki-pona.pl
This extension allows you to write blocks using toki pona and on the
web, the linja pona font is used to render them. In order for this to
work, you must have the linja-pona-4.2.woff file in your wiki data
directory.
=> https://github.com/janSame/linja-pona/#linja-pona
Example:
=> //toki.transjovian.org/
## web-edit.pl
lib/App/Phoebe/TokiPona.pm view on Meta::CPAN
use App::Phoebe::TokiPona;
=cut
package App::Phoebe::TokiPona;
use App::Phoebe::Web;
use App::Phoebe qw(@extensions $server $log);
use File::Slurper qw(read_binary);
use Modern::Perl;
push(@extensions, \&toki_pona_font);
sub toki_pona_font {
my $stream = shift;
my $request = shift;
if ($request =~ m!^GET /linja-pona-4.2.woff HTTP/1\.[01]$!) {
serve_font_via_http($stream);
return 1;
}
return 0;
}
sub serve_font_via_http {
my $stream = shift;
$log->info("Serving font via HTTP");
$stream->write("HTTP/1.1 200 OK\r\n");
$stream->write("Content-Type: font/woff\r\n");
$stream->write("Cache-Control: public, max-age=86400, immutable\r\n"); # 24h
$stream->write("\r\n");
my $dir = $server->{wiki_dir};
$stream->write(read_binary("$dir/linja-pona-4.2.woff"));
}
# CSS
no warnings qw(redefine);
*old_serve_css_via_http = \&App::Phoebe::Web::serve_css_via_http;
*App::Phoebe::Web::serve_css_via_http = \&serve_css_via_http;
sub serve_css_via_http {
my $stream = shift;
old_serve_css_via_http($stream);
$log->info("Adding more CSS via HTTP (for toki pona)");
$stream->write(<<'EOT');
@font-face {
font-family: linja-pona;
src: url('/linja-pona-4.2.woff') format('woff');
font-weight: normal;
font-style: normal;
}
pre.toki {
font-family: linja-pona;
font-feature-settings: "liga" 1, "clig" 1, "calt" 1, "kern" 1, "mark" 1;
text-rendering: optimizeLegibility;
font-size: 150%;
}
EOT
}
t/TokiPona.t view on Meta::CPAN
plan skip_all => 'This is an author test. Set $ENV{TEST_AUTHOR} to a true value to run.' unless $ENV{TEST_AUTHOR};
require './t/test.pl';
# variables set by test.pl
our $dir;
our $host;
our $port;
# write fake font file
write_text("$dir/linja-pona-4.2.woff", "TEST");
like(query_web("GET / HTTP/1.0\r\nhost: $host:$port"),
qr/^HTTP\/1.1 200 OK/, "Web is served");
like(query_web("GET /linja-pona-4.2.woff HTTP/1.0\r\nhost: $host:$port"),
qr/^TEST/m, "Font is served");
like(query_web("GET /default.css HTTP/1.0\r\nhost: $host:$port"),
qr/^pre.toki/m, "CSS is modified");
( run in 1.998 second using v1.01-cache-2.11-cpan-ceb78f64989 )