Browse Source

Add GA; optimize a bit

master
sipp11 9 years ago
parent
commit
e648ead175
  1. 1
      .gitignore
  2. 31
      generate_static.py
  3. 1550
      in.html
  4. 1776
      index.html
  5. 9
      sync_to_mango.sh

1
.gitignore vendored

@ -0,0 +1 @@
*.html

31
generate_static.py

@ -13,7 +13,6 @@ HEADER = '''
<title>Traffy 73 tracker</title>
<meta name="description" content="Traffy" />
<meta name="keywords" content="traffy bus tracking 73" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300|Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://bus.traffy.xyz/build/css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
@ -54,6 +53,16 @@ FOOTER = '''
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-72505920-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
'''
@ -140,7 +149,7 @@ with open('index.html', 'w') as f:
prev_stop_id = j['prev_stop']['stop_id']
next_stop_id = j['next_stop']['stop_id']
print ' btw stop %s - %s -- ref = %s' % (prev_stop_id, next_stop_id, rel_ref)
# print ' btw stop %s - %s -- ref = %s' % (prev_stop_id, next_stop_id, rel_ref)
if rel_ref < 10:
stops[prev_stop_id]['at_stop'] = True
elif rel_ref > 90:
@ -155,11 +164,11 @@ with open('index.html', 'w') as f:
stop_id = stop['stop_id']
at_stop_text = ''
if stops[stop_id]['at_stop']:
print ' stop %s has %s bus at stop' % (stop_id, stops[stop_id]['at_stop'])
# print ' stop %s has %s bus at stop' % (stop_id, stops[stop_id]['at_stop'])
at_stop_text = '<i class="fa fa-bus"></i>'
running_text = ''
if stops[stop_id]['running']:
print ' stop %s has %s bus leaving' % (stop_id, stops[stop_id]['running'])
# print ' stop %s has %s bus leaving' % (stop_id, stops[stop_id]['running'])
running_text = GO
stop_data = {
'name': stop['name'],
@ -168,8 +177,8 @@ with open('index.html', 'w') as f:
}
s = STOP_TMPL % stop_data
if at_stop_text or running_text:
print s.encode('utf-8')
# if at_stop_text or running_text:
# print s.encode('utf-8')
content_.append(s)
ind += 1
@ -214,7 +223,7 @@ with open('in.html', 'w') as f:
prev_stop_id = j['prev_stop']['stop_id']
next_stop_id = j['next_stop']['stop_id']
print ' btw stop %s - %s -- ref = %s' % (prev_stop_id, next_stop_id, rel_ref)
# print ' btw stop %s - %s -- ref = %s' % (prev_stop_id, next_stop_id, rel_ref)
if rel_ref < 10:
stops[prev_stop_id]['at_stop'] = True
elif rel_ref > 90:
@ -229,11 +238,11 @@ with open('in.html', 'w') as f:
stop_id = stop['stop_id']
at_stop_text = ''
if stops[stop_id]['at_stop']:
print ' stop %s has %s bus at stop' % (stop_id, stops[stop_id]['at_stop'])
# print ' stop %s has %s bus at stop' % (stop_id, stops[stop_id]['at_stop'])
at_stop_text = '<i class="fa fa-bus"></i>'
running_text = ''
if stops[stop_id]['running']:
print ' stop %s has %s bus leaving' % (stop_id, stops[stop_id]['running'])
# print ' stop %s has %s bus leaving' % (stop_id, stops[stop_id]['running'])
running_text = GO
stop_data = {
'name': stop['name'],
@ -242,8 +251,8 @@ with open('in.html', 'w') as f:
}
s = STOP_TMPL % stop_data
if at_stop_text or running_text:
print s.encode('utf-8')
# if at_stop_text or running_text:
# print s.encode('utf-8')
content_.append(s)
ind += 1

1550
in.html

File diff suppressed because it is too large Load Diff

1776
index.html

File diff suppressed because it is too large Load Diff

9
sync_to_mango.sh

@ -0,0 +1,9 @@
#!/bin/sh
RUSER=sipp11
RHOST=mango-its
PORT=22
RPATH=/opt/www/public/transit
LPATH=./
rsync -avu -e "ssh -p $PORT" $LPATH $RUSER@$RHOST:$RPATH \
--exclude=node_modules --exclude=.git \
--exclude=*.sh --exclude=.DS_Store
Loading…
Cancel
Save