nofxx-god_web 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Rakefile +50 -0
- data/Readme.textile +82 -0
- data/VERSION +1 -0
- data/bin/god_web +11 -0
- data/bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml +18 -0
- data/bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml +18 -0
- data/bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml +18 -0
- data/bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml +18 -0
- data/bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml +18 -0
- data/bugs/project.yaml +16 -0
- data/god_web.gemspec +109 -0
- data/lib/app.rb +56 -0
- data/lib/environment.rb +28 -0
- data/lib/god_web.rb +197 -0
- data/lib/sinatra_http_auth.rb +53 -0
- data/public/.DS_Store +0 -0
- data/public/app.css +30 -0
- data/public/icons/databases.png +0 -0
- data/public/icons/gear.png +0 -0
- data/public/icons/groups.png +0 -0
- data/public/icons/key.png +0 -0
- data/public/icons/monitor.png +0 -0
- data/public/icons/restart.png +0 -0
- data/public/icons/ruby.png +0 -0
- data/public/icons/server.png +0 -0
- data/public/icons/start.png +0 -0
- data/public/icons/stop.png +0 -0
- data/public/icons/terminal.png +0 -0
- data/public/icons/unmonitor.png +0 -0
- data/public/icons/unmonitored.png +0 -0
- data/public/icons/unmonitored_old.png +0 -0
- data/public/icons/up.png +0 -0
- data/public/icons/warn.png +0 -0
- data/public/icons/wrench.png +0 -0
- data/public/iui/backButton.png +0 -0
- data/public/iui/blueButton.png +0 -0
- data/public/iui/cancel.png +0 -0
- data/public/iui/grayButton.png +0 -0
- data/public/iui/iui-logo-touch-icon.png +0 -0
- data/public/iui/iui.css +396 -0
- data/public/iui/iui.js +510 -0
- data/public/iui/iuix.css +1 -0
- data/public/iui/iuix.js +1 -0
- data/public/iui/listArrow.png +0 -0
- data/public/iui/listArrowSel.png +0 -0
- data/public/iui/listGroup.png +0 -0
- data/public/iui/loading.gif +0 -0
- data/public/iui/pinstripes.png +0 -0
- data/public/iui/redButton.png +0 -0
- data/public/iui/selection.png +0 -0
- data/public/iui/thumb.png +0 -0
- data/public/iui/toggle.png +0 -0
- data/public/iui/toggleOn.png +0 -0
- data/public/iui/toolButton.png +0 -0
- data/public/iui/toolbar.png +0 -0
- data/public/iui/whiteButton.png +0 -0
- data/spec/god_web_spec.rb +46 -0
- data/spec/spec_helper.rb +11 -0
- data/views/command.erb +4 -0
- data/views/status.erb +30 -0
- data/views/watch.erb +10 -0
- metadata +146 -0
data/public/iui/iui.js
ADDED
@@ -0,0 +1,510 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2007-9, iUI Project Members
|
3
|
+
See LICENSE.txt for licensing terms
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
|
9
|
+
var slideSpeed = 20;
|
10
|
+
var slideInterval = 0;
|
11
|
+
|
12
|
+
var currentPage = null;
|
13
|
+
var currentDialog = null;
|
14
|
+
var currentWidth = 0;
|
15
|
+
var currentHash = location.hash;
|
16
|
+
var hashPrefix = "#_";
|
17
|
+
var pageHistory = [];
|
18
|
+
var newPageCount = 0;
|
19
|
+
var checkTimer;
|
20
|
+
var hasOrientationEvent = false;
|
21
|
+
var portraitVal = "portrait";
|
22
|
+
var landscapeVal = "landscape";
|
23
|
+
|
24
|
+
// *************************************************************************************************
|
25
|
+
|
26
|
+
window.iui =
|
27
|
+
{
|
28
|
+
animOn: false, // Experimental slide animation with CSS transition disabled by default
|
29
|
+
|
30
|
+
showPage: function(page, backwards)
|
31
|
+
{
|
32
|
+
if (page)
|
33
|
+
{
|
34
|
+
if (currentDialog)
|
35
|
+
{
|
36
|
+
currentDialog.removeAttribute("selected");
|
37
|
+
currentDialog = null;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (hasClass(page, "dialog"))
|
41
|
+
showDialog(page);
|
42
|
+
else
|
43
|
+
{
|
44
|
+
var fromPage = currentPage;
|
45
|
+
currentPage = page;
|
46
|
+
|
47
|
+
if (fromPage)
|
48
|
+
setTimeout(slidePages, 0, fromPage, page, backwards);
|
49
|
+
else
|
50
|
+
updatePage(page, fromPage);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
},
|
54
|
+
|
55
|
+
showPageById: function(pageId)
|
56
|
+
{
|
57
|
+
var page = $(pageId);
|
58
|
+
if (page)
|
59
|
+
{
|
60
|
+
var index = pageHistory.indexOf(pageId);
|
61
|
+
var backwards = index != -1;
|
62
|
+
if (backwards)
|
63
|
+
pageHistory.splice(index, pageHistory.length);
|
64
|
+
|
65
|
+
iui.showPage(page, backwards);
|
66
|
+
}
|
67
|
+
},
|
68
|
+
|
69
|
+
showPageByHref: function(href, args, method, replace, cb)
|
70
|
+
{
|
71
|
+
var req = new XMLHttpRequest();
|
72
|
+
req.onerror = function()
|
73
|
+
{
|
74
|
+
if (cb)
|
75
|
+
cb(false);
|
76
|
+
};
|
77
|
+
|
78
|
+
req.onreadystatechange = function()
|
79
|
+
{
|
80
|
+
if (req.readyState == 4)
|
81
|
+
{
|
82
|
+
if (replace)
|
83
|
+
replaceElementWithSource(replace, req.responseText);
|
84
|
+
else
|
85
|
+
{
|
86
|
+
var frag = document.createElement("div");
|
87
|
+
frag.innerHTML = req.responseText;
|
88
|
+
iui.insertPages(frag.childNodes);
|
89
|
+
}
|
90
|
+
if (cb)
|
91
|
+
setTimeout(cb, 1000, true);
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
if (args)
|
96
|
+
{
|
97
|
+
req.open(method || "GET", href, true);
|
98
|
+
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
99
|
+
req.setRequestHeader("Content-Length", args.length);
|
100
|
+
req.send(args.join("&"));
|
101
|
+
}
|
102
|
+
else
|
103
|
+
{
|
104
|
+
req.open(method || "GET", href, true);
|
105
|
+
req.send(null);
|
106
|
+
}
|
107
|
+
},
|
108
|
+
|
109
|
+
insertPages: function(nodes)
|
110
|
+
{
|
111
|
+
var targetPage;
|
112
|
+
for (var i = 0; i < nodes.length; ++i)
|
113
|
+
{
|
114
|
+
var child = nodes[i];
|
115
|
+
if (child.nodeType == 1)
|
116
|
+
{
|
117
|
+
if (!child.id)
|
118
|
+
child.id = "__" + (++newPageCount) + "__";
|
119
|
+
|
120
|
+
var clone = $(child.id);
|
121
|
+
if (clone)
|
122
|
+
clone.parentNode.replaceChild(child, clone);
|
123
|
+
else
|
124
|
+
document.body.appendChild(child);
|
125
|
+
|
126
|
+
if (child.getAttribute("selected") == "true" || !targetPage)
|
127
|
+
targetPage = child;
|
128
|
+
|
129
|
+
--i;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
if (targetPage)
|
134
|
+
iui.showPage(targetPage);
|
135
|
+
},
|
136
|
+
|
137
|
+
getSelectedPage: function()
|
138
|
+
{
|
139
|
+
for (var child = document.body.firstChild; child; child = child.nextSibling)
|
140
|
+
{
|
141
|
+
if (child.nodeType == 1 && child.getAttribute("selected") == "true")
|
142
|
+
return child;
|
143
|
+
}
|
144
|
+
},
|
145
|
+
isNativeUrl: function(href)
|
146
|
+
{
|
147
|
+
for(var i = 0; i < iui.nativeUrlPatterns.length; i++)
|
148
|
+
{
|
149
|
+
if(href.match(iui.nativeUrlPatterns[i])) return true;
|
150
|
+
}
|
151
|
+
return false;
|
152
|
+
},
|
153
|
+
nativeUrlPatterns: [
|
154
|
+
new RegExp("^http:\/\/maps.google.com\/maps\?"),
|
155
|
+
new RegExp("^mailto:"),
|
156
|
+
new RegExp("^tel:"),
|
157
|
+
new RegExp("^http:\/\/www.youtube.com\/watch\\?v="),
|
158
|
+
new RegExp("^http:\/\/www.youtube.com\/v\/"),
|
159
|
+
new RegExp("^javascript:"),
|
160
|
+
|
161
|
+
]
|
162
|
+
};
|
163
|
+
|
164
|
+
// *************************************************************************************************
|
165
|
+
|
166
|
+
addEventListener("load", function(event)
|
167
|
+
{
|
168
|
+
var page = iui.getSelectedPage();
|
169
|
+
var locPage = getPageFromLoc();
|
170
|
+
|
171
|
+
if (page)
|
172
|
+
iui.showPage(page);
|
173
|
+
|
174
|
+
if (locPage && (locPage != page))
|
175
|
+
iui.showPage(locPage);
|
176
|
+
|
177
|
+
setTimeout(preloadImages, 0);
|
178
|
+
if (typeof window.onorientationchange == "object")
|
179
|
+
{
|
180
|
+
window.onorientationchange=orientChangeHandler;
|
181
|
+
hasOrientationEvent = true;
|
182
|
+
setTimeout(orientChangeHandler, 0);
|
183
|
+
}
|
184
|
+
setTimeout(checkOrientAndLocation, 0);
|
185
|
+
checkTimer = setInterval(checkOrientAndLocation, 300);
|
186
|
+
}, false);
|
187
|
+
|
188
|
+
addEventListener("unload", function(event)
|
189
|
+
{
|
190
|
+
return;
|
191
|
+
}, false);
|
192
|
+
|
193
|
+
addEventListener("click", function(event)
|
194
|
+
{
|
195
|
+
var link = findParent(event.target, "a");
|
196
|
+
if (link)
|
197
|
+
{
|
198
|
+
function unselect() { link.removeAttribute("selected"); }
|
199
|
+
|
200
|
+
if (link.href && link.hash && link.hash != "#" && !link.target)
|
201
|
+
{
|
202
|
+
link.setAttribute("selected", "true");
|
203
|
+
iui.showPage($(link.hash.substr(1)));
|
204
|
+
setTimeout(unselect, 500);
|
205
|
+
}
|
206
|
+
else if (link == $("backButton"))
|
207
|
+
history.back();
|
208
|
+
else if (link.getAttribute("type") == "submit")
|
209
|
+
submitForm(findParent(link, "form"));
|
210
|
+
else if (link.getAttribute("type") == "cancel")
|
211
|
+
cancelDialog(findParent(link, "form"));
|
212
|
+
else if (link.target == "_replace")
|
213
|
+
{
|
214
|
+
link.setAttribute("selected", "progress");
|
215
|
+
iui.showPageByHref(link.href, null, null, link, unselect);
|
216
|
+
}
|
217
|
+
else if (iui.isNativeUrl(link.href))
|
218
|
+
{
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
else if (link.target == "_webapp")
|
222
|
+
{
|
223
|
+
location.href = link.href;
|
224
|
+
}
|
225
|
+
else if (!link.target)
|
226
|
+
{
|
227
|
+
link.setAttribute("selected", "progress");
|
228
|
+
iui.showPageByHref(link.href, null, null, null, unselect);
|
229
|
+
}
|
230
|
+
else
|
231
|
+
return;
|
232
|
+
|
233
|
+
event.preventDefault();
|
234
|
+
}
|
235
|
+
}, true);
|
236
|
+
|
237
|
+
addEventListener("click", function(event)
|
238
|
+
{
|
239
|
+
var div = findParent(event.target, "div");
|
240
|
+
if (div && hasClass(div, "toggle"))
|
241
|
+
{
|
242
|
+
div.setAttribute("toggled", div.getAttribute("toggled") != "true");
|
243
|
+
event.preventDefault();
|
244
|
+
}
|
245
|
+
}, true);
|
246
|
+
|
247
|
+
function getPageFromLoc()
|
248
|
+
{
|
249
|
+
var page;
|
250
|
+
var result = location.hash.match(/#_([^\?_]+)/);
|
251
|
+
if (result)
|
252
|
+
page = result[1];
|
253
|
+
if (page)
|
254
|
+
page = $(page);
|
255
|
+
return page;
|
256
|
+
}
|
257
|
+
|
258
|
+
function orientChangeHandler()
|
259
|
+
{
|
260
|
+
var orientation=window.orientation;
|
261
|
+
switch(orientation)
|
262
|
+
{
|
263
|
+
case 0:
|
264
|
+
setOrientation(portraitVal);
|
265
|
+
break;
|
266
|
+
|
267
|
+
case 90:
|
268
|
+
case -90:
|
269
|
+
setOrientation(landscapeVal);
|
270
|
+
break;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
function checkOrientAndLocation()
|
276
|
+
{
|
277
|
+
if (!hasOrientationEvent)
|
278
|
+
{
|
279
|
+
if (window.innerWidth != currentWidth)
|
280
|
+
{
|
281
|
+
currentWidth = window.innerWidth;
|
282
|
+
var orient = currentWidth == 320 ? portraitVal : landscapeVal;
|
283
|
+
setOrientation(orient);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
if (location.hash != currentHash)
|
288
|
+
{
|
289
|
+
var pageId = location.hash.substr(hashPrefix.length);
|
290
|
+
iui.showPageById(pageId);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
function setOrientation(orient)
|
295
|
+
{
|
296
|
+
document.body.setAttribute("orient", orient);
|
297
|
+
setTimeout(scrollTo, 100, 0, 1);
|
298
|
+
}
|
299
|
+
|
300
|
+
function showDialog(page)
|
301
|
+
{
|
302
|
+
currentDialog = page;
|
303
|
+
page.setAttribute("selected", "true");
|
304
|
+
|
305
|
+
if (hasClass(page, "dialog") && !page.target)
|
306
|
+
showForm(page);
|
307
|
+
}
|
308
|
+
|
309
|
+
function showForm(form)
|
310
|
+
{
|
311
|
+
form.onsubmit = function(event)
|
312
|
+
{
|
313
|
+
event.preventDefault();
|
314
|
+
submitForm(form);
|
315
|
+
};
|
316
|
+
|
317
|
+
form.onclick = function(event)
|
318
|
+
{
|
319
|
+
if (event.target == form && hasClass(form, "dialog"))
|
320
|
+
cancelDialog(form);
|
321
|
+
};
|
322
|
+
}
|
323
|
+
|
324
|
+
function cancelDialog(form)
|
325
|
+
{
|
326
|
+
form.removeAttribute("selected");
|
327
|
+
}
|
328
|
+
|
329
|
+
function updatePage(page, fromPage)
|
330
|
+
{
|
331
|
+
if (!page.id)
|
332
|
+
page.id = "__" + (++newPageCount) + "__";
|
333
|
+
|
334
|
+
location.hash = currentHash = hashPrefix + page.id;
|
335
|
+
pageHistory.push(page.id);
|
336
|
+
|
337
|
+
var pageTitle = $("pageTitle");
|
338
|
+
if (page.title)
|
339
|
+
pageTitle.innerHTML = page.title;
|
340
|
+
|
341
|
+
if (page.localName.toLowerCase() == "form" && !page.target)
|
342
|
+
showForm(page);
|
343
|
+
|
344
|
+
var backButton = $("backButton");
|
345
|
+
if (backButton)
|
346
|
+
{
|
347
|
+
var prevPage = $(pageHistory[pageHistory.length-2]);
|
348
|
+
if (prevPage && !page.getAttribute("hideBackButton"))
|
349
|
+
{
|
350
|
+
backButton.style.display = "inline";
|
351
|
+
backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
|
352
|
+
}
|
353
|
+
else
|
354
|
+
backButton.style.display = "none";
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
function slidePages(fromPage, toPage, backwards)
|
359
|
+
{
|
360
|
+
var axis = (backwards ? fromPage : toPage).getAttribute("axis");
|
361
|
+
|
362
|
+
clearInterval(checkTimer);
|
363
|
+
|
364
|
+
if (canDoSlideAnim() && axis != 'y')
|
365
|
+
{
|
366
|
+
slide2(fromPage, toPage, backwards, slideDone);
|
367
|
+
}
|
368
|
+
else
|
369
|
+
{
|
370
|
+
slide1(fromPage, toPage, backwards, axis, slideDone);
|
371
|
+
}
|
372
|
+
|
373
|
+
function slideDone()
|
374
|
+
{
|
375
|
+
if (!hasClass(toPage, "dialog"))
|
376
|
+
fromPage.removeAttribute("selected");
|
377
|
+
checkTimer = setInterval(checkOrientAndLocation, 300);
|
378
|
+
setTimeout(updatePage, 0, toPage, fromPage);
|
379
|
+
fromPage.removeEventListener('webkitTransitionEnd', slideDone, false);
|
380
|
+
}
|
381
|
+
}
|
382
|
+
|
383
|
+
function canDoSlideAnim()
|
384
|
+
{
|
385
|
+
return (iui.animOn) && (typeof WebKitCSSMatrix == "object");
|
386
|
+
}
|
387
|
+
|
388
|
+
function slide1(fromPage, toPage, backwards, axis, cb)
|
389
|
+
{
|
390
|
+
if (axis == "y")
|
391
|
+
(backwards ? fromPage : toPage).style.top = "100%";
|
392
|
+
else
|
393
|
+
toPage.style.left = "100%";
|
394
|
+
|
395
|
+
scrollTo(0, 1);
|
396
|
+
toPage.setAttribute("selected", "true");
|
397
|
+
var percent = 100;
|
398
|
+
slide();
|
399
|
+
var timer = setInterval(slide, slideInterval);
|
400
|
+
|
401
|
+
function slide()
|
402
|
+
{
|
403
|
+
percent -= slideSpeed;
|
404
|
+
if (percent <= 0)
|
405
|
+
{
|
406
|
+
percent = 0;
|
407
|
+
clearInterval(timer);
|
408
|
+
cb();
|
409
|
+
}
|
410
|
+
|
411
|
+
if (axis == "y")
|
412
|
+
{
|
413
|
+
backwards
|
414
|
+
? fromPage.style.top = (100-percent) + "%"
|
415
|
+
: toPage.style.top = percent + "%";
|
416
|
+
}
|
417
|
+
else
|
418
|
+
{
|
419
|
+
fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%";
|
420
|
+
toPage.style.left = (backwards ? -percent : percent) + "%";
|
421
|
+
}
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
function slide2(fromPage, toPage, backwards, cb)
|
427
|
+
{
|
428
|
+
toPage.style.webkitTransitionDuration = '0ms'; // Turn off transitions to set toPage start offset
|
429
|
+
// fromStart is always 0% and toEnd is always 0%
|
430
|
+
// iPhone won't take % width on toPage
|
431
|
+
var toStart = 'translateX(' + (backwards ? '-' : '') + window.innerWidth + 'px)';
|
432
|
+
var fromEnd = 'translateX(' + (backwards ? '100%' : '-100%') + ')';
|
433
|
+
toPage.style.webkitTransform = toStart;
|
434
|
+
toPage.setAttribute("selected", "true");
|
435
|
+
toPage.style.webkitTransitionDuration = ''; // Turn transitions back on
|
436
|
+
function startTrans()
|
437
|
+
{
|
438
|
+
fromPage.style.webkitTransform = fromEnd;
|
439
|
+
toPage.style.webkitTransform = 'translateX(0%)'; //toEnd
|
440
|
+
}
|
441
|
+
fromPage.addEventListener('webkitTransitionEnd', cb, false);
|
442
|
+
setTimeout(startTrans, 0);
|
443
|
+
}
|
444
|
+
|
445
|
+
function preloadImages()
|
446
|
+
{
|
447
|
+
var preloader = document.createElement("div");
|
448
|
+
preloader.id = "preloader";
|
449
|
+
document.body.appendChild(preloader);
|
450
|
+
}
|
451
|
+
|
452
|
+
function submitForm(form)
|
453
|
+
{
|
454
|
+
iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
|
455
|
+
}
|
456
|
+
|
457
|
+
function encodeForm(form)
|
458
|
+
{
|
459
|
+
function encode(inputs)
|
460
|
+
{
|
461
|
+
for (var i = 0; i < inputs.length; ++i)
|
462
|
+
{
|
463
|
+
if (inputs[i].name)
|
464
|
+
args.push(inputs[i].name + "=" + escape(inputs[i].value));
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
var args = [];
|
469
|
+
encode(form.getElementsByTagName("input"));
|
470
|
+
encode(form.getElementsByTagName("textarea"));
|
471
|
+
encode(form.getElementsByTagName("select"));
|
472
|
+
return args;
|
473
|
+
}
|
474
|
+
|
475
|
+
function findParent(node, localName)
|
476
|
+
{
|
477
|
+
while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
|
478
|
+
node = node.parentNode;
|
479
|
+
return node;
|
480
|
+
}
|
481
|
+
|
482
|
+
function hasClass(self, name)
|
483
|
+
{
|
484
|
+
var re = new RegExp("(^|\\s)"+name+"($|\\s)");
|
485
|
+
return re.exec(self.getAttribute("class")) != null;
|
486
|
+
}
|
487
|
+
|
488
|
+
function replaceElementWithSource(replace, source)
|
489
|
+
{
|
490
|
+
var page = replace.parentNode;
|
491
|
+
var parent = replace;
|
492
|
+
while (page.parentNode != document.body)
|
493
|
+
{
|
494
|
+
page = page.parentNode;
|
495
|
+
parent = parent.parentNode;
|
496
|
+
}
|
497
|
+
|
498
|
+
var frag = document.createElement(parent.localName);
|
499
|
+
frag.innerHTML = source;
|
500
|
+
|
501
|
+
page.removeChild(parent);
|
502
|
+
|
503
|
+
while (frag.firstChild)
|
504
|
+
page.appendChild(frag.firstChild);
|
505
|
+
}
|
506
|
+
|
507
|
+
function $(id) { return document.getElementById(id); }
|
508
|
+
function ddd() { console.log.apply(console, arguments); }
|
509
|
+
|
510
|
+
})();
|