-
Notifications
You must be signed in to change notification settings - Fork 0
/
markdown.php
60 lines (45 loc) · 1.77 KB
/
markdown.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once './core/bundles/parsedown/parsedown.php';
require_once './games/games.php';
//default game
$gameId = array_key_first($games);
//set the game to the one requested via get
if(isset($_GET['g']) && !is_array($_GET['g']) && array_key_exists($_GET['g'], $games)){
$gameId = $_GET['g'];
}
$game = $games[$gameId];
$gameMd = $game["game-md"];
$markdownFile = @file_get_contents('./games/' . $gameMd . $r);
if($markdownFile == false){
echo "create a markdown file named test-game.md and refresh this page";
die();
}
$config = require dirname(__FILE__).'/core/config/config.php';
$url = $config['serverBasePath'];
function replaceData($url, $file, $testFlag, $gameid){
$test = "";
if($testFlag)
$test = "testing&";
$gameid = "g=$gameid&";
$file = str_replace('%resource%', $url . "resources.php?{$test}{$gameid}r=", $file);
$file = str_replace('%action%', $url . "action.php?{$test}{$gameid}a=", $file);
return $file;
}
$previewMarkdownFile = replaceData($url, $markdownFile, true, $gameId);
$productionMarkdownFile = htmlspecialchars(replaceData($url, $markdownFile, false, $gameId));
echo "<p>games: <br>";
foreach(array_keys($games) as $key){
if($key == $gameId)
echo "<a>[$key]</a><br>";
else
echo "<a href=\"?g=$key\"> $key </a><br>";
}
echo "<p>server url: $url</p>";
echo "<p>markdown location: {$game['markdown-location']}</p>";
echo "<br><h3>here is your markdown preview</h3>";
$Parsedown = new Parsedown();
echo $Parsedown->text($previewMarkdownFile);
echo "<br><h3>here is your production markdown</h3>";
echo "<pre><code>$productionMarkdownFile</code></pre>";
echo "<p>good colors for both dark and light theme title_color: #eb1f6a | icon_color: #e28905 | text_color: #999999 | bg_color: #27282200</p>";
echo "<button>click here</button>";