Browse Source

updated to auto-generate the index

master
Julio Biason 8 years ago
parent
commit
441c665fca
  1. 1
      cpp.html
  2. 119
      index.html
  3. 17
      makeidx.py

1
cpp.html

@ -52,6 +52,7 @@
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-background='_images/C++-unofficial.sh-600x600.png'>
<h1>C++</h1>
</section>
<section>

119
index.html

@ -25,6 +25,10 @@ div.thumb {
ul.inline-list li {
text-align: center;
}
div.record {
height: 110px;
}
</style>
</head>
@ -37,85 +41,54 @@ ul.inline-list li {
</ul>
</nav>
<!--
<div class='row'>
<div class='small-12 columns'>
<ul class='inline-list'>
<li><a href='pypoa.html'>
<div class='thumb' style='background-image:url("_images/poa.jpg")'></div>
PyPoa
</a></li>
<li><a href='rest.html'>
<div class='thumb' style='background-image:url("_images/Seascapeshd.png")'></div>
ReST
</a></li>
<li><a href='gitsvn.html'>
<div class='thumb' style='background-image:url("_images/Sketch27014711.png")'></div>
GIT-SVN
</a></li>
<li><a href='gitflow.html'>
<div class='thumb' style='background-image:url("_images/git-workflow-gitflow.png")'></div>
GIT Flow
</a></li>
<li><a href='python.html'>
<div class='thumb' style='background-image:url("_images/zen-of-python-poster-a3.png")'></div>
Python
</li>
<li><a href='flask.html'>
<div class='thumb' style='background-image:url("_images/flask.png")'></div>
Flask
</a></li>
<li><a href='gtg-hamster.html'>
<div class='thumb'></div>
GTG + Hamster
</a></li>
<li><a href='ajax-sosp-cors-csrf.html'>
<div class='thumb' style='background-image:url("_images/ajax-sosp-cors-csrf.png")'></div>
SOSP/CORS
</a></li>
<li><a href='pylint.html'>
<div class='thumb' style='background-image:url("_images/pylint.png")'></div>
Pylint
</a></li>
<li><a href='spa.html'>
<div class='thumb' style='background-image:url("_images/Eau_Rouge_1997.jpg")'></div>
SPA
</a></li>
<li><a href='noconflict.html'>
<div class='thumb' style='background-image:url("_images/jquery_noconflict.jpg")'></div>
$.noConflict()
</a></li>
<li><a href='tdc2015.html'>
<div class='thumb' style='background-image:url("_images/tdc-logo-post.png")'></div>
TDC Agile
</a></li>
<li><a href="django.html">
<div class="thumb" style='background-image:url("_images/django-allauth.png")'></div>
Ententendo Django
</a></li>
<li><a href="django-rest.html">
<div class="thumb" style='background-image:url("_images/django-rest.png")'></div>
Django REST Framework
</a></li>
</ul>
</div>
<div class="small-8 columns text-center">Title</div>
<div class="small-4 columns">Last Updated</div>
</div>
-->
<div id='presentations'></div>
<script src="_external/jquery.js"></script>
<script src="_external/foundation.min.js"></script>
<script>$(document).foundation();</script>
<div id='record' class='hide row record'>
<a href=''>
<div class="small-2 columns">
<div class="thumb"></div>
</div>
<div class="small-6 columns title"></div>
<div class="small-4 columns updated"></div>
</a>
</div>
<script type="text/javascript">
$(function() {
$.ajax({
url: 'index.json',
dataType: 'json',
}).done(function (data) {
var record;
for (var pos in data) {
record = data[pos];
console.log(record);
var template = $('#record').clone();
template.removeClass('hide');
template.removeAttr('id');
template.find('a').attr('href', record.presentation);
template.find('.thumb').css('background-image', 'url("' + record.image + '")');
template.find('.title').append(record.title);
template.find('.updated').append(record.changed);
$('#presentations').append(template);
}
})
})
</script>
</body>
</html>

17
makeidx.py

@ -11,7 +11,7 @@ import datetime
import json
DATA_BACKGROUND = re.compile(r"data-background='(.*?)'")
PRES_TITLE = re.compile(r"<h1>(.*?)</h1>")
PRES_TITLE = re.compile(r"<h1.*?>(.*?)</h1>")
def retrieve_presentation_info(filename):
@ -30,6 +30,12 @@ def retrieve_presentation_info(filename):
logging.debug('Image for %s = %s', filename, image.group(1))
logging.debug('Title for %s = %s', filename, title.group(1))
result = (image.group(1), title.group(1))
elif not content:
logging.debug('%s has no content', filename)
elif not image:
logging.debug('%s has no image', filename)
else:
logging.debug('%s has no title', filename)
return result
@ -37,8 +43,10 @@ def check_presentations(file_list):
"""Check if the any of the files in the file list are presentations."""
result = []
for filename in file_list:
logging.debug('-->')
if not filename.endswith('.html'):
# presentations are HTML only
logging.debug('%s ignored, not an HTML file', filename)
continue
(image, title) = retrieve_presentation_info(filename)
@ -47,9 +55,12 @@ def check_presentations(file_list):
date = datetime.datetime.fromtimestamp(stat_info.st_mtime)
logging.debug('Modified date = %s', date)
result.append({'title': title,
result.append({'presentation': filename,
'title': title,
'image': image,
'changed': date.strftime('%Y-%m-%d %H:%M:%S')})
else:
logging.debug('Missing information on %s', filename)
return result
@ -75,6 +86,8 @@ def main():
continue
content = check_presentations(files)
# holy shit, talk about abusing Python internals
content.sort(cmp=lambda x, y: -1 if x['title'] < y['title'] else 1)
with open('index.json', 'w') as output:
output.write(json.dumps(content))

Loading…
Cancel
Save