update readme
This commit is contained in:
parent
b12cf019e7
commit
ab3227b75f
88 changed files with 7546 additions and 176 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Lubian\NoFramework\Action;
|
||||
|
||||
use Lubian\NoFramework\Model\MarkdownPage;
|
||||
use Lubian\NoFramework\Repository\MarkdownPageFilesystem;
|
||||
use Lubian\NoFramework\Repository\MarkdownPageRepo;
|
||||
use Lubian\NoFramework\Template\Renderer;
|
||||
use Parsedown;
|
||||
|
@ -12,19 +14,33 @@ use function str_replace;
|
|||
|
||||
class Page
|
||||
{
|
||||
public function __invoke(
|
||||
public function __construct(
|
||||
private ResponseInterface $response,
|
||||
private MarkdownPageRepo $repo,
|
||||
private Parsedown $parsedown,
|
||||
private Renderer $renderer,
|
||||
){}
|
||||
public function show(
|
||||
string $page,
|
||||
ResponseInterface $response,
|
||||
MarkdownPageRepo $repo,
|
||||
Parsedown $parsedown,
|
||||
Renderer $renderer,
|
||||
): ResponseInterface {
|
||||
$page = $repo->byTitle($page);
|
||||
$page = $this->repo->byTitle($page);
|
||||
$content = $this->linkFilter($page->content);
|
||||
$content = $parsedown->parse($content);
|
||||
$html = $renderer->render('page', ['content' => $content]);
|
||||
$response->getBody()->write($html);
|
||||
return $response;
|
||||
$content = $this->parsedown->parse($content);
|
||||
$html = $this->renderer->render('page', ['content' => $content, 'title' => $page->title]);
|
||||
$this->response->getBody()->write($html);
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
public function list(): ResponseInterface
|
||||
{
|
||||
$pages = array_map(
|
||||
fn (MarkdownPage $p) => ['title' => $p->title, 'id' => $p->id],
|
||||
$this->repo->all()
|
||||
);
|
||||
$html = $this->renderer->render('pagelist', ['pages' => $pages]);
|
||||
$this->response->getBody()->write($html);
|
||||
return $this->response;
|
||||
|
||||
}
|
||||
|
||||
private function linkFilter(string $content): string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue