A brief history.
A glance at everything on one screen
Interesting slices of the election
But for context, not just flash news updates
For a sense of timeliness
Now we’re here
I’m so sorry.
We always build static websites.
How can you make a live website static?
Powered by our static site generating app template!
Regenerating static sites is slow, even on big servers.
slides = models.Slide.select()
slugs = [slide.slug for slide in slides if slide.slug not
in ['state-senate-results', 'state-house-results'] and not
slide.slug.startswith('tumblr')]
slides.database.close()
Parallel(n_jobs=NUM_CORES)(delayed(_render_results_slide)
(slug, output_path) for slug in slugs)
We might have built a library.
if (IS_CAST_RECEIVER) {
$newSlide.show();
setTimer();
}
else {
$newSlide.velocity('fadeIn', 800, setTimer);
}
html {
font-size:1vw;
}
body {
margin:0;
}
#stack {
box-sizing:border-box;
margin: 0 auto;
width: 100rem;
height: 56.25rem;
}
Everything else is in rems.
var onWindowResize = function(){
var aspect = window.innerWidth / window.innerHeight;
if ( aspect > 16/9) {
document.documentElement.style.fontSize = ((16/9) / aspect)
+ 'vw';
} else {
document.documentElement.style.fontSize = '1vw';
}
}
Generate a timestamp file locally:
def reset_browsers():
"""
Create a timestampped JSON file so the client will reset their page.
"""
payload = {}
# get current time and convert to epoch time
now = datetime.now().strftime('%s')
# set everything you want in the json file
payload['timestamp'] = now
with open('www/live-data/timestamp.json', 'w') as f:
json.dump(now, f)
deploy_json('www/live-data/timestamp.json', 'live-data/timestamp.json')
Poll the timestamp file on the client. If the timestamp changed, refresh the page:
var reloadTimestamp = null;
var getTimestamp = function() {
if (reloadTimestamp == null) {
checkTimestamp();
}
setInterval(checkTimestamp, 180000);
}
var checkTimestamp = function() {
$.ajax({
'url': '/live-data/timestamp.json',
'cache': false,
'success': function(data) {
var newTime = data['timestamp'];
if (reloadTimestamp == null) {
reloadTimestamp = newTime;
}
if (reloadTimestamp != newTime) {
$.cookie('reload', true);
window.location.reload(true);
}
}
});
}
$(document).ready(function)() {
getTimestamp();
if ($.cookie('reload')) {
$.removeCookie('reload');
}
});