haha! commit
This commit is contained in:
parent
a5dab2ea2c
commit
85bfef926c
BIN
+++/jules-henri.ico
Normal file
BIN
+++/jules-henri.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 798 B |
57
+++/lestyle.css
Normal file
57
+++/lestyle.css
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tableau {
|
||||||
|
border: 10px grey ridge;
|
||||||
|
margin: 5em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
display: block;
|
||||||
|
margin: 1em;
|
||||||
|
border: 10px grey ridge;
|
||||||
|
font-size: small;
|
||||||
|
text-align: left;
|
||||||
|
width: 55em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
border: 2px grey ridge;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td img {
|
||||||
|
width: 20em;
|
||||||
|
border: 2px grey ridge;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lst ul li { display: inline; }
|
||||||
|
|
||||||
|
.lst ul li img {
|
||||||
|
border: 10px grey ridge;
|
||||||
|
margin: 2em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
width: 450;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lst ul li video {
|
||||||
|
border: 10px grey ridge;
|
||||||
|
margin: 2em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
width: 450;
|
||||||
|
}
|
||||||
|
|
||||||
|
address {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#index_tile h1 {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BIN
+++/yeux.png
Normal file
BIN
+++/yeux.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
+++/*.jpg
|
||||||
|
+++/*.pdf
|
||||||
|
+++/Screen-Shot-2014-05-26-at-20.40.24-b.png
|
||||||
10
<table>
Normal file
10
<table>
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
[[text_md]]
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
[[link_md]]
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
@ -1,2 +1,2 @@
|
|||||||
# __sssstatic
|
|
||||||
__sssstatic __sssstatic __sssstatic __sssstatic
|
__sssstatic __sssstatic __sssstatic __sssstatic
|
||||||
|
|
||||||
|
|||||||
207
gen.py
Normal file
207
gen.py
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys, os, string, markdown, argparse, shutil, json, glob, re
|
||||||
|
from distutils import dir_util as dirutil
|
||||||
|
|
||||||
|
arg_parser = argparse.ArgumentParser(description='Generates html file accroding to directory content');
|
||||||
|
|
||||||
|
input_dir = '../content/';
|
||||||
|
output_dir = '../deploy/';
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
global input_dir, output_dir, clean
|
||||||
|
arg_parser.add_argument('--input', help='input directory');
|
||||||
|
arg_parser.add_argument('--output', help='output directory');
|
||||||
|
arg_parser.add_argument('--clean', help='cleans the output directory');
|
||||||
|
args = arg_parser.parse_args();
|
||||||
|
if args.input and os.path.isdir(args.input):
|
||||||
|
input_dir = args.input;
|
||||||
|
if args.output and os.path.isdir(args.output):
|
||||||
|
output_dir = args.output;
|
||||||
|
|
||||||
|
def translate(txt, dirname):
|
||||||
|
try:
|
||||||
|
table = open(os.path.join('.', '<table>'), 'r+');
|
||||||
|
except:
|
||||||
|
print('error opening <table> file. aborting...');
|
||||||
|
sys.exit(0);
|
||||||
|
|
||||||
|
[text, link] = txt.split('- - -');
|
||||||
|
text_md = markdown.markdown(text);
|
||||||
|
link_md = markdown.markdown(link);
|
||||||
|
|
||||||
|
# revise this - perhaps with a better
|
||||||
|
link_md = link_md.replace('data/', dirname + '/');
|
||||||
|
|
||||||
|
out = table.read().replace('[[text_md]]', text_md);
|
||||||
|
return out.replace('[[link_md]]', link_md);
|
||||||
|
|
||||||
|
def escape_date(dirname):
|
||||||
|
return re.sub('^20\d{2}?.', '', dirname)
|
||||||
|
|
||||||
|
def emit_img(file):
|
||||||
|
return '<a href="' + file + '"><img src="' + file + '" /></a>'
|
||||||
|
|
||||||
|
def emit_video_mp4(file):
|
||||||
|
return '<video controls><source src="' + file + '" type="video/mp4"</video>'
|
||||||
|
|
||||||
|
def default(file):
|
||||||
|
return None;
|
||||||
|
|
||||||
|
content_map = {
|
||||||
|
'.png': emit_img,
|
||||||
|
'.jpg': emit_img,
|
||||||
|
'.m4v': emit_video_mp4,
|
||||||
|
'.mov': emit_video_mp4,
|
||||||
|
'.html': default,
|
||||||
|
'.txt': default
|
||||||
|
};
|
||||||
|
|
||||||
|
def index_content(dir_name, data_dir, index_txt, template):
|
||||||
|
|
||||||
|
# index_txt is a json file containing one thing:
|
||||||
|
# an array of files names or glob patterns
|
||||||
|
|
||||||
|
print " indexing content -- " + dir_name;
|
||||||
|
|
||||||
|
try:
|
||||||
|
index_file = open(index_txt, 'r+');
|
||||||
|
content_index = json.loads(index_file.read());
|
||||||
|
except:
|
||||||
|
print "error opening index: " + index_txt;
|
||||||
|
return;
|
||||||
|
|
||||||
|
files = [];
|
||||||
|
for i in content_index:
|
||||||
|
f = os.path.join(data_dir, i);
|
||||||
|
if os.path.isfile(f):
|
||||||
|
files.append(i);
|
||||||
|
else:
|
||||||
|
files += [os.path.basename(a) for a in glob.glob(f)];
|
||||||
|
|
||||||
|
content = ""
|
||||||
|
for j in files:
|
||||||
|
x, ext = os.path.splitext(j);
|
||||||
|
element = content_map[ext](j);
|
||||||
|
if element:
|
||||||
|
content += "<li>" + content_map[ext](j) + "</li>" + "\n";
|
||||||
|
|
||||||
|
#print content
|
||||||
|
|
||||||
|
html = template.replace('[[content]]', content).replace('[[dir]]', dir_name);
|
||||||
|
|
||||||
|
#print html
|
||||||
|
|
||||||
|
#check if <Project Name>.txt exists (description file)
|
||||||
|
f = os.path.join(data_dir, "*.txt");
|
||||||
|
txt_files = [a for a in [os.path.basename(a) for a in glob.glob(f)] if a != 'index.txt'];
|
||||||
|
if len(txt_files) == 1:
|
||||||
|
fn = txt_files[0];
|
||||||
|
link = '<li><a href="' + fn + '">' + fn + '</a></li>';
|
||||||
|
html = html.replace('<!--[[info]]-->', link);
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
out = open(os.path.join(data_dir, 'index.html'), 'w');
|
||||||
|
out.write(html);
|
||||||
|
out.close();
|
||||||
|
except:
|
||||||
|
print('error creating content index output file. aborting...');
|
||||||
|
sys.exit(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
#fix python markdown utf8 nonsense
|
||||||
|
reload(sys);
|
||||||
|
sys.setdefaultencoding('utf8');
|
||||||
|
|
||||||
|
parse_args();
|
||||||
|
|
||||||
|
print '1/3 - Configuring';
|
||||||
|
|
||||||
|
# main index template
|
||||||
|
try:
|
||||||
|
template = open(os.path.join('.', 'index_template.html'), 'r+');
|
||||||
|
except:
|
||||||
|
print('error opening template file. aborting...');
|
||||||
|
sys.exit(0);
|
||||||
|
|
||||||
|
# images index template
|
||||||
|
try:
|
||||||
|
content_indx_template = open(os.path.join('.', 'index_apache_template.html'), 'r+');
|
||||||
|
content_index_template_str = content_indx_template.read();
|
||||||
|
except:
|
||||||
|
print('error opening template file. aborting...');
|
||||||
|
sys.exit(0);
|
||||||
|
|
||||||
|
if not os.path.exists(output_dir):
|
||||||
|
os.mkdir(output_dir);
|
||||||
|
|
||||||
|
try:
|
||||||
|
out = open(os.path.join(output_dir, 'index.html'), 'w');
|
||||||
|
except:
|
||||||
|
print('error creating output file. aborting...');
|
||||||
|
sys.exit(0);
|
||||||
|
|
||||||
|
print '2/3 - Parsing input';
|
||||||
|
|
||||||
|
dirs = [d for d in os.listdir(input_dir) if not d == '_system' and os.path.isdir(os.path.join(input_dir,d))];
|
||||||
|
|
||||||
|
content = '';
|
||||||
|
|
||||||
|
dirs.sort(); # dirs should be date-named
|
||||||
|
|
||||||
|
for d in reversed(dirs):
|
||||||
|
dd = os.path.join(input_dir,d);
|
||||||
|
indx_txt = os.path.join(dd, 'index.txt');
|
||||||
|
if os.path.isfile(indx_txt):
|
||||||
|
try:
|
||||||
|
indx = open(indx_txt, 'r+');
|
||||||
|
except:
|
||||||
|
print "error opening index: " + indx_txt;
|
||||||
|
continue;
|
||||||
|
|
||||||
|
txt = indx.read();
|
||||||
|
dirname = os.path.basename(dd);
|
||||||
|
newdirname = escape_date(dirname) # trim date out of url -- permalink
|
||||||
|
content += translate(txt, newdirname);
|
||||||
|
content += '\n<br>\n';
|
||||||
|
|
||||||
|
# data dir / content
|
||||||
|
data_dir = os.path.join(dd, 'data');
|
||||||
|
if os.path.isdir(data_dir):
|
||||||
|
|
||||||
|
#check if content needs index
|
||||||
|
content_indx_txt = os.path.join(data_dir, 'index.txt');
|
||||||
|
if os.path.isfile(content_indx_txt):
|
||||||
|
index_content(d, data_dir, content_indx_txt, content_index_template_str);
|
||||||
|
|
||||||
|
|
||||||
|
#copy content
|
||||||
|
out_data_dir = os.path.join(output_dir, newdirname);
|
||||||
|
try:
|
||||||
|
dirutil.copy_tree(data_dir, out_data_dir);
|
||||||
|
except:
|
||||||
|
print "error copying " + data_dir + " to " + out_data_dir + ". Continuing."
|
||||||
|
continue;
|
||||||
|
|
||||||
|
print '3/3 - Generating ouput';
|
||||||
|
|
||||||
|
html = template.read().replace('[[content]]', content);
|
||||||
|
|
||||||
|
out.write(html);
|
||||||
|
|
||||||
|
style_in = os.path.join('.', '+++');
|
||||||
|
style_out = os.path.join(output_dir, '+++');
|
||||||
|
try:
|
||||||
|
dirutil.copy_tree(style_in, style_out);
|
||||||
|
except IOError as err:
|
||||||
|
print err;
|
||||||
|
|
||||||
|
template.close();
|
||||||
|
content_indx_template.close();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
print 'done.';
|
||||||
21
index_apache_template.html
Normal file
21
index_apache_template.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Index of /gauthiier.info/2014.waveforms</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../+++/lestyle.css"/>
|
||||||
|
<meta name="keywords" content="david gauthier, gauthiier, davidgauthier, dviid">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="index_tile"><h1>Index of /gauthiier.info/[[dir]]</h1></div>
|
||||||
|
<ul>
|
||||||
|
<li><a href=".."> Parent Directory</a></li>
|
||||||
|
<!--[[info]]-->
|
||||||
|
</ul>
|
||||||
|
<div class="lst">
|
||||||
|
<ul>
|
||||||
|
[[content]]
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<address>Apache Server at gauthiier.info Port 80</address>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
23
index_template.html
Normal file
23
index_template.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<meta name="keywords" content="david gauthier, gauthiier, davidgauthier, dviid">
|
||||||
|
<meta name="description" content="David Gauthier (b.1979, CA) - selected index of work.">
|
||||||
|
<link rel="icon" href="+++/jules-henri.ico" type="image/x-icon">
|
||||||
|
<link rel="stylesheet" type="text/css" href="+++/lestyle.css"/>
|
||||||
|
<link href="https://github.com/gauthiier" rel="me"/>
|
||||||
|
<link href="https://soundcloud.com/gauthiier" rel="me"/>
|
||||||
|
<link rel="openid.delegate" href="http://gauthiier.info/" />
|
||||||
|
<link rel="openid.server" href="https://indieauth.com/openid" />
|
||||||
|
<title>David Gauthier</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div align="center">
|
||||||
|
<a href="http://pgp.mit.edu/pks/lookup?op=get&search=0x1848D82FADED2A21"><img src="+++/yeux.png" width="500" class="tableau"></a>
|
||||||
|
<h1><i>Gauthiier - (Selected) Index</i></h1>
|
||||||
|
<h4><a href="http://www.uva.nl/en/profile/g/a/d.gauthier/d.gauthier.html">index of recent academic work</a></h4>
|
||||||
|
<h4>d[at]gauthiier.info</h4>
|
||||||
|
[[content]]
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user