惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
N
Netflix TechBlog - Medium
C
Check Point Blog
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
腾讯CDC
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
V
V2EX
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
B
Blog

Feed of "schmarty/gem-diamond"

issue when using indieauth[dot]com? gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond proxy for profile images gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond
gem-diamond
schmarty · 2024-07-29 · via Feed of "schmarty/gem-diamond"

共有 3 个文件被更改,包括 41 次插入7 次删除

@ -6,20 +6,19 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Schmarty\Micropubkit\Controllers\Common\{ResponseAware,ResponseAwareTrait};
use Schmarty\Micropubkit\Controllers\Common\{TemplatesAware,TemplatesAwareTrait};
class Controller implements ResponseAware {
class Controller implements ResponseAware, TemplatesAware {
use ResponseAwareTrait;
use TemplatesAwareTrait;
private \League\Plates\Engine $templates;
private \App\Model\Site $site;
private \App\Model\SiteCheck $siteCheck;
public function __construct(\League\Plates\Engine $templates, \App\Model\Site $site, \App\Model\SiteCheck $siteCheck) {
$this->templates = $templates;
public function __construct(\App\Model\Site $site, \App\Model\SiteCheck $siteCheck) {
$this->site = $site;
$this->siteCheck = $siteCheck;
$this->templates->addData(['hostname' => $_SERVER['SERVER_NAME']]);
}
public function index(ServerRequestInterface $request): ResponseInterface {

@ -0,0 +1,31 @@
<?php declare(strict_types=1);
namespace App;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Server\MiddlewareInterface;
use Schmarty\Micropubkit\Controllers\Common\{TemplatesAware,TemplatesAwareTrait};
class TemplatesCommonMiddleware implements MiddlewareInterface, TemplatesAware
{
use TemplatesAwareTrait;
/**
* {@inheritdoc}
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// add common bits that our temlpates need to know
$this->templates->addData([
'hostname' => $_SERVER['SERVER_NAME']
]);
// and pass along
return $handler->handle($request);
}
}
@ -24,12 +24,16 @@ $app->container->addShared(App\Model\SiteCheck::class)->addArgument(App\DB::clas
// set up controller for welcome and forms
$app->container->addShared(App\Controller::class)
->addArgument(League\Plates\Engine::class)
->addArgument(App\Model\Site::class)
->addArgument(App\Model\SiteCheck::class);
// set up middleware
$app->container->add(App\TemplatesCommonMiddleware::class);
// allow login everywhere but be chill about it
$app->route->middleware($app->optionalAuthMiddleware);
$app->route
->middleware($app->optionalAuthMiddleware)
->middleware($app->container->get(App\TemplatesCommonMiddleware::class));
// set up app-specific routes
$app->route->get('/', 'App\\Controller::index')->setName('loginForm');