forked from newtoallofthis123/climb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
179 lines (157 loc) · 6.01 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/*
* Entry point for the ClimbUI application
*/
namespace ClimbUI;
use Approach\Render\HTML;
// disable errors
error_reporting(0);
global $body, $webpage;
require_once __DIR__ . '/support/lib/vendor/autoload.php';
$webpage = new HTML(tag: 'html');
$webpage->before = '<!DOCTYPE html>' . PHP_EOL;
$head = new HTML(tag: 'head');
$head[] = $pageTitle = new HTML(tag: 'title', content: 'ClimbUI');
$head[] = new HTML(tag: 'meta', attributes: [
'charset' => 'utf-8',
], selfContained: true);
$head[] = new HTML(tag: 'meta', attributes: [
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=edge',
], selfContained: true);
$head[] = new HTML(tag: 'meta', attributes: [
'name' => 'viewport',
'content' => 'width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0',
], selfContained: true);
$head[] = new HTML(tag: 'meta', attributes: [
'name' => 'author',
'content' => 'Ishan Joshi',
], selfContained: true);
// We will be using Bootstrap for the layout
$head[] = new HTML(tag: 'link', attributes: [
'rel' => 'stylesheet',
'href' => '//cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css',
], selfContained: true);
// Rest are some custom styles and scripts
$head[] = new HTML(tag: 'link', attributes: [
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => '/static/css/layout.css',
], selfContained: true);
$head[] = new HTML(tag: 'link', attributes: [
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => '/static/css/style.css',
], selfContained: true);
$head[] = new HTML(tag: 'link', attributes: [
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => '/static/css/reset.css',
], selfContained: true);
$head[] = new HTML(tag: 'link', attributes: [
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => '/static/css/menu.css',
], selfContained: true);
$head[] = $pageTitle;
$head[] = new HTML(tag: 'link', attributes: [
'href' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css',
'rel' => 'stylesheet',
], selfContained: true);
$head[] = new HTML(tag: 'link', attributes: [
'href' => 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css',
'rel' => 'stylesheet',
], selfContained: true);
// JQuery baby!!
$head[] = new HTML(tag: 'script', attributes: [
'src' => '//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js',
]);
// The actual approach library
$head[] = new HTML(tag: 'script', attributes: [
'type' => 'text/javascript',
'src' => '/static/js/approach/approach.interface.js',
]);
$head[] = new HTML(tag: 'script', attributes: [
'type' => 'text/javascript',
'src' => '/static/js/approach/approach.utility.js',
]);
$head[] = new HTML(tag: 'script', attributes: [
'src' => '/static/js/main.js',
'type' => 'module',
]);
$body = new HTML(tag: 'body');
$filename = __DIR__ . '/config.json';
$content = file_get_contents($filename);
$config = json_decode($content, true);
$repo = $config['CLIMBSUI_REPO'];
$owner = $config['CLIMBSUI_OWNER'];
$body->content = <<<HTML
<div class="Stage">
<div id="main" class="Screen">
<div class="Oyster Interface InterfaceContent controls">
<section class="header controls">
<button class="backBtn">
<div>
<i class="expand fa fa-angle-left"></i>
</div>
</button>
<button
class="controls btn breadcrumbDropper current-state ms-2"
id="menuButton"
>
<span id="menuButtonText"><span></span></span>
<i class="fa fa-caret-down"></i>
</button>
<ul class="breadcrumbs" style="display: none"></ul>
<span id="newButton">
<button
class="control btn btn-primary current-state ms-2"
data-api="/server.php"
data-api-method="POST"
data-intent='{ "REFRESH": { "Climb" : "New" } }'
data-context='{ "_response_target": "#content > div", "parent_id": "", "repo": "$repo", "owner": "$owner" }'
>
New
</button>
</span>
<span id="newTemplate">
</span>
</section>
<ul class="Toolbar controls">
<li>
<div class="visual control"
data-api="/server.php"
data-api-method="POST"
data-intent='{ "REFRESH": { "Climb" : "Menu" } }'
data-context='{ "_response_target": ".Toolbar > .active > ul", "owner": "$owner", "repo": "$repo"}'
>
<img src="/static/img/climb.svg" />
<label>Climb</label>
</div>
<ul></ul>
</li>
<li>
<button
class="control btn current-state ms-2"
data-api="/server.php"
data-api-method="POST"
data-intent='{ "REFRESH": { "Climb" : "Settings" } }'
data-context='{ "_response_target": "#content > div"}'
>
<i class="bi bi-gear"></i>
</button>
</li>
</ul>
</div>
<div class="Viewport">
<div id="content">
<div class="ClimbsUI"></div>
</div>
<div id="result"></div>
</div>
</div>
</div>
HTML;
$webpage[] = $head;
$webpage[] = $body;
echo $webpage->render();