Skip to content

Commit af85151

Browse files
committed
feat: Add gh.mtex.dev integration ...
1 parent 03e844c commit af85151

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

config.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,87 @@
11
<?php
22

33
return [
4-
'version' => 'v1.3.3',
4+
'version' => 'v1.4.0',
5+
'gh_service_index' => 5,
56
'services' => [
67
[
78
'address' => 'https://mtex.dev',
89
'name' => 'Landingpage',
910
'description' => 'Our main landingpage',
1011
'github' => 'https://github.com/MTEDdotDev/static-landingpage',
12+
'github_slug' => 'static-landingpage',
1113
'is_deployed' => true,
1214
],
1315
[
1416
'address' => 'https://index.mtex.dev',
1517
'name' => 'Service Index',
1618
'description' => 'Central directory and manifest of all mtex.dev domains and nodes.',
1719
'github' => 'https://github.com/MTEDdotDev/index.mtex.dev',
20+
'github_slug' => 'index.mtex.dev',
1821
'is_deployed' => true,
1922
],
2023
[
2124
'address' => 'https://legal.mtex.dev',
2225
'name' => 'Legal Center',
2326
'description' => 'Multilingual hub for imprint, privacy policies, and legal documentation.',
2427
'github' => 'https://github.com/MTEXdotDev/legal.mtex.dev',
28+
'github_slug' => 'legal.mtex.dev',
2529
'is_deployed' => true,
2630
],
2731
[
2832
'address' => 'https://tw.mtex.dev',
2933
'name' => 'Tailwind Components Libary',
3034
'description' => 'Our TailwindCSS component library for rapid UI development.',
3135
'github' => 'https://github.com/MTEDdotDev/tw.mtex.dev',
36+
'github_slug' => 'tw.mtex.dev',
3237
'is_deployed' => true,
3338
],
3439
[
3540
'address' => 'https://nx.mtex.dev',
3641
'name' => 'MTEX Nexus',
3742
'description' => 'A lightweight JSON API gateway for seamless data exchange and rapid prototyping.',
3843
'github' => 'https://github.com/MTEDdotDev/nx.mtex.dev',
44+
'github_slug' => 'nx.mtex.dev',
45+
'is_deployed' => true,
46+
],
47+
[
48+
'address' => 'https://gh.mtex.dev',
49+
'name' => 'MTEX GitHub Redirect',
50+
'description' => 'Redirects to the github-repos.',
51+
'github' => 'https://github.com/MTEDdotDev/gh.mtex.dev',
52+
'github_slug' => 'gh.mtex.dev',
3953
'is_deployed' => true,
4054
],
4155
[
4256
'address' => 'https://diff.mtex.dev',
4357
'name' => 'MTEX Diff',
4458
'description' => 'A visual comparison tool for JSON payloads and code.',
4559
'github' => 'https://github.com/MTEDdotDev/diff.mtex.dev',
60+
'github_slug' => 'diff.mtex.dev',
4661
'is_deployed' => true,
4762
],
4863
[
4964
'address' => 'https://gimy.site',
5065
'name' => 'GimySite',
5166
'description' => 'Free static website hosting for modern developers.',
5267
'github' => 'https://github.com/MTEDdotDev/gimy.site',
68+
'github_slug' => 'gimy.site',
5369
'is_deployed' => false,
5470
],
5571
[
5672
'address' => 'https://getmy.name',
5773
'name' => 'GetMyName',
5874
'description' => 'A headless API to power your personal portfolio data.',
5975
'github' => 'https://github.com/MTEDdotDev/getmy.name',
76+
'github_slug' => 'getmy.name',
6077
'is_deployed' => true,
6178
],
6279
[
6380
'address' => 'https://getmy.blog',
6481
'name' => 'GetMyBlog',
6582
'description' => 'Lightweight blogging-api for the minimalist writer.',
6683
'github' => 'https://github.com/MTEDdotDev/getmy.blog',
84+
'github_slug' => 'getmy.blog',
6785
'is_deployed' => false,
6886
],
6987
],

index.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
date_default_timezone_set('Europe/Berlin');
33
$config = require 'config.php';
44

5+
$gh_redirect_active = false;
6+
$gh_service_index = $config['gh_service_index'] ?? 5;
7+
if (isset($config['services'][$gh_service_index])) {
8+
$gh_service = $config['services'][$gh_service_index];
9+
if ($gh_service['is_deployed']) {
10+
$ch_gh = curl_init($gh_service['address']);
11+
curl_setopt($ch_gh, CURLOPT_NOBODY, true);
12+
curl_setopt($ch_gh, CURLOPT_FOLLOWLOCATION, true);
13+
curl_setopt($ch_gh, CURLOPT_TIMEOUT, 2); // Fast check
14+
curl_exec($ch_gh);
15+
$gh_code = curl_getinfo($ch_gh, CURLINFO_HTTP_CODE);
16+
curl_close($ch_gh);
17+
if ($gh_code >= 200 && $gh_code < 400) {
18+
$gh_redirect_active = true;
19+
}
20+
}
21+
}
22+
523
if (isset($_GET['type'])) {
624
$type = strtolower($_GET['type']);
725
if ($type === 'raw') {
@@ -110,6 +128,14 @@
110128

111129
<div class="space-y-4">
112130
<?php foreach ($config['services'] as $index => $service): ?>
131+
<?php
132+
$targetGithubUrl = $service['github'];
133+
$usingGhMtex = false;
134+
if ($gh_redirect_active && isset($service['github_slug']) && !empty($service['github_slug'])) {
135+
$targetGithubUrl = 'https://gh.mtex.dev/' . $service['github_slug'];
136+
$usingGhMtex = true;
137+
}
138+
?>
113139
<div id="service-<?php echo $index; ?>"
114140
data-address="<?php echo $service['address']; ?>"
115141
data-deployed="<?php echo $service['is_deployed'] ? 'true' : 'false'; ?>"
@@ -125,10 +151,10 @@ class="service-card bg-neutral-900 border border-neutral-800 rounded-2xl p-5 md:
125151
</div>
126152
<p class="text-sm text-neutral-400 mb-4 leading-relaxed max-w-2xl"><?php echo $service['description']; ?></p>
127153
<div class="flex items-center flex-wrap gap-x-3 gap-y-2 text-xs">
128-
<a href="<?php echo $service['github']; ?>" target="_blank"
154+
<a href="<?php echo $targetGithubUrl; ?>" target="_blank"
129155
class="text-neutral-500 hover:text-white transition-colors flex items-center gap-1.5 group">
130156
<svg class="w-3.5 h-3.5 opacity-70 group-hover:opacity-100" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
131-
Repository
157+
Repository <?php if ($usingGhMtex) echo '<span class="ml-1 opacity-50" title="Routed via gh.mtex.dev">↗</span>'; ?>
132158
</a>
133159
<span class="text-neutral-800">|</span>
134160
<span class="text-neutral-600 font-mono tracking-tighter truncate max-w-[150px] sm:max-w-none"><?php echo str_replace(['https://', 'http://'], '', $service['address']); ?></span>

0 commit comments

Comments
 (0)