From 3cdbfdcb048bba2dec6fa43d7844252874b3a9ff Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 25 Jul 2021 14:59:01 -0400 Subject: [PATCH] Better styling, variable syntax, and cookies Adjusted text sizes on mobile. New default variable syntax makes for more consistent whitespace (allowing for simpler internal code). JS won't load cookies if the company name is unchanged from the default. --- flaskr/static/styles.css | 3 +-- flaskr/templates/writing.html | 3 +++ latty.py | 21 ++++++++++++--------- writing.py | 20 ++++++-------------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/flaskr/static/styles.css b/flaskr/static/styles.css index 4e76d37..8e545c9 100644 --- a/flaskr/static/styles.css +++ b/flaskr/static/styles.css @@ -44,11 +44,10 @@ body { } textarea { width: 80vw; - font-size: 250%; + font-size: 200%; } .bigtext { min-height: 40vh; - font-size: 80%; } } diff --git a/flaskr/templates/writing.html b/flaskr/templates/writing.html index f4fdb72..aab92e9 100644 --- a/flaskr/templates/writing.html +++ b/flaskr/templates/writing.html @@ -21,6 +21,9 @@ return ""; } function loadCookies() { + if (document.getElementById('company').value === "BananaCorp") { + return + } console.log(document.cookie); cookies = [ 'username', diff --git a/latty.py b/latty.py index 78c39d9..8626578 100644 --- a/latty.py +++ b/latty.py @@ -27,21 +27,24 @@ class CLData(): ("body", self.body), ] -def define(file, name, data, whitespace=""): file.write("\\def \\" + name + "{" + data + whitespace + "}\n") +def define(file, name, data, whitespace=""): + file.write("\\def \\" + name + "{" + data + whitespace + "}\n") -def generate(data: CLData, unique): +def get_unique(): + import uuid + unique = str(uuid.uuid1().hex) + print("Unique ID: " + unique) + return unique + +def generate(data: CLData): import threading + unique = get_unique() proj_dir = os.path.dirname(os.getcwd()) + '/undercover/' output_dir = proj_dir + 'outputs/' unique_file = output_dir + unique + ".tex" f = open(unique_file, "w") - define(f, "username", data.username) - define(f, "thecompany", data.company) - define(f, "jobandpronoun", data.jobandpronoun, " ") - define(f, "skilltypes", data.skilltypes, " ") - define(f, "myskills", data.myskills, " ") - define(f, "closingtext", data.closingtext) - define(f, "body", data.body) + for pair in data.get_pairs(): + file.write("\\def \\" + pair[0] + "{" + pair[0] + "}\n") f.write(open(proj_dir + "/writing_templates/base.tex", "r").read()) f.close() diff --git a/writing.py b/writing.py index c570e30..808c27c 100644 --- a/writing.py +++ b/writing.py @@ -2,6 +2,7 @@ from flask import (Blueprint, render_template, request, make_response) from wtforms import Form, BooleanField, StringField, TextAreaField, validators +import urllib.parse from latty import (CLData, generate) @@ -34,11 +35,11 @@ class CLForm(Form): default="I look forward to hearing from you" ) - body_string = ("My name is \\username. I would like to work as " - "\\jobandpronoun with your company. I think my \\skilltypes knowledge " - "of \\myskills will contribute well to your team.\n\n" + body_string = ("My name is {\\username}. I would like to work as " + "{\\jobandpronoun} with your company. I think my {\\skilltypes} knowledge " + "of {\\myskills} can contribute a lot to your team.\n\n" - "I am passionate about my work, and think we would work well together.\n\n" + "I am passionate about what I do, and I think we would work well together.\n\n" "Thank you for your consideration.") body = TextAreaField('Body:', @@ -46,15 +47,8 @@ class CLForm(Form): default=body_string ) -def get_unique(): - import uuid - unique = str(uuid.uuid1().hex) - print("Unique ID: " + unique) - return unique - @writing_blueprint.route('/', methods=('GET', 'POST')) def index(): - import urllib.parse form = CLForm(request.form) if request.method == 'POST' and form.validate(): data = CLData( @@ -67,12 +61,11 @@ def index(): body=form.body.data, ) - resp = generate(data, get_unique()) + resp = generate(data) # Save entered data as cookies on user's machine if not resp: resp = make_response(render_template('writing.html', form=form, - unique=get_unique(), )) for pair in data.get_pairs(): resp.set_cookie(pair[0], urllib.parse.quote(pair[1])) @@ -80,5 +73,4 @@ def index(): return render_template('writing.html', form=form, - unique=get_unique(), )