Skip to content

Commit 7023e5c

Browse files
committed
feat: Add json-output support
1 parent 94b48bf commit 7023e5c

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.htaccess

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RewriteEngine On
2+
RewriteCond %{REQUEST_FILENAME} !-f
3+
RewriteCond %{REQUEST_FILENAME} !-d
4+
RewriteRule ^ index.php [QSA,L]

config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
return [
4-
'version' => 'v1.0.0',
4+
'version' => 'v2.0.0',
55

66
'domains' => [
77
'mtex.dev',

index.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
$config = require 'config.php';
33
$domains = $config['domains'];
44
$version = $config['version'];
5+
6+
$requestUri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
7+
if ($requetsUri === '/json' || $requestUri === '/json/' || $requestUri === '/index.php/json' || $requestUri === '/index.php/json/' || (isset($_GET['format']) && $_GET['format'] === 'json') || (isset($_GET['output']) && $_GET['output'] === 'json')) {
8+
header('Content-Type: application/json; charset=utf-8');
9+
echo json_encode([
10+
'version' => $version,
11+
'domains' => $domains,
12+
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
13+
exit;
14+
}
515
?>
616
<html lang="en">
717
<head>
@@ -10,10 +20,17 @@
1020
<meta name="description" content="Central directory and manifest of all mtex.dev domains and nodes.">
1121
<meta name="keywords" content="mtex, mtex.dev, domain, directory, nodes, manifest, index">
1222
<meta name="author" content="MTEX.dev">
23+
24+
<meta property="og:image" content="https://github.com/MTEXdotDev.png">
25+
26+
<meta property="twitter:image" content="https://github.com/MTEXdotDev.png">
27+
28+
<link rel="icon" type="image/x-icon" href="https://github.com/MTEXdotDev.png">
29+
<link rel="apple-touch-icon" href="https://github.com/MTEXdotDev.png">
1330
<title>MTEX.dev // Domain Directory</title>
1431
</head>
1532
<body>
16-
<p>MTEX.dev Domain Directory - Version <?php echo htmlspecialchars($version); ?></p>
33+
<p>MTEX.dev Domain Directory - Version <?php echo htmlspecialchars(string: $version); ?></p>
1734
<ul>
1835
<?php foreach ($domains as $domain): ?>
1936
<li><?php echo htmlspecialchars($domain); ?></li>

0 commit comments

Comments
 (0)