App-Phoebe

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  your extensions are written!

- Phoebe no longer uses STDIN and STDOUT to serve requests but a
  Mojo::IOLoop::Stream object. Phoebe is no longer a class so the
  $self parameter of many calls either fell away or got replaced with
  a $stream object to which you $stream->write.

- Phoebe lost many options and capabilities for daemonisation. Using
  systemd is now the recommended way to run Phoebe (using a
  traditional setup is still possible, but there are no longer any
  options to set a PID file, to background the process, and so on).

- The huge config file of mine I mined for code examples got split
  into smaller files, and where you previously had one big config file
  you can now also have a conf.d/ directory with even more config
  files. All the files in the contrib/ directory of this distribution
  are lifted straight from my setup.

1.20

- Add conf.d directory next to the config file for easier code sharing

lib/App/Phoebe/Web.pm  view on Meta::CPAN

    # fully qualified because we're in a different package!
    *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 dark mode)");
      $stream->write(<<'EOT');
    @media (prefers-color-scheme: dark) {
       body { color: #eeeee8; background-color: #333333; }
       a:link { color: #1e90ff }
       a:hover { color: #63b8ff }
       a:visited { color: #7a67ee }
    }
    EOT
    }

    1;

=cut

lib/App/Phoebe/Web.pm  view on Meta::CPAN

  $stream->write("</ul>\n");
}

sub serve_css_via_http {
  my $stream = shift;
  $log->info("Serving CSS via HTTP");
  $stream->write("HTTP/1.1 200 OK\r\n");
  $stream->write("Content-Type: text/css\r\n");
  $stream->write("Cache-Control: public, max-age=86400, immutable\r\n"); # 24h
  $stream->write("\r\n");
  $stream->write("html { max-width: 70ch; padding: 2ch; margin: auto; color: #111; background: #ffe; }\n");
  $stream->write(".del { color: rgb(222,56,43); }\n"); # diff: deleted
  $stream->write(".ins { color: rgb(57,181,74); }\n"); # diff: inserted
}

sub serve_index_via_http {
  my $stream = shift;
  my $host = shift;
  my $space = shift;
  $log->info("Serving index of all pages via HTTP");
  $stream->write("HTTP/1.1 200 OK\r\n");

lib/App/Phoebe/Web.pm  view on Meta::CPAN

  my %rgb = (
    0 => "0,0,0",
    1 => "222,56,43",
    2 => "57,181,74",
    3 => "255,199,6",
    4 => "0,111,184",
    5 => "118,38,113",
    6 => "44,181,233",
    7 => "204,204,204");
  $code = join("", map {
    "<span style=\"color: rgb($rgb{$_}); background-color: rgb($rgb{$_})\">$_</span>";
	       } split //, $code);
  return $code;
}

sub serve_rss_via_http {
  my $stream = shift;
  my $host = shift;
  my $space = shift;
  $log->info("Serving RSS via HTTP");
  $stream->write("HTTP/1.1 200 OK\r\n");



( run in 0.878 second using v1.01-cache-2.11-cpan-d8267643d1d )