Skip to content

Commit

Permalink
Added link overview page and GitHub fluff.
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Jun 15, 2019
1 parent f2dc47a commit 09cee66
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will otherwise have CRLF line endings on checkout.
*.php text eol=lf
*.json text eol=lf

# GitHub baggage for development.
.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
README.md export-ignore
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Packages
*.zip
*.7z
*.gz
*.tar
*.rar

## Local storage
*.log
*.ser
*.sql
*.sqlite

## Common work-file extensions
*.tmp
*.bak

## OS generated files
.DS_Store
.DS_Store?
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Endpoint not found - tsf.fyi</title>
<title>Endpoint not found - TSF.fyi</title>
<meta http-equiv=refresh content="5; url=https://theseoframework.com/" />
<link rel=canonical href=https://theseoframework.com/ />
<meta name=viewport content="width=device-width, initial-scale=1" />
Expand Down
2 changes: 1 addition & 1 deletion 503.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Could not resolve endpoint - tsf.fyi</title>
<title>Could not resolve endpoint - TSF.fyi</title>
<meta http-equiv=refresh content="5; url=https://theseoframework.com/" />
<link rel=canonical href=https://theseoframework.com/ />
<meta name=viewport content="width=device-width, initial-scale=1" />
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [TSF.fyi](https://tsf.fyi/links) #

This repository is a clone of the TSF.fyi website. It's built because our primary domain name, theseoframework.com, is large and unwieldy.

No ads. No tracking. No nonsense.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
exit;
}

function retry() {
function retry(): void {
// Retry after 1s.
$retry = ( $_GET['r'] ?? 0 ) + 1;

Expand Down Expand Up @@ -113,7 +113,7 @@ function find_endpoint( stdClass $json, array $r ): string {
}

return $endpoint ?? $default;
};
}

$location = find_endpoint( $json, $r ) ?: '';

