diff --git a/app.py b/app.py index dce53a1..342a7b9 100644 --- a/app.py +++ b/app.py @@ -6,7 +6,7 @@ import sys import tempfile import io import requests -from svg_to_hpgl import svgToHPGL +# from svg_to_hpgl import svgToHPGL app = Flask(__name__) @@ -20,21 +20,20 @@ prefix = 'cobbled-pad-' # VARIABLES 4 CATALOGUE # ------------------------------ -output = { +collection = { 'stroke': { 'ascii': ' | ' , 'fonts': [] }, 'script': { 'ascii': ' _/' , 'fonts': [] }, 'block': { 'ascii': '|_|' , 'fonts': [] }, 'outline': { 'ascii': '/ /' , 'fonts': [] }, 'effect': { 'ascii': ': :' , 'fonts': [] }, - 'pattern': { 'ascii': ')()' , 'fonts': [] }, + 'pattern': { 'ascii': '(((' , 'fonts': [] }, - # 'fill': { 'ascii': '_/', 'fonts': {} }, + 'fill': { 'ascii': '###' , 'fonts': [] }, + '3d': { 'ascii': '_|/' , 'fonts': [] }, - # 'directions': { 'ascii': '_/', 'fonts': {} }, - # '3d': { 'ascii': '_/', 'fonts': {} }, - - # 'frame': { 'ascii': '_/', 'fonts': {} }, - # 'code': { 'ascii': '_/', 'fonts': {} }, + # 'directions': { 'ascii': '_/', 'fonts': [] }, + # 'frame': { 'ascii': '_/', 'fonts': [] }, + # 'code': { 'ascii': '_/', 'fonts': [] }, } databases = { 'default': 'fonts made by the figlet developpers and given with the program, early 1993', @@ -128,6 +127,33 @@ def make_figfont(ascii): figfont_file.write(ascii) return figfont_path +def parse_collection(): + # walk in the figlet font directory + for root, dirs, files in os.walk(fonts_directory): + for name in files: + + (basename, ext) = os.path.splitext(name) + if ext in possible_extensions: + + figfont = os.path.join(root, name) + print(figfont) + + # get font databases out of first folder + database = root.split('/')[-2] + # get font type out of last folder + type = root.split('/')[-1] + + # only include selected types + if type in collection: + + f = {} + f['name'] = name + f['database'] = database + f['figfont'] = figfont + + # sort them by type + collection[type]['fonts'].append(f) + # ROUTES # ------------------------------ @@ -161,7 +187,7 @@ def index(): def draw(): params = { - 'pad': request.args.get('p') or 'default', + 'pad': request.args.get('p') or 'index', 'weight': request.args.get('w') or '3', } params['pad-full'] = etherpad + prefix + params['pad'] @@ -209,7 +235,7 @@ def font(): params = { 'text': request.args.get('t') or 'the quick brown fox jumps over the lazy dog', - 'pad': request.args.get('p') or 'standard', + 'pad': request.args.get('p') or 'font_index', 'weight': request.args.get('w') or '3', } params['pad-full'] = etherpad + prefix + params['pad'] @@ -224,28 +250,38 @@ def writing(id): params = { 'text': request.args.get('t') or 'the quick brown fox jumps over the lazy dog', - 'pad': id or 'standard', + 'pad': id or 'ascriipt', 'weight': request.args.get('w') or '3', } - params['pad-full'] = etherpad + prefix + params['pad'] - - pad_answer = get_pad(params['pad-full']) - # TODO: only create new file if content of pad changed - # store as a temporary file - - if pad_answer[0]: - ascii = pad_answer[1] - figfont = make_figfont(ascii) + if '.flf' in params['pad']: + # it's not a pad it's a local figfont file + figfont = '/'.join(params['pad'].split('_')) figlet_answer = text2figlet(params['text'], figfont) + if figlet_answer[0]: ascii = figlet_answer[1] svg = ascii2svg(figlet_answer[1], params['weight']) else: ascii = svg = figlet_answer[1] - + else: - ascii = svg = pad_answer[1] + # we compile a figfont from a pad + params['pad-full'] = etherpad + prefix + params['pad'] + pad_answer = get_pad(params['pad-full']) + + if pad_answer[0]: + ascii = pad_answer[1] + figfont = make_figfont(ascii) + + figlet_answer = text2figlet(params['text'], figfont) + if figlet_answer[0]: + ascii = figlet_answer[1] + svg = ascii2svg(figlet_answer[1], params['weight']) + else: + ascii = svg = figlet_answer[1] + else: + ascii = svg = pad_answer[1] return render_template( 'writing.html', @@ -263,52 +299,21 @@ def writing(id): # # FIGLET 2 SVGBOB INTERACTIVE CATALOGUE -# @app.route("/catalogue.html") -# def catalogue(): +@app.route("/catalogue.html") +def catalogue(): -# # text and weight as get parameter -# params = { -# 'text': request.args.get('t') or 'Echoes', -# 'weight': request.args.get('w') or '3', -# } - -# # walk in the figlet font directory -# for root, dirs, files in os.walk(fonts_directory): -# for name in files: - -# (basename, ext) = os.path.splitext(name) -# if ext in possible_extensions: - -# figfont = os.path.join(root, name) -# print(figfont) - -# # get font category out of last folder -# catalogue = root.split('/')[-2] -# type = root.split('/')[-1] -# if type in output: - -# f = {} -# output[type]['fonts'].append(f) -# f['name'] = name -# f['catalogue'] = catalogue -# f['ascii'] = text2figlet(params['text'], figfont) -# f['svg'] = ascii2svg(f['ascii'], params['weight']) - -# # regex auto_fix -# f['ascii_fix'] = ascii_autofix(f['ascii']) - -# if f['ascii'] != f['ascii_fix']: -# f['autofix'] = True -# f['ascii_fix_indication'] = autofix_indication(f['ascii_fix']) -# f['svg_fix'] = ascii2svg(f['ascii_fix'], params['weight']) - -# return render_template( -# 'catalogue.html', -# title = title, -# databases = databases, -# output = output, -# params = params) + # text and weight as get parameter + params = { + 'text': request.args.get('t') or 'the quick brown fox jumps over the lazy dog', + 'weight': request.args.get('w') or '3', + } + return render_template( + 'catalogue.html', + title = title, + databases = databases, + collection = collection, + params = params) # _ _ _ # | |__ _ __ __ _| | _____ ___ __ ___ _ __| |_ @@ -371,4 +376,5 @@ def hpgl (id): return r if __name__ == '__main__': - app.run(debug=True, host='0.0.0.0') \ No newline at end of file + parse_collection() + app.run(debug=True, host='0.0.0.0') \ No newline at end of file diff --git a/iceberg/42.svg b/iceberg/42.svg new file mode 100644 index 0000000..7a9eeca --- /dev/null +++ b/iceberg/42.svg @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iceberg/Capture d’écran de 2024-02-20 01-05-06.png b/iceberg/Capture d’écran de 2024-02-20 01-05-06.png new file mode 100644 index 0000000..c8c9f19 Binary files /dev/null and b/iceberg/Capture d’écran de 2024-02-20 01-05-06.png differ diff --git a/iceberg/Capture d’écran de 2024-02-24 15-42-20.png b/iceberg/Capture d’écran de 2024-02-24 15-42-20.png new file mode 100644 index 0000000..b13faa8 Binary files /dev/null and b/iceberg/Capture d’écran de 2024-02-24 15-42-20.png differ diff --git a/iceberg/Screenshot 2024-03-30 at 16-34-12 Cobbled paths.png b/iceberg/Screenshot 2024-03-30 at 16-34-12 Cobbled paths.png new file mode 100644 index 0000000..483019a Binary files /dev/null and b/iceberg/Screenshot 2024-03-30 at 16-34-12 Cobbled paths.png differ diff --git a/iceberg/Screenshot 2024-03-30 at 16-39-06 Cobbled paths.png b/iceberg/Screenshot 2024-03-30 at 16-39-06 Cobbled paths.png new file mode 100644 index 0000000..f59c88f Binary files /dev/null and b/iceberg/Screenshot 2024-03-30 at 16-39-06 Cobbled paths.png differ diff --git a/iceberg/Screenshot 2024-03-30 at 16-44-16 Cobbled paths.png b/iceberg/Screenshot 2024-03-30 at 16-44-16 Cobbled paths.png new file mode 100644 index 0000000..14769d9 Binary files /dev/null and b/iceberg/Screenshot 2024-03-30 at 16-44-16 Cobbled paths.png differ diff --git a/iceberg/besançon/full-pic.png b/iceberg/besançon/full-pic.png new file mode 100644 index 0000000..d3d332b Binary files /dev/null and b/iceberg/besançon/full-pic.png differ diff --git a/iceberg/besançon/small-pic.png b/iceberg/besançon/small-pic.png new file mode 100644 index 0000000..e2b8eae Binary files /dev/null and b/iceberg/besançon/small-pic.png differ diff --git a/iceberg/metascriipt.svg b/iceberg/metascriipt.svg new file mode 100644 index 0000000..2d9362c --- /dev/null +++ b/iceberg/metascriipt.svg @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iceberg/out.svg b/iceberg/out.svg new file mode 100644 index 0000000..c2eb602 --- /dev/null +++ b/iceberg/out.svg @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/static/css/interface.css b/static/css/interface.css index d278818..0c1c5bb 100644 --- a/static/css/interface.css +++ b/static/css/interface.css @@ -41,23 +41,34 @@ p{ body{ margin-top: calc(var(--bar-h) * 1); } +body.write, body.catalogue, body.draw{ margin-top: calc(var(--bar-h) * 2); } +body.write .font, +body.catalogue .font, +body.draw .font{ + height: calc(100vh - var(--bar-h) * 2); + grid-template-rows: 1fr; + box-sizing: border-box; +} + +body > .tabs{ + position: fixed; + top: 0; + width: 100%; + z-index: 99999; +} nav ul, .controls{ box-sizing: border-box; - position: fixed; width: 100%; - z-index: 999; display: flex; align-items: center; } -nav ul{ - top: 0; -} + nav ul li{ flex-grow: 1; } @@ -83,12 +94,13 @@ nav ul a.active{ ================================================= */ .controls{ + position: fixed; gap: 0.5rem; top: var(--bar-h); background-color: var(--c-back); - border-bottom: 1px solid black; - padding: 0rem 2rem; + padding: 0rem 1rem; height: var(--bar-h); + z-index: 99; } h1,h2{ @@ -100,7 +112,9 @@ input, button{ strong{ font-weight: bold; } - +#text-input{ + width: 26em; +} .controls hr{ display: block !important; border: none; @@ -128,41 +142,13 @@ label{ flex: 1 1 0%; } -.legend::before{ - content: ''; - width: 1em; - height: 1em; - border-radius: 50%; - background-color: var(--c); - margin-right: 0.5em; - display: inline-block; - vertical-align: middle; -} - -/* CATEGORIES - ================================================= */ - -summary{ - padding: 1rem 2rem; - background: black; - color: white; - border-bottom: whitesmoke solid 1px; - cursor: pointer; - position: sticky; - top: calc(var(--bar-h) * 2); - - z-index: 99; -} - - - /* one font block */ .font{ display: grid; - grid-template-columns: repeat(2, calc(50% - 1rem)); - gap: 0.5rem 2rem; - padding: 0.5rem 2rem 1rem; + grid-template-columns: repeat(2, calc(50% - 0.5rem)); + gap: 1rem; + padding: 0 1rem 1rem; position: relative; } @@ -194,23 +180,31 @@ aside.left{ .f-ascii{ font-family: monospace; font-size: 1rem; - padding: 1rem; background-color: white; overflow: auto; line-height: 1; - - grid-column: 1 / span 1; - grid-row: 2 / span 1; } .f-svg{ padding: 1rem; background-color: white; overflow: auto; - - grid-column: 2 / span 1; - grid-row: 2 / span 1; } +.f-ascii, +.f-svg{ + height: 100%; + width: 100%; + box-sizing: border-box; + grid-row: 1 / span 1; + border: 1px solid black; +} +.f-svg iframe{ + border: none !important; + width: 100%; + height: 100%; + display: block; +} + .f-double{ width: 100%; height: 100%; @@ -226,25 +220,10 @@ hr{ hr:last-of-type{ display: none; } -summary + hr{ - display: none; -} svg{ overflow: visible; } -/* catalogue colors */ -.font h2::before{ - content: ''; - width: 1em; - height: 1em; - border-radius: 50%; - background-color: var(--c); - margin-right: 0.5em; - display: inline-block; - vertical-align: middle; -} - /* autofix colors */ .fix-label{ border-bottom: solid limegreen 3px; @@ -325,51 +304,82 @@ ul.classic{ margin: 0.5rem 0; } -/* DRAW +/* font ================================================= */ -.draw .font{ - height: calc(100vh - var(--bar-h) * 2); - grid-template-rows: 1fr; - box-sizing: border-box; - padding: 1rem 2rem; -} -.draw .f-ascii, -.draw .f-svg{ - height: 100%; - width: 100%; - box-sizing: border-box; - grid-row: 1 / span 1; - border: 1px solid black; +.write .font{ + grid-template-columns: 32rem 1fr; } -.draw .f-ascii{ - padding: 0; + +/* catalogue + ================================================= */ + +.catalogue .font{ + grid-template-columns: 1fr; } -.draw .f-svg{ - padding: 0; + +details{ + position: relative; + z-index: 999; } -.f-svg iframe{ - border: none !important; - width: 100%; - height: 100%; - display: block; +details[open] > summary{ + background-color: var(--c-link); } -.figfont{ - grid-template-columns: 32rem 1fr; +summary{ + padding: 0.5rem 1rem; + background: black; + color: white; + cursor: pointer; + white-space: nowrap; + padding-right: 3rem; } - -.reload::after{ - content: 'reload'; +summary span{ + display: inline-block; position: absolute; - inset: 0; - background-color: rgba(0,0,205,0.2); - z-index: 999; - pointer-events: none; - color: white; + right: 0.5rem; +} +summary + div{ + position: absolute; + left: 100%; + top: 0; +} +.collection{ + width: 75vw; display: flex; - justify-content: center; - align-items: center; - font-weight: bold; + flex-wrap: wrap; +} +.collection > .figfont{ + padding: 0.5rem 1rem; + background: lightgray; + cursor: pointer; + white-space: nowrap; + box-sizing: border-box; + outline: 1px solid black; + outline-offset: -0.5px; +} +.figfont:hover{ + color: var(--c-link); +} +/* catalogue colors */ +.figfont::before{ + content: ''; + width: 0.75em; + height: 0.75em; + border-radius: 50%; + background-color: var(--c); + margin-right: 0.5em; + display: inline-block; + vertical-align: middle; +} +.legend::before{ + content: ''; + width: 1em; + height: 1em; + border-radius: 50%; + background-color: var(--c); + margin-right: 0.5em; + display: inline-block; + vertical-align: middle; } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 19b91b2..6aa467d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,12 +22,13 @@ -