App-Phoebe

 view release on metacpan or  search on metacpan

t/Oddmuse.t  view on Meta::CPAN

like(query_gemini("$base/do/blog"), qr(2021-06-28)m, "Blog including 2021-06-28");

# Leaving a comment

like(query_gemini("$base/page/2021-06-28"),
     qr(=> $base/do/comment/2021-06-28 Leave a short comment)m,
     "2021-06-28 has link to comments");
like(query_gemini("$base/do/comment/2021-06-28", undef, 0), # no cert!
     qr(^60)m, "Client certificate required in order to comment");
like(query_gemini("$base/do/comment/2021-06-28"),
     qr(^10)m, "Token required");
like(query_gemini("$base/do/comment/2021-06-28?lalala"),
     qr(^59)m, "Wrong token");
like(query_gemini("$base/do/comment/2021-06-28?hello"),
     qr(^10)m, "Input required");
$haiku = <<EOT;
The+city cries but
Our metal worms dig deeper
Every day, alas.
EOT
like(query_gemini("$base/do/comment/2021-06-28?" . uri_escape($haiku)),
     qr(^30 $base/page/Comments_on_2021-06-28)m, "Redirect");
like(query_gemini("$base/page/Comments_on_2021-06-28"),
     qr(The city cries), "Comment saved, plusses handled");

# Unit testing of text formatting rules

ok(require App::Phoebe, "load phoebe");
ok(require App::Phoebe::Oddmuse, "load oddmuse.pl");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", "Testing [Foo:Bar baz]");
like($page, qr(^Testing baz$)m, "Namespace link with text, text");
like($page, qr(^=> gemini://localhost:1965/Foo/page/Bar baz$)m, "Namespace link with text, link");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", "e.g. &#x2605; is ★");
like($page, qr(^e.g. ★ is ★$)m, "HTML entities that look like hash tags");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", "it has [Tau_Subsector:?action=index 39 pages]");
like($page, qr(^it has 39 pages$)m, "index link inline text");
like($page, qr(^=> gemini://localhost:1965/Tau_Subsector/do/index 39 pages$)m, "index link");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
This is a table.

|hello|
|kitten|

And this is the end.});
like($page, qr(^This is a table\.\n\n```\n\|hello\|\n\|kitten\|\n```\n\nAnd this is the end\.$)m, "table");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
This is a list.

* first
- second

And this is the end.});
like($page, qr(^This is a list\.\n\n\* first\n\* second\n\nAnd this is the end\.$)m, "list");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image:https://alexschroeder.ch/podcast/logo-small.png]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png https://alexschroeder.ch/podcast/logo-small.png \(image\)\n)m, "image 1a");
like($page, qr(^x$)m, "image x");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image:https://alexschroeder.ch/podcast/logo-small.png|Halberds and Helmets]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png Halberds and Helmets \(image\)\n)m, "image 2a");
like($page, qr(^x$)m, "image x");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image:https://alexschroeder.ch/podcast/logo-small.png|Halberds and Helmets|Halberds and Helmets Podcast]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png Halberds and Helmets \(image\)\n)m, "image 3a1");
like($page, qr(^=> gemini://localhost:1965/page/Halberds_and_Helmets_Podcast Halberds and Helmets \(follow-up\)\n)m, "image 3a2");
like($page, qr(^x$)m, "image x");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image/right:https://alexschroeder.ch/podcast/logo-small.png]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png https://alexschroeder.ch/podcast/logo-small.png \(image\)\n)m, "image 1b");
like($page, qr(^x$)m, "image x");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image/right:https://alexschroeder.ch/podcast/logo-small.png|Halberds and Helmets]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png Halberds and Helmets \(image\)\n)m, "image 2b");
like($page, qr(^x$)m, "image x");

$page = App::Phoebe::Oddmuse::oddmuse_gemini_text(undef, $host, "", qq{
[[image/right:https://alexschroeder.ch/podcast/logo-small.png|Halberds and Helmets|Halberds and Helmets Podcast]]
x});
like($page, qr(^=> https://alexschroeder.ch/podcast/logo-small.png Halberds and Helmets \(image\)\n)m, "image 3b1");
like($page, qr(^=> gemini://localhost:1965/page/Halberds_and_Helmets_Podcast Halberds and Helmets \(follow-up\)\n)m, "image 3b");
like($page, qr(^x$)m, "image x");

done_testing();



( run in 1.134 second using v1.01-cache-2.11-cpan-302cb4679cc )