diff --git a/latty.py b/latty.py index 8aabd43..2af3762 100644 --- a/latty.py +++ b/latty.py @@ -21,8 +21,18 @@ class CLData(): closingtext: str body: str -def define(file, name, data, whitespace=""): - file.write("\\def \\" + name + "{" + data + whitespace + "}\n") + def get_pairs(): + return [ + ("username", username), + ("company", company), + ("jobandpronoun", jobandpronoun), + ("skilltypes", skilltypes), + ("myskills", myskills), + ("closingtext", closingtext), + ("body", body), + ] + +def define(file, name, data, whitespace=""): file.write("\\def \\" + name + "{" + data + whitespace + "}\n") def generate(data: CLData, unique): proj_dir = os.path.dirname(os.getcwd()) + '/undercover/' diff --git a/writing.py b/writing.py index 7570b2b..4f35850 100644 --- a/writing.py +++ b/writing.py @@ -8,23 +8,6 @@ from latty import (CLData, generate) writing_blueprint = Blueprint('writing', __name__,) -default_defines = [ - ("username", "Sage"), - ("company", "BananaCorp"), - ("jobandpronoun", "Banana Stocker"), - ("skilltypes", "practical"), - ("myskills", "stocking"), - ("closingtext", "I am looking forward to hearing from you"), - ("body", """ - My name is \\username. I would like to work as \\jobandpronoun with your - company. I think my knowledge of \\myskills will contribute well to your - team. - - I am passionate about my work, and think we would work well together. - - Thank you for your consideration."""), -] - class CLForm(Form): username = StringField('Username', [validators.Length(min=4, max=99)], @@ -78,13 +61,14 @@ def index(): closingtext=form.closingtext.data, body=form.body.data, ) - return generate(data, get_unique()) - #return send_from_directory(download, unique + ".pdf", as_attachment=True) - for define in default_defines: - print("\\def \\" + define[0] + " {xxx}") + resp = generate(data, get_unique()) + # Save entered data as cookies on user's machine + for pair in data.get_pairs(): + resp.set_cookie(pair[0], pair[1]) + return resp + return render_template('writing.html', form=form, unique=get_unique(), - defines=default_defines )