mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-02-05 03:34:33 +00:00
implement getPageLinkByPath method, fix readme
This commit is contained in:
parent
d12b52597f
commit
fbfaed02fc
32
README.md
32
README.md
@ -121,7 +121,7 @@ var_dump (
|
||||
$filesystem->getList(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getTree
|
||||
@ -133,7 +133,7 @@ var_dump (
|
||||
$filesystem->getTree(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getPagePathsByPath
|
||||
@ -145,7 +145,7 @@ var_dump (
|
||||
$filesystem->getPagePathsByPath(
|
||||
// absolute path to target data directory (e.g. Filesystem::getDirectoryPathByUri)
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getDirectoryPathByUri
|
||||
@ -158,7 +158,7 @@ var_dump (
|
||||
$filesystem->getPagePathByUri(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getDirectoryUriByPath
|
||||
@ -171,7 +171,7 @@ var_dump (
|
||||
$filesystem->getPageUriByPath(
|
||||
'/full/path/to/page.txt'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
### Helper
|
||||
@ -185,7 +185,7 @@ $helper = new \Yggverse\Gemini\Dokuwiki\Helper(
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getChildrenSectionLinksByUri
|
||||
#### Helper::getChildrenSectionLinksByUri
|
||||
|
||||
Return simple array of children section links in Gemini format
|
||||
|
||||
@ -194,10 +194,10 @@ var_dump (
|
||||
$helper->getChildrenSectionLinksByUri(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Filesystem::getChildrenPageLinksByUri
|
||||
#### Helper::getChildrenPageLinksByUri
|
||||
|
||||
Return simple array of children page links in Gemini format
|
||||
|
||||
@ -206,5 +206,19 @@ var_dump (
|
||||
$helper->getChildrenPageLinksByUri(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Helper::getPageLinkByPath
|
||||
|
||||
Return page link (that contain document name) in Gemini format
|
||||
|
||||
```
|
||||
var_dump (
|
||||
$helper->getPageLinkByPath(
|
||||
$filesystem->getPagePathByUri(
|
||||
'hello:world'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
@ -110,19 +110,10 @@ class Helper
|
||||
{
|
||||
foreach ((array) $this->_filesystem->getPagePathsByPath($directory) as $file)
|
||||
{
|
||||
$pages[] = sprintf(
|
||||
'=> /%s %s',
|
||||
$this->_filesystem->getPageUriByPath(
|
||||
$file
|
||||
),
|
||||
$this->_reader->getH1(
|
||||
$this->_reader->toGemini(
|
||||
file_get_contents(
|
||||
$file
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($link = $this->getPageLinkByPath($file))
|
||||
{
|
||||
$pages[] = $link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,4 +129,26 @@ class Helper
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function getPageLinkByPath(string $path): ?string
|
||||
{
|
||||
if (in_array($path, $this->_filesystem->getList()) && is_file($path) && is_readable($path))
|
||||
{
|
||||
return sprintf(
|
||||
'=> /%s %s',
|
||||
$this->_filesystem->getPageUriByPath(
|
||||
$path
|
||||
),
|
||||
$this->_reader->getH1(
|
||||
$this->_reader->toGemini(
|
||||
file_get_contents(
|
||||
$path
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user