imported
This commit is contained in:
commit
738c3dc4a1
4 changed files with 2060 additions and 0 deletions
241
assets/style.css
Normal file
241
assets/style.css
Normal file
|
@ -0,0 +1,241 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
font-family: Verdana, Geneva, "Dejavu Sans", Arial, Helvetica, sans-serif;
|
||||
background: #ddd;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.dark {
|
||||
background: #111;
|
||||
color: #fff;
|
||||
}
|
||||
.mio {
|
||||
background: #fbeeff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #22b;
|
||||
}
|
||||
a:hover,
|
||||
a:focus,
|
||||
a:active {
|
||||
color: #b22;
|
||||
}
|
||||
|
||||
.dark a {
|
||||
text-decoration: none;
|
||||
color: #aaf;
|
||||
}
|
||||
.dark a:hover,
|
||||
.dark a:focus,
|
||||
.dark a:active {
|
||||
color: #faa;
|
||||
}
|
||||
|
||||
.mio a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
.mio a:hover,
|
||||
.mio a:focus,
|
||||
.mio a:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.navigation {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 250px;
|
||||
background-image: linear-gradient(90deg, #999, #ddd);
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
direction: rtl;
|
||||
}
|
||||
.dark .navigation {
|
||||
background-image: linear-gradient(90deg, #444, #111);
|
||||
}
|
||||
.mio .navigation {
|
||||
background-image: linear-gradient(90deg, #ecddee, #fbeeff);
|
||||
}
|
||||
.navigation-inner {
|
||||
direction: ltr;
|
||||
padding-bottom: 100vh;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font: 20px/30px Verdana, "DejaVu Sans", sans-serif;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: block;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
.depth-2 { padding-top: 5px; font-size: 1.2em; margin-top: 10px; }
|
||||
.depth-3 { padding-left: 10px; font-size: 1.1em; }
|
||||
.depth-4 { padding-left: 20px; }
|
||||
.depth-5 { padding-left: 30px; font-size: .9em; }
|
||||
.depth-6 { padding-left: 40px; font-size: .9em; }
|
||||
|
||||
.content {
|
||||
margin-left: 250px;
|
||||
padding-bottom: 100vh;
|
||||
}
|
||||
.content-wrapper {
|
||||
max-width: 1200px;
|
||||
margin: 20px auto 0;
|
||||
background: #eee;
|
||||
padding: 6px 20px 20px;
|
||||
box-shadow: 0 0 10px #aaa;
|
||||
}
|
||||
.dark .content-wrapper {
|
||||
background: #222;
|
||||
box-shadow: 0 0 10px #000;
|
||||
}
|
||||
.mio .content-wrapper {
|
||||
background: #fbeeff;
|
||||
box-shadow: initial;
|
||||
border: 1px solid #9475b2;
|
||||
}
|
||||
|
||||
@media (max-width: 1450px) {
|
||||
.content-wrapper {
|
||||
margin: 0;
|
||||
box-shadow: initial !important;
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.navigation {
|
||||
background-image: linear-gradient(90deg, #999, #eee);
|
||||
}
|
||||
.dark .navigation {
|
||||
background-image: linear-gradient(90deg, #444, #222);
|
||||
}
|
||||
.mio .navigation {
|
||||
background-image: linear-gradient(90deg, #ecddee, #fbeeff);
|
||||
}
|
||||
}
|
||||
|
||||
.attribs {
|
||||
font-size: .9em;
|
||||
line-height: 1.5em;
|
||||
text-align: center;
|
||||
margin: 10px;
|
||||
}
|
||||
.mio .attribs a {
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
.mio .attribs a:hover, .mio .attribs a:focus, .mio .attribs a:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.options {
|
||||
font-size: .9em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
line-height: 2em;
|
||||
margin-top: 10px;
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.mio h1, .mio h2, .mio h3, .mio h4, .mio h5, .mio h6 {
|
||||
color: #306;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
.mio h1 {
|
||||
background-color: #9475b2;
|
||||
border: 0;
|
||||
padding: 5px 20px;
|
||||
margin: -6px -20px 15px;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
margin-top: 10px;
|
||||
padding: 5px;
|
||||
font-family: Consolas, monospace;
|
||||
}
|
||||
.dark pre {
|
||||
background-color: #111;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: 1px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: .5em 0;
|
||||
}
|
||||
|
||||
table td, table th {
|
||||
border: 1px solid;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
.mio table {
|
||||
border: solid 1px #9475B2;
|
||||
}
|
||||
.mio th {
|
||||
background:#9475B2;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
border: 0;
|
||||
color: #306;
|
||||
}
|
||||
.mio td {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
.dark code {
|
||||
background-color: #111;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
p + h2, table + h2 {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
p + h3, table + h3,
|
||||
p + h4, table + h4,
|
||||
p + h5, table + h5,
|
||||
p + h6, table + h6 {
|
||||
margin-top: 1em;
|
||||
}
|
104
index.php
Normal file
104
index.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
define('DOC_START', microtime(true));
|
||||
define('DOC_PATH', 'https://patchii.net/flashii/sharp-chat/raw/branch/mistress/Protocol.md');
|
||||
|
||||
function clean_section_name(string $name): string {
|
||||
return str_replace('`', '', trim($name, " \t\n\r\0\x0B#"));
|
||||
}
|
||||
|
||||
function create_section_anchor(string $name): string {
|
||||
return preg_replace('#[^0-9a-zA-Z]#', '-', strtolower($name));
|
||||
}
|
||||
|
||||
$validColourSchemes = ['Light' => '', 'Dark' => 'dark', 'Mio' => 'mio'];
|
||||
|
||||
if(isset($_GET['c']) && is_string($_GET['c']) && in_array($_GET['c'], $validColourSchemes)) {
|
||||
setcookie('scd_cs', $_GET['c'], strtotime('+1 year'), '/sockchat');
|
||||
header('Location: ./');
|
||||
exit;
|
||||
}
|
||||
|
||||
$colorScheme = isset($_COOKIE['scd_cs']) && in_array($_COOKIE['scd_cs'] ?? null, $validColourSchemes) ? $_COOKIE['scd_cs'] : '';
|
||||
|
||||
require_once 'parsedown.php';
|
||||
|
||||
$docPath = DOC_PATH;
|
||||
|
||||
$mdLocalPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5($docPath);
|
||||
|
||||
if(is_file($mdLocalPath) && (filemtime($mdLocalPath) + 300) >= time()) {
|
||||
$protInfo = file_get_contents($mdLocalPath);
|
||||
} else {
|
||||
$protInfo = file_get_contents($docPath);
|
||||
file_put_contents($mdLocalPath, $protInfo);
|
||||
}
|
||||
|
||||
$protLines = explode("\n", $protInfo);
|
||||
$sections = [];
|
||||
|
||||
foreach($protLines as $line) {
|
||||
if(empty($line))
|
||||
continue;
|
||||
|
||||
if($line[0] === '#') {
|
||||
$depth = 0;
|
||||
|
||||
for($i = 0;;$i++) {
|
||||
if($line[$i] === '#')
|
||||
$depth++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
$name = clean_section_name($line, " \t\n\r\0\x0B#");
|
||||
|
||||
if($depth > 1) {
|
||||
$anchor = create_section_anchor($name);
|
||||
$sections[] = [
|
||||
'name' => $name,
|
||||
'anchor' => $anchor,
|
||||
'depth' => $depth,
|
||||
];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Sock Chat Documentation</title>
|
||||
<link href="./assets/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body<?php if(!empty($colorScheme)) { echo ' class="' . $colorScheme . '"'; } ?>>
|
||||
<div class="navigation">
|
||||
<div class="navigation-inner">
|
||||
<a class="logo" href="#">Sock Chat Docs</a>
|
||||
<div class="options">
|
||||
<?php foreach($validColourSchemes as $name => $scheme): ?>
|
||||
<a href="?c=<?=$scheme;?>">[<?=$name;?>]</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php foreach($sections as $section): ?>
|
||||
<a href="#<?=$section['anchor'];?>" class="nav-link depth-<?=$section['depth'];?>">
|
||||
<?=$section['name'];?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="content-wrapper">
|
||||
<?=(new Parsedown)->text($protInfo);?>
|
||||
</div>
|
||||
<div class="attribs">
|
||||
<div class="attrib">Sock Chat was created by <a href="http://dev.aroltd.com">reemo</a></div>
|
||||
<div class="attrib">Markdown parsing by a <a href="./src.php?f=parsedown.php">modified</a> version of <a href="https://github.com/erusev/parsedown">Parsedown</a></div>
|
||||
<div class="attrib">Maintained by <a href="https://flash.moe">flashwave</a></div>
|
||||
<div class="attrib"><a href="./src.php?f=index.php">This page</a> is automatically generated using Protocol.md from the <a href="https://patchii.net/flashii/sharp-chat">Sharp Chat</a> repository.</div>
|
||||
<div class="attrib">Loaded in <?=number_format(microtime(true) - DOC_START, 5);?> seconds.</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
1696
parsedown.php
Normal file
1696
parsedown.php
Normal file
File diff suppressed because it is too large
Load diff
19
src.php
Normal file
19
src.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
$file = !empty($_GET['f']) && is_string($_GET['f']) && ctype_print($_GET['f']) ? trim(str_replace('..', '', (string)$_GET['f']), '/') : '';
|
||||
$allowedPaths = [
|
||||
'index.php',
|
||||
'parsedown.php',
|
||||
'src.php',
|
||||
];
|
||||
$maskStrings = [
|
||||
];
|
||||
|
||||
if(empty($file) || !isset($_GET['f']))
|
||||
$file = $allowedPaths[0];
|
||||
|
||||
if(in_array($file, $allowedPaths, true)) {
|
||||
$file = file_get_contents($file);
|
||||
foreach($maskStrings as $string)
|
||||
$file = str_replace($string, '*****', $file);
|
||||
highlight_string($file);
|
||||
}
|
Reference in a new issue