Skip to content

Commit 0df7a7a

Browse files
author
Lawrence Chan
committed
Initial skeleton code
1 parent 5f88881 commit 0df7a7a

35 files changed

+12375
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "bottle"]
2+
path = bottle
3+
url = https://github.com/defnull/bottle.git

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dash.txt
2-
========
2+
========
3+
Super crude script to display text files as a web-based dashboard.

bottle

Submodule bottle added at e52b2be

bottle.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bottle/bottle.py

dash.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
3+
import re
4+
import bottle as btl
5+
6+
DIVIDER_RE = re.compile(r'^===+$')
7+
CHECKBOX_RE = re.compile(r'^\s*\[([^\]]*)\]\s*(\S.*)$')
8+
9+
@btl.route('/')
10+
def dash():
11+
with open(btl.request.app.path) as f:
12+
raw = f.read()
13+
lines = raw.splitlines()
14+
divider_idx = [i for i, l in enumerate(lines) if DIVIDER_RE.match(l)]
15+
categories = [lines[i - 1] for i in divider_idx]
16+
data = []
17+
for i in range(len(divider_idx)):
18+
cat = categories[i]
19+
if i >= len(divider_idx) - 1:
20+
rows = lines[(divider_idx[i] + 1):]
21+
else:
22+
rows = lines[(divider_idx[i] + 1):(divider_idx[i+1] - 1)]
23+
items = []
24+
for r in rows:
25+
if r.strip() == '':
26+
continue
27+
match = CHECKBOX_RE.match(r)
28+
done = False
29+
if not match:
30+
continue
31+
if match.group(1).strip() != '':
32+
done = True
33+
items.append((done, match.group(2)))
34+
data.append((categories[i], items))
35+
return btl.template('dash.tpl', data=data)
36+
37+
@btl.route('/static/<filepath:path>')
38+
def static(filepath):
39+
return btl.static_file(filepath, root='./static/')
40+
41+
def main(path, host='localhost', port=8080):
42+
app = btl.default_app()
43+
app.path = path
44+
btl.run(app=app, host=host, port=port, reloader=True)
45+
46+
if __name__ == '__main__':
47+
import argparse
48+
parser = argparse.ArgumentParser()
49+
parser.add_argument('path')
50+
parser.add_argument('--host', default='localhost')
51+
parser.add_argument('--port', default=8080)
52+
53+
args = parser.parse_args()
54+
main(**vars(args))

dash.tpl

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="/static/css/foundation.min.css"/>
5+
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
6+
<meta http-equiv="refresh" content="10"/>
7+
</head>
8+
<body>
9+
%for category, todos in data:
10+
<div class="row">
11+
<div class="twelve columns">
12+
<h4>{{ category }}</h4>
13+
</div>
14+
<div class="twelve columns">
15+
<dl class="nice vertical tabs">
16+
%for done, t in todos:
17+
<!--<div class="twelve columns">-->
18+
%if done:
19+
<dd class="done">{{ t }}</dd>
20+
%else:
21+
<dd class="pending">{{ t }}</dd>
22+
%end
23+
<!--</div>-->
24+
%end
25+
</dl>
26+
</div>
27+
</div>
28+
%end
29+
</body>
30+
</html>

static/css/foundation.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/css/style.css

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.blue {
2+
background-color: #2ba6cb;
3+
}
4+
5+
dl.tabs.vertical dd.done {
6+
color: #c0c0c0;
7+
}
8+
9+
dl.tabs.vertical dd.done:before {
10+
border-left: 5px solid #d0d0d0;
11+
}
12+
13+
dl.tabs.vertical dd.pending:before {
14+
border-left: 5px solid #2ba6cb;
15+
}
16+
17+
dl.tabs.vertical dd {
18+
/* background: #f2f2f2; */
19+
background: none;
20+
border: 1px solid #e6e6e6;
21+
border-width: 1px 1px 0 0;
22+
color: #555;
23+
display: block;
24+
font-size: 14px;
25+
height: auto;
26+
line-height: 1;
27+
padding: 15px 20px;
28+
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
29+
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
30+
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
31+
position: relative;
32+
}
33+
34+
dl.tabs.vertical dd:before {
35+
display:block;
36+
content:".";
37+
color:transparent;
38+
font-size:0;
39+
/* border-left:5px solid #f24495; */
40+
height:100%;
41+
position:absolute;
42+
left:0;
43+
padding:1px 0;
44+
top:-1px;
45+
bottom:-1px;
46+
}
658 Bytes
Loading
Loading
523 Bytes
Loading
2.55 KB
Loading
527 Bytes
Loading
289 Bytes
Loading
Loading
3.17 KB
Loading
537 Bytes
Loading
527 Bytes
Loading

