Skip to content

Commit

Permalink
Cleaned up code. More links.
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Oct 21, 2024
1 parent ec4b2f2 commit db6ffae
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
header( 'Cache-Control: max-age=3600', true );
header( 'Pragma: public' );

if ( ( $_GET['error'] ?? false ) ) {
if ( $_GET['error'] ?? false ) {
header( 'X-Robots-Tag: noindex, follow', true );
header( 'Cache-Control: max-age=60', true );
http_response_code( 503 );
require __DIR__ . DIRECTORY_SEPARATOR . '503.html';
exit;
}

function retry(): void {
function retry() {
$retry = (int) ( $_GET['r'] ?? 0 ) + 1;

if ( $retry > 3 ) {
Expand Down Expand Up @@ -68,7 +68,7 @@ function retry(): void {

$r = array_values( array_filter( explode( '/', $request ) ) );

function find_endpoint( stdClass $json, array $r ): string {
function find_endpoint( $json, $r ) {

$default = '';
$depth = 0;
Expand All @@ -87,7 +87,7 @@ function find_endpoint( stdClass $json, array $r ): string {
if ( false !== strpos( $_endpoint, '$$' ) ) {
// Wildcard replacement.
$_items = array_slice( $r, $depth );
$next = str_replace( '$$', implode( '/', $_items ), $_json );
$next = str_replace( '$$', implode( '/', $_items ), $_json );
} else {
// Prudent replacement.
$next = str_replace( '$', $r[ $depth ], $_json );
Expand Down
44 changes: 39 additions & 5 deletions links.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"install-em": "https://kb.theseoframework.com/kb/how-to-install-the-extension-manager/",
"common-update-issues": "https://kb.theseoframework.com/kb/common-plugin-update-issues/",
"pixelcounter": "https://kb.theseoframework.com/kb/what-are-pixel-counters/",
"structureddata": "https://kb.theseoframework.com/kb/structured-data-supported-by-the-seo-framework/"
"structureddata": "https://kb.theseoframework.com/kb/structured-data-supported-by-the-seo-framework/",
"data": "https://kb.theseoframework.com/kb/data-stored-in-your-database/"
},
"_default": "https://kb.theseoframework.com/kb/"
},
Expand Down Expand Up @@ -97,6 +98,7 @@
},
"github": {
"_alt": [
"g",
"gh",
"git"
],
Expand All @@ -117,8 +119,19 @@
"_default": "https://github.com/lebaux"
},
"tsf": {
"_alt": [
"t"
],
"_deep": {
"$$": "https://github.com/sybrew/the-seo-framework/$$"
"$$": "https://github.com/sybrew/the-seo-framework/$$",
"version": {
"_deep": {
"$$": "https://github.com/sybrew/the-seo-framework/blob/$$"
},
"_alt": [
"v"
]
}
},
"_default": "https://github.com/sybrew/the-seo-framework"
},
Expand Down Expand Up @@ -250,7 +263,7 @@
"_deep": {
"premium": "https://premium.theseoframework.com/support/"
},
"_default": "https://theseoframework.com/contact/"
"_default": "https://theseoframework.com/support/contact/"
},
"support": {
"_deep": {
Expand Down Expand Up @@ -284,7 +297,7 @@
"public-em"
],
"_deep": {
"private": "https://theseoframework.com/contact/"
"private": "https://theseoframework.com/support/contact/"
},
"_default": "https://github.com/sybrew/The-SEO-Framework-Extension-Manager/issues/new/choose"
},
Expand All @@ -298,7 +311,7 @@
"_alt": [
"email"
],
"_default": "https://theseoframework.com/contact/"
"_default": "https://theseoframework.com/support/contact/"
}
},
"_default": "https://theseoframework.com/support/"
Expand Down Expand Up @@ -335,5 +348,26 @@
}
},
"_default": "https://twitter.com/TheSEOFramework"
},
"snippets": {
"_alt": [
"snippet"
],
"_deep": {
"install": {
"_alt": [
"install-guide",
"how-to-use"
],
"_default": "https://github.com/sybrew/tsf-snippets/blob/main/README.md#how-to-install-a-snippet"
},
"get": {
"_deep": {
"$$": "https://dl.theseoframework.com/get/snippet/$$"
}
},
"$$": "https://github.com/sybrew/tsf-snippets/tree/main/$$"
},
"_default": "https://github.com/sybrew/tsf-snippets"
}
}
4 changes: 2 additions & 2 deletions links.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function make_alt_link( array $basepoints, string $altendpoint, string $altfor,
</head>
<body>
<main>
<h1><a href=https://tsf.fyi/links.php><?php echo $icon; ?>TSF.fyi</a> registered endpoints</h1>
<h1><a href=https://tsf.fyi/links.php><?= $icon ?>TSF.fyi</a> registered endpoints</h1>
<p>
<em><strong>$</strong> = single directory wildcard. <strong>$$</strong> = unlimited directory wildcard.</em><br>
<em>Bolded endpoints are canonical, others are alternatives; either may trickle down for deeper links.</em>
Expand Down Expand Up @@ -257,7 +257,7 @@ function make_alt_link( array $basepoints, string $altendpoint, string $altfor,
[
'<a href=https://theseoframework.com/>The SEO Framework</a>',
(int) abs( ( hrtime( true ) - $timer ) / 1e3 ),
bin2hex( random_bytes( 16 ) ),
bin2hex( random_bytes( 16 ) ), // This doesn't do anything useful but show that every request is unique.
]
);
?>
Expand Down

0 comments on commit db6ffae

Please sign in to comment.