Name detail pages now show DNS records from sidechain, ITNS sidechain registration, services links (DNS/SSL/Proxy), and CIC governance label for community members. Available names link to claim page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
73 lines
2 KiB
PHP
73 lines
2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Mod\Names\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Mod\Chain\Services\DaemonRpc;
|
|
|
|
/**
|
|
* .lthn name registrar web views.
|
|
*
|
|
* GET /names — search + directory
|
|
* GET /names/register — registration form
|
|
* GET /names/{name} — name detail page
|
|
*/
|
|
class NamesWebController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly DaemonRpc $rpc,
|
|
) {}
|
|
|
|
public function index(Request $request): \Illuminate\View\View
|
|
{
|
|
$result = $this->rpc->getAllAliases();
|
|
$aliases = $result['aliases'] ?? [];
|
|
$search = $request->get('search', '');
|
|
|
|
if ($search) {
|
|
$aliases = array_filter($aliases, fn ($a) => str_contains($a['alias'] ?? '', strtolower($search))
|
|
|| str_contains($a['comment'] ?? '', strtolower($search)));
|
|
}
|
|
|
|
return view('names::index', [
|
|
'aliases' => array_values($aliases),
|
|
'total' => count($result['aliases'] ?? []),
|
|
'search' => $search,
|
|
]);
|
|
}
|
|
|
|
public function register(): \Illuminate\View\View
|
|
{
|
|
return view('names::register');
|
|
}
|
|
|
|
public function show(string $name): \Illuminate\View\View
|
|
{
|
|
$alias = $this->rpc->getAliasByName($name);
|
|
|
|
if (! $alias) {
|
|
return view('names::available', ['name' => $name]);
|
|
}
|
|
|
|
// Fetch DNS records from sidechain
|
|
$records = [];
|
|
try {
|
|
$response = Http::timeout(3)->get("http://127.0.0.1:5553/names/{$name}");
|
|
if ($response->ok()) {
|
|
$records = $response->json() ?? [];
|
|
}
|
|
} catch (\Throwable $e) {
|
|
// Sidechain unavailable — show page without records
|
|
}
|
|
|
|
return view('names::show', [
|
|
'name' => $name,
|
|
'alias' => $alias,
|
|
'records' => $records,
|
|
]);
|
|
}
|
|
}
|