From 0d39eb69f731bca1c18d6ed5fde3ce0e380971dd Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 5 Mar 2024 00:03:20 +0200 Subject: [PATCH] support gemtext by default --- src/server.php | 75 ++------------------------------------------------ 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/src/server.php b/src/server.php index cba7f8d..b6005e5 100644 --- a/src/server.php +++ b/src/server.php @@ -496,48 +496,6 @@ $server->setHandler( break; - case 'gemtext': - - // Key - $result[] = null; - $result[] = sprintf( - '# %s', - trim( - preg_replace( // single-line - '/[\s]+/', - ' ', - $record['key'] - ) - ) - ); - - // Value - $result[] = null; - $result[] = trim( - preg_replace( - [ - '/[\n\r]{3,}/', // remove extra breaks - ], - [ - PHP_EOL . PHP_EOL, - ], - $record['value'] - ) - ); - - // Time - $result[] = null; - $result[] = sprintf( - '%s in %d', - date( - 'Y-m-d', - $record['time'] - ), - $record['block'] - ); - - break; - default: // Key @@ -558,8 +516,8 @@ $server->setHandler( $result[] = trim( preg_replace( [ - '/(^|\s+)(#|\*|```|=>)/', // escape gemini text - '/[\n\r]{3,}/', // remove extra breaks + '/(^|\s+)(#|##)/', // escape h1, h2, hashtags + '/[\n\r]{3,}/', // remove extra breaks ], [ '$1 $2', @@ -595,12 +553,6 @@ $server->setHandler( case 'raw': $result[] = null; - $result[] = sprintf( - '=> /%s?gemtext %s', - $record['transaction'], - $config->geminiapp->string->view->gemtext - ); - $result[] = sprintf( '=> /%s %s', $record['transaction'], @@ -609,32 +561,9 @@ $server->setHandler( break; - case 'gemtext': - - $result[] = null; - $result[] = sprintf( - '=> /%s %s', - $record['transaction'], - $config->geminiapp->string->view->reader - ); - - $result[] = sprintf( - '=> /%s?raw %s', - $record['transaction'], - $config->geminiapp->string->view->raw - ); - - break; - default: $result[] = null; - $result[] = sprintf( - '=> /%s?gemtext %s', - $record['transaction'], - $config->geminiapp->string->view->gemtext - ); - $result[] = sprintf( '=> /%s?raw %s', $record['transaction'],