static/js/app.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
;(function ($, window, undefined) {
2+
'use strict';
3+
4+
var $doc = $(document),
5+
Modernizr = window.Modernizr;
6+
7+
8+
$.fn.foundationAlerts ? $doc.foundationAlerts() : null;
9+
$.fn.foundationAccordion ? $doc.foundationAccordion() : null;
10+
$.fn.foundationTooltips ? $doc.foundationTooltips() : null;
11+
$('input, textarea').placeholder();
12+
13+
14+
$.fn.foundationButtons ? $doc.foundationButtons() : null;
15+
16+
17+
$.fn.foundationNavigation ? $doc.foundationNavigation() : null;
18+
19+
20+
$.fn.foundationTopBar ? $doc.foundationTopBar() : null;
21+
22+
$.fn.foundationCustomForms ? $doc.foundationCustomForms() : null;
23+
$.fn.foundationMediaQueryViewer ? $doc.foundationMediaQueryViewer() : null;
24+
25+
26+
$.fn.foundationTabs ? $doc.foundationTabs() : null;
27+
28+
29+
30+
$("#featured").orbit();
31+
32+
33+
// UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE8 SUPPORT AND ARE USING .block-grids
34+
// $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
35+
// $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
36+
// $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
37+
// $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
38+
39+
// Hide address bar on mobile devices
40+
if (Modernizr.touch) {
41+
$(window).load(function () {
42+
setTimeout(function () {
43+
window.scrollTo(0, 1);
44+
}, 0);
45+
});
46+
}
47+
48+
})(jQuery, this);

static/js/foundation.min.js

+71
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
;(function ($, window, undefined){
2+
'use strict';
3+
4+
$.fn.foundationAccordion = function (options) {
5+
6+
$('.accordion li', this).on('click.fndtn', function () {
7+
var p = $(this).parent(); //changed this
8+
var flyout = $(this).children('.content').first();
9+
$('.content', p).not(flyout).hide().parent('li').removeClass('active'); //changed this
10+
flyout.show(0, function () {
11+
flyout.parent('li').addClass('active');
12+
});
13+
});
14+
15+
};
16+
17+
})( jQuery, this );

static/js/jquery.foundation.alerts.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
;(function ($, window, undefined) {
2+
'use strict';
3+
4+
$.fn.foundationAlerts = function (options) {
5+
var settings = $.extend({
6+
callback: $.noop
7+
}, options);
8+
9+
$(document).on("click", ".alert-box a.close", function (e) {
10+
e.preventDefault();
11+
$(this).closest(".alert-box").fadeOut(function () {
12+
$(this).remove();
13+
// Do something else after the alert closes
14+
settings.callback();
15+
});
16+
});
17+
18+
};
19+
20+
})(jQuery, this);
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
;(function ($, window, undefined) {
2+
'use strict';
3+
4+
$.fn.foundationButtons = function(options) {
5+
var $doc = $(document);
6+
// Prevent event propagation on disabled buttons
7+
$doc.on('click.fndtn', '.button.disabled', function (e) {
8+
e.preventDefault();
9+
});
10+
11+
$('.button.dropdown > ul', this).addClass('no-hover');
12+
13+
$doc.on('click.fndtn', '.button.dropdown, .button.dropdown.split span', function (e) {
14+
// Stops further propagation of the event up the DOM tree when clicked on the button.
15+
// Events fired by its descendants are not being blocked.
16+
$('.button.dropdown').children('ul').removeClass('show-dropdown');
17+
if (e.target === this) {
18+
e.stopPropagation();
19+
}
20+
});
21+
22+
$doc.on('click.fndtn', '.button.dropdown.split span', function (e) {
23+
e.preventDefault();
24+
$('.button.dropdown', this).not($(this).parent()).children('ul').removeClass('show-dropdown');
25+
$(this).siblings('ul').toggleClass('show-dropdown');
26+
});
27+
28+
$doc.on('click.fndtn', '.button.dropdown:not(.split)', function (e) {
29+
$('.button.dropdown', this).not(this).children('ul').removeClass('show-dropdown');
30+
$(this).children('ul').toggleClass('show-dropdown');
31+
});
32+
33+
$doc.on('click.fndtn', 'body, html', function () {
34+
$('.button.dropdown ul').removeClass('show-dropdown');
35+
});
36+
37+
// Positioning the Flyout List
38+
var normalButtonHeight = $('.button.dropdown:not(.large):not(.small):not(.tiny)', this).outerHeight() - 1,
39+
largeButtonHeight = $('.button.large.dropdown', this).outerHeight() - 1,
40+
smallButtonHeight = $('.button.small.dropdown', this).outerHeight() - 1,
41+
tinyButtonHeight = $('.button.tiny.dropdown', this).outerHeight() - 1;
42+
43+
$('.button.dropdown:not(.large):not(.small):not(.tiny) > ul', this).css('top', normalButtonHeight);
44+
$('.button.dropdown.large > ul', this).css('top', largeButtonHeight);
45+
$('.button.dropdown.small > ul', this).css('top', smallButtonHeight);
46+
$('.button.dropdown.tiny > ul', this).css('top', tinyButtonHeight);
47+
48+
$('.button.dropdown.up:not(.large):not(.small):not(.tiny) > ul', this).css('top', 'auto').css('bottom', normalButtonHeight - 2);
49+
$('.button.dropdown.up.large > ul', this).css('top', 'auto').css('bottom', largeButtonHeight - 2);
50+
$('.button.dropdown.up.small > ul', this).css('top', 'auto').css('bottom', smallButtonHeight - 2);
51+
$('.button.dropdown.up.tiny > ul', this).css('top', 'auto').css('bottom', tinyButtonHeight - 2);
52+
53+
};
54+
55+
})( jQuery, this );

0 commit comments

Comments
 (0)