diff --git a/.gitignore b/.gitignore index d237c6a..8a8dde4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.static/settings.json venv/ +++/*.jpg +++/*.jpeg @@ -7,3 +8,4 @@ venv/ +++/533201N0032129W_from_the_Sea_poster.png +++/key.asc +++/index.html +.DS_Store diff --git a/.static/settings.template.json b/.static/settings.template.json new file mode 100644 index 0000000..8f2a8e2 --- /dev/null +++ b/.static/settings.template.json @@ -0,0 +1,5 @@ +{ + "inputdir": "<>", + "outputdir": "<>", + "style": "<>" +} \ No newline at end of file diff --git a/gen.py b/gen.py index 2d3785e..daec81e 100644 --- a/gen.py +++ b/gen.py @@ -1,31 +1,13 @@ #!/usr/bin/env python -import sys, os, string, markdown, argparse, shutil, json, glob, re -from distutils import dir_util as dirutil +import argparse, json, sys, markdown, shutil, json, re, pathlib, shutil -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; +input_dir = None +output_dir = None +style = None +codebase = pathlib.Path(__file__).parent.absolute() def translate_index_header(txt, dirname): - try: - table = open(os.path.join('.', ''), 'r+'); - except: - print('error opening
file. aborting...'); - sys.exit(0); - href = None sections = txt.count('- - -'); if sections == 0: @@ -43,7 +25,12 @@ def translate_index_header(txt, dirname): # revise this - perhaps with a better link_md = link_md.replace('data/', dirname + '/'); - out = table.read().replace('[[text_md]]', text_md); + + table = codebase / "templates/
" + with table.open(encoding="utf-8") as fp: + out = fp.read() + + out = out.replace('[[text_md]]', text_md); out = out.replace('[[link_md]]', link_md); if href: href = href.replace('data/', dirname + '/'); @@ -53,45 +40,49 @@ def translate_index_header(txt, dirname): def escape_date(dirname): return re.sub('^20\d{2}?.', '', dirname) -def emit_img(file, data_dir): - return '' +def emit_img(file: pathlib.Path, data_dir: pathlib.Path): -def emit_video_mp4(file, data_dir): - return '
b/templates/
new file mode 100644 index 0000000..6f26b0d --- /dev/null +++ b/templates/
@@ -0,0 +1,12 @@ +
+ + + + + + +
+ [[text_md]] +
+ [[link_md]] +
\ No newline at end of file diff --git a/templates/index_apache_template.html b/templates/index_apache_template.html new file mode 100644 index 0000000..20d984d --- /dev/null +++ b/templates/index_apache_template.html @@ -0,0 +1,24 @@ + + + + + Index of /gauthiier.info/[[dir]] + + + + +

Index of /gauthiier.info/[[dir]]

+
+ + Parent Directory +
+ +
+ +
+ +
Apache Server at gauthiier.info Port 80
+ + diff --git a/templates/index_template.html b/templates/index_template.html new file mode 100644 index 0000000..e538b13 --- /dev/null +++ b/templates/index_template.html @@ -0,0 +1,23 @@ + + + + + + + + + + + David Gauthier + + +
+ +

David Gauthier

+

(Selected) Index of works

+

index of academic work

+

d[at]gauthiier.info

+ [[content]] +
+ + diff --git a/templates/robots.txt b/templates/robots.txt new file mode 100644 index 0000000..134b4d5 --- /dev/null +++ b/templates/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /+++/ \ No newline at end of file diff --git a/utils/wavconv.py b/utils/wavconv.py new file mode 100644 index 0000000..cec0345 --- /dev/null +++ b/utils/wavconv.py @@ -0,0 +1,61 @@ +import argparse, sys, os, glob, subprocess + +supported = ['ogg', 'mp3'] + +def sanity_check_system(): + r = subprocess.call("ffmpeg -version", shell=True) == 0 + if not r: + sys.exit("ffmpeg not installed. Aborting...") + +def convert(i, o, f): + global supported + if f not in supported: + print("warning: format " + f + "is not supported") + return + + if f == 'mp3': + codec = 'libmp3lame' + elif f == 'ogg': + codec = 'libvorbis' + + subprocess.call(['ffmpeg', '-i', i, '-acodec', codec, o]) + + +if __name__ == '__main__': + + p = argparse.ArgumentParser(description='Converts .wav files to other formats (using ffmpeg)'); + p.add_argument('-i', '--input', help='input directory'); + p.add_argument('-f', '--format', help='output formats (ogg and/or mp3)', nargs="+"); + + sanity_check_system() + + args = p.parse_args() + + if not args.format: + sys.exit("Nor formats specified. Aborting.") + + formats = [] + for f in args.format: + if f not in supported: + print("warning: format " + f + "is not supported") + else: + formats.append(f) + + if not formats: + sys.exit("None of the specified formats are supported. Aborting.") + + input_dir = "." + if args.input: + input_dir = args.input + + wav_files = glob.glob(os.path.join(input_dir, "*.wav")) + for w in wav_files: + for f in formats: + fn = os.path.join(input_dir, os.path.basename(w).replace('.wav', '.' + f)) + convert(w, fn, f) + + + + + +