Expand Down
14 changes: 11 additions & 3 deletions links.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"contributing": "https://github.com/sybrew/the-seo-framework/blob/master/.github/CONTRIBUTING.md",
"links": {
"_alt": [
"endpoint",
"endpoints"
],
"_default": "https://tsf.fyi/links.php"
},
"man": {
"_alt": [
"about",
"manual"
],
"_deep": {
"links": "https://raw.githubusercontent.com/sybrew/tsf-fyi/master/links.json"
"rawlinks": "https://raw.githubusercontent.com/sybrew/tsf-fyi/master/links.json",
"home": "https://tsf.fyi/links.php"
},
"_default": "https://github.com/sybrew/tsf-fyi"
},
"shortlinks": "https://tsf.fyi/links.json",
"contributing": "https://github.com/sybrew/the-seo-framework/blob/master/.github/CONTRIBUTING.md",
"kb": {
"_alt": [
"knowledge",
Expand All @@ -24,6 +31,7 @@
},
"docs": {
"_alt": [
"d",
"tuts",
"help"
],
Expand Down
219 changes: 219 additions & 0 deletions links.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<?php

$timer = microtime( true );

header( 'Cache-Control: max-age=3600', true );
header( 'Pragma: public' );
header( 'X-Robots-Tag: noindex, follow', true );

$json = json_decode(
file_get_contents( __DIR__ . DIRECTORY_SEPARATOR . 'links.json', false, stream_context_create( [ 'http' => [ 'timeout' => 1 ] ] ) )
?: []
);

if ( ! $json ) {
header( 'Cache-Control: max-age=30', true );
http_response_code( 503 );
echo 'Something went wrong parsing the links. Try again later.';
exit;
}

function loop_json( stdClass $json, array $basepoints = [] ) {
foreach ( $json as $_endpoint => $_json ) {
if ( is_string( $_json ) ) {
yield from make_link( $basepoints, $_endpoint, $_json );
} else {
if ( $_json->_default ?? '' ) {
yield from make_link( $basepoints, $_endpoint, $_json->_default );
}
foreach ( $_json->_alt ?? [] as $_alt ) {
yield from make_alt_link( $basepoints, $_alt, $_endpoint );
}
if ( isset( $_json->_deep ) ) {
yield from loop_json( $_json->_deep, array_merge( $basepoints, [ $_endpoint ] ) );
}
}
}
}

function make_link( array $basepoints, $endpoint, $link ) {
$endpoint = false !== strpos( $endpoint, '$' ) ? sprintf( '<em class="noselect underline">%s</em>', $endpoint ) : $endpoint;
yield
sprintf( '<strong>%s</strong>', 'https://tsf.fyi/' . ltrim( implode( '/', $basepoints ) . "/$endpoint", '/' ) )
=> $link;
}

function make_alt_link( array $basepoints, $altendpoint, $altfor ) {
yield
'<span class=noselect>&mdash; </span>https://tsf.fyi/' . ltrim( implode( '/', $basepoints ) . "/$altendpoint", '/' )
=> sprintf( '<em>%s</em>', 'https://tsf.fyi/' . ltrim( implode( '/', $basepoints ) . "/$altfor", '/' ) );
}

$icon = <<<'ICON'
<svg class="icon" x="0px" y="0px" viewBox="0 0 275 275" shape-rendering="geometricPrecision"><g>
<path class="path1" d="M274.516,185.634c0-1.09-0.242-1.453-1.453-1.453c-15.137,0-30.394,0-45.531,0
c-1.09,0-1.453-0.242-1.453-1.453c0-15.137,0-30.394,0-45.531c0-1.211-0.363-1.453-1.453-1.453c-6.539,0-13.078,0-19.617,0
c-6.539,0-13.078,0-19.617,0c-1.09,0-1.453,0.242-1.453,1.453c0,15.137,0,30.394,0,45.531c0,1.09-0.242,1.453-1.453,1.453
c-15.137,0-30.394,0-45.531,0c-1.211,0-1.453,0.363-1.453,1.453c0,6.539,0,13.078,0,19.617c0,6.539,0,13.078,0,19.617
c0,1.09,0.242,1.453,1.453,1.453c15.137,0,30.394,0,45.531,0c1.09,0,1.453,0.242,1.453,1.453c0,15.137,0,30.394,0,45.531
c0,1.211,0.363,1.453,1.453,1.453c6.539,0,13.078,0,19.617,0c6.539,0,13.078,0,19.617,0c1.09,0,1.453-0.242,1.453-1.453
c0-15.137,0-30.394,0-45.531c0-1.09,0.242-1.453,1.453-1.453c15.137,0,30.394,0,45.531,0c1.211,0,1.453-0.363,1.453-1.453
c0-6.539,0-13.078,0-19.617C274.516,198.712,274.516,192.173,274.516,185.634z"></path>
<path class="path2" d="M274.516,106.318c0-13.683,0-27.367,0-41.171c0-3.027,0-6.176,0-9.203c0-0.605-0.121-1.09-0.727-1.574
c-1.332-1.09-2.543-2.301-3.754-3.391c-4.844-4.359-9.566-8.84-14.41-13.199c-6.902-6.297-13.805-12.594-20.707-18.769
c-4.965-4.48-9.93-8.961-14.773-13.441c-2.18-1.937-4.48-3.754-6.418-6.055c-66.964,0-134.049,0-201.013,0
c-1.09,0.121-1.574,0.242-2.301,0.605C7.266,1.331,4.844,3.39,2.906,6.175C1.332,8.476,0.242,10.897,0,13.561
c0,82.101,0,164.322,0,246.423c0.242,0.484,0,0.969,0.242,1.453c0.121,0.363,0.121,0.605,0.242,0.969
c0.605,2.785,1.574,5.328,3.512,7.387C7.266,273.547,11.746,275,16.59,275c23.492,0,47.105,0,70.597,0l0,0c1.09,0,2.18,0,3.269,0
c0.121,0,0.242,0,0.363,0l0,0c23.976,0,47.953,0,71.929,0c0.363,0,0.605,0,0.969,0c0.605,0,0.727-0.242,0.727-0.848
c0-8.719,0-17.558,0-26.277c0-1.695,0-1.695-1.816-1.695c-23.855,0-47.71,0-71.687,0l0,0c-20.101,0-40.203,0-60.425,0
c-1.816,0-1.574,0.121-1.574-1.574c0-71.445,0-142.889,0-214.334c0-1.816-0.242-1.695,1.695-1.695c31.968,0,64.058,0,96.026,0
c25.429,0,50.859,0,76.288,0c0.848,0,1.453,0.121,2.059,0.727c1.937,1.816,3.996,3.633,5.934,5.449
c7.266,6.539,14.41,13.199,21.676,19.738c4.238,3.875,8.355,7.75,12.594,11.625c0.848,0.727,1.09,1.453,1.09,2.422
c0,12.594,0,25.187,0,37.781l0,0c0,18.89,0,37.66,0,56.55c0,1.574,0,1.574,1.574,1.574c8.355,0,16.711,0,25.066,0
c1.574,0,1.574,0,1.574-1.695C274.516,143.978,274.516,125.209,274.516,106.318L274.516,106.318z"></path>
</g></svg>
ICON;

?><!DOCTYPE html>
<html>
<head>
<title>TSF.fyi links</title>
<meta name=viewport content="width=device-width, initial-scale=1" />
<style>
body {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
background: #919ea1;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
font-size: 16px;
line-height: 1.625em;
color: #333;
margin: 0
}
a {
color: inherit;
text-decoration: none
}
a:focus {
outline: none;
text-decoration: underline
}
main {
color: #070d03;
padding: 2em;
background: #e3e7e8;
border: 1px solid #465053;
margin: 1em auto;
border-radius: 3px;
box-shadow: 0 0 1em #465053;
max-width: 1400px
}
footer {
text-align: center;
color: #fdfbfe;
margin: 1em auto;
max-width: 1400px;
font-size: .875em
}
h1 {
margin-top: 0
font-family: Verdana,Geneva,sans-serif;
font-size: 25px;
font-weight: 400;
line-height: 26px; /* 25+1 svg overflow clip fix */
margin: 0
}
h1 a {
vertical-align: top
}
h1 a:hover,
h1 a:focus {
color: inherit
}
h1 svg {
display: inline-block;
padding: 0;
margin-right: 7px;
margin-left: 0;
vertical-align: bottom;
width: 1em;
height: 1em;
fill: currentColor;
line-height: 1em
}
h1 a:hover .path1 {
fill: #0ebfe9
}
table, td, th {
border: 1px solid #222
}
table {
border-collapse: collapse;
width: 100%;
overflow: auto
}
th {
text-align: left
}
th, td {
padding: .25em .5em
}
.underline {
text-decoration: underline
}
.noselect {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
</style>
</head>
<body>
<main>
<h1><a href=https://tsf.fyi/links.php><?php echo $icon; ?>TSF.fyi</a> registered endpoints</h1>
<p>
<em><strong>$</strong> = single directory wildcard. <strong>$$</strong> = unlimited directory wildcard.</em><br>
</p>
<table>
<tr>
<th>
Endpoint
</th>
<th>
Link
</th>
</tr>
<?php
foreach ( loop_json( $json ) as $_endpoint => $_result ) {
vprintf(
"\t\t\t\t<tr><td>%s</td><td>%s</td></tr>",
[
$_endpoint,
$_result
]
);
}
?>
</table>
</main>
<footer>
<p>
<?php
vprintf(
'Powered by %s &bull; Generated in %s microseconds &bull; Generation ID: <code>%s</code>',
[
'<a href=https://theseoframework.com/>The SEO Framework</a>',
(int) abs( ( microtime( true ) - $timer ) * 1e6 ),
bin2hex( random_bytes( 16 ) ),
]
);
?>
</p>
</footer>
</body>
</html>
<?php

0 comments on commit 09cee66

Please sign in to comment.