-
Notifications
You must be signed in to change notification settings - Fork 7
/
repository.php
80 lines (69 loc) · 1.95 KB
/
repository.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
require_once('internal/app.php');
// redirect to login form
if ( ! \obo\API::getInstance()->getSessionValid())
{
header("Location: /repository-login.php");
exit;
}
// default file locations
$cdn_scripts = [
'react.js' => '//unpkg.com/react@16.14.0/umd/react.development.js',
'react-dom.js' => '//unpkg.com/react-dom@16.14.0/umd/react-dom.development.js',
];
$cdn_scripts_production = [
'react.js' => 'https://unpkg.com/react@16.14.0/umd/react.production.min.js',
'react-dom.js' => 'https://unpkg.com/react-dom@16.14.0/umd/react-dom.production.min.js',
];
$css = [
'fonts' => 'https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i,900,900i|Roboto+Mono:400,400i,700,700i|Noto+Serif:400,400i,700,700i',
'repository.css' => '/assets/dist/repository.css',
];
$js = [
'repository.js' => '/assets/dist/repository.js',
];
// load manifest generated by webpack, override defaults
$manifest_path = __DIR__.'/assets/dist/manifest.json';
if(file_exists($manifest_path)){
// assume we're no long in dev, use production cdn scripts
$cdn_scripts = $cdn_scripts_production;
$manifest_contents = file_get_contents(__DIR__.'/assets/dist/manifest.json');
$manifest = json_decode($manifest_contents, true);
// move css files over to $css key
foreach($manifest as $key => $value)
{
$endswith = substr($key, -3);
switch($endswith){
case 'css':
$css[$key] = $value;
break;
case '.js':
$js[$key] = $value;
break;
}
}
}
?><!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Repository | Obojobo™</title>
<?php
foreach($css as $file){
echo "<link href=\"{$file}\" rel=\"stylesheet\" crossorigin=\"anonymous\" media=\"all\" />";
}
?>
</head>
<body>
<div id="react-app"></div>
<div id="react-dialog"></div>
<?php
foreach($cdn_scripts as $cdn){
echo "<script src=\"{$cdn}\"></script>";
}
foreach($js as $file){
echo "<script src=\"{$file}\"></script>";
}
?>
</body>
</html>