This repository was archived by the owner on Dec 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
67 lines (54 loc) · 1.64 KB
/
index.php
File metadata and controls
67 lines (54 loc) · 1.64 KB
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
61
62
63
64
65
66
67
<?php
namespace ThemeViz;
header("Access-Control-Allow-Origin: *");
define("THEMEVIZ_BASE_PATH", dirname(__FILE__));
include_once(THEMEVIZ_BASE_PATH . "/vendor/autoload.php");
$app = new \Slim\App([
"debug" => true,
"settings" => [
"displayErrorDetails" => true
]
]);
use Psr\Http\Message\RequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
$app->add(function (Request $request, Response $response, callable $next) {
$uri = $request->getUri();
$path = $uri->getPath();
if ($path != '/' && substr($path, -1) == '/') {
// permanently redirect paths with a trailing slash
// to their non-trailing counterpart
$uri = $uri->withPath(substr($path, 0, -1));
if($request->getMethod() == 'GET') {
return $response->withRedirect((string)$uri, 301);
}
else {
return $next($request->withUri($uri), $response);
}
}
return $next($request, $response);
});
$app->get('/', function ($request, $response, $args) {
if ($_GET["theme"]) {
define("THEMEVIZ_THEME_PATH", realpath($_GET["theme"]));
$factory = new Factory();
/** @var App $tvApp */
$tvApp = $factory->get("App");
$tvApp->buildStyleGuide();
$buildUrl = "file://".THEMEVIZ_BASE_PATH."/build/styleGuide.html";
return $response->getBody()->write(
"Style guide compiled for theme:<br/>" .
THEMEVIZ_THEME_PATH .
"<br /><br /><a href='$buildUrl' target='_blank'>$buildUrl</a>"
);
}
return $response->getBody()->write(<<<DOC
<form method="get">
<input type="text" name="theme" placeholder="Theme Path" />
</form>
DOC
);
});
$app->get('/status', function ($request, $response, $args) {
return $response->getBody()->write("OK");
});
$app->run();