Browse Source

implement link builder

main
ghost 9 months ago
parent
commit
a1b052b7cc
  1. 32
      src/controller/room.php

32
src/controller/room.php

@ -94,17 +94,9 @@ class Room
[ [
$namespace['name'], $namespace['name'],
$namespace['total'], $namespace['total'],
( $this->_url(
$this->_config->gemini->server->port == 1965 ?
sprintf(
'gemini://%s/room/%s',
$this->_config->gemini->server->host,
$namespace['namespace']
) :
sprintf( sprintf(
'gemini://%s:%d/%s', '/room/%s',
$this->_config->gemini->server->host,
$this->_config->gemini->server->port,
$namespace['namespace'] $namespace['namespace']
) )
) )
@ -171,6 +163,7 @@ class Room
return str_replace( return str_replace(
[ [
'{logo}', '{logo}',
'{home}',
'{subject}', '{subject}',
'{posts}' '{posts}'
], ],
@ -178,6 +171,7 @@ class Room
file_get_contents( file_get_contents(
__DIR__ . '/../../logo.ascii' __DIR__ . '/../../logo.ascii'
), ),
$this->_url(),
$subject ? $subject : $namespace, $subject ? $subject : $namespace,
implode( implode(
PHP_EOL, PHP_EOL,
@ -413,4 +407,22 @@ class Room
) )
); );
} }
private function _url(?string $path = null)
{
return (
$this->_config->gemini->server->port == 1965 ?
sprintf(
'gemini://%s%s',
$this->_config->gemini->server->host,
$path
) :
sprintf(
'gemini://%s:%d%s',
$this->_config->gemini->server->host,
$this->_config->gemini->server->port,
$path
)
);
}
} }
Loading…
Cancel
Save