Browse Source

urlencode fs navigation links

main
yggverse 7 months ago
parent
commit
aa27bcc9b7
  1. 39
      src/Controller/Nex.php
  2. 10
      src/Model/Filesystem.php

39
src/Controller/Nex.php

@ -125,21 +125,36 @@ class Nex implements MessageComponentInterface @@ -125,21 +125,36 @@ class Nex implements MessageComponentInterface
foreach ($list as $item)
{
// Build gemini text link
$link = ['=>'];
if ($item['name'])
if ($item['link'])
{
$link[] = $item['file'] ? $item['name']
: $item['name'] . '/';
}
$link =
[
'=>', // gemtext format
$item['file'] ? $item['link']
: $item['link'] . '/'
];
if ($item['time'] && $this->_environment->get('time'))
{
$link[] = date('Y-m-d', $item['time']);
}
// Append modification time on enabled
if ($item['time'] && $this->_environment->get('time'))
{
$link[] = date(
'Y-m-d', // gemfeed format
$item['time']
);
}
// Append alt name on link urlencoded
if ($item['name'] != $item['link'])
{
$link[] = $item['name'];
}
// Append link to the new line
$line[] = implode(' ', $link);
// Append link to the new line
$line[] = implode(
' ',
$link
);
}
}
// Merge lines to response

10
src/Model/Filesystem.php

@ -135,8 +135,11 @@ class Filesystem @@ -135,8 +135,11 @@ class Filesystem
$directories[] =
[
'file' => false,
'name' => $name,
'path' => $path,
'name' => $name,
'link' => urlencode(
$name
),
'time' => filemtime(
$path
)
@ -149,8 +152,11 @@ class Filesystem @@ -149,8 +152,11 @@ class Filesystem
$files[] =
[
'file' => true,
'name' => $name,
'path' => $path,
'name' => $name,
'link' => urlencode(
$name
),
'time' => filemtime(
$path
)

Loading…
Cancel
Save