diff --git a/latty.py b/latty.py
index 20936a6..ee28c8e 100644
--- a/latty.py
+++ b/latty.py
@@ -36,8 +36,8 @@ def define(file, name, data, whitespace=""): file.write("\\def \\" + name + "{"
def generate(data: CLData, unique):
proj_dir = os.path.dirname(os.getcwd()) + '/undercover/'
- template_dir = os.path.dirname(os.getcwd()) + '/undercover/temp/'
- unique_file = template_dir + unique + ".tex"
+ temp_dir = proj_dir + '/temp/'
+ unique_file = temp_dir + unique + ".tex"
f = open(unique_file, "w")
define(f, "username", data.username)
define(f, "thecompany", data.company)
@@ -49,9 +49,10 @@ def generate(data: CLData, unique):
f.write(open(proj_dir + "/writing_templates/base.tex", "r").read())
f.close()
- base_tex = template_dir + unique + ".tex"
- com = "pdflatex -jobname=outputs/" + unique + " " + base_tex
+ base_tex = temp_dir + unique + ".tex"
+ com = "pdflatex -halt-on-error -jobname=outputs/" + unique + " " + base_tex
print("COM: '" + com + "'")
+ #TODO: If error, don't try to return the pdf
subprocess.run(['bash', '-c', com])
root_dir = os.path.dirname(os.getcwd())
diff --git a/writing.py b/writing.py
index 0177b29..8cb169f 100644
--- a/writing.py
+++ b/writing.py
@@ -9,47 +9,52 @@ from latty import (CLData, generate)
writing_blueprint = Blueprint('writing', __name__,)
class CLForm(Form):
- username = StringField('Username',
+ username = StringField('Username:',
[validators.Length(min=4, max=99)],
- default="Sage Bongos"
+ default="Sage Bernerner"
)
- company = StringField('Company',
+ company = StringField('Company:',
[validators.Length(min=4, max=99)],
default="BananaCorp"
)
- jobandpronoun = StringField('Job and Pronoun',
+ jobandpronoun = StringField('Job and Pronoun (a/an):',
[validators.Length(min=4, max=99)],
default="a banana stocker"
)
- skilltypes = StringField('Skill Type',
+ skilltypes = StringField('Skill Type:',
[validators.Length(min=4, max=99)],
default="practical"
)
- myskills = StringField('My Skills',
+ myskills = StringField('My Skills:',
[validators.Length(min=4, max=99)],
default="stocking bananas"
)
- closingtext = StringField('Closing Text',
+ closingtext = TextAreaField('Closing Text:',
[validators.Length(min=4, max=99)],
- default="I am looking forward to hearing from you"
+ default="I look forward to hearing from you"
)
- body = TextAreaField('Body',
+
+ 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"
+
+ "I am passionate about my work, and think we would work well together.\n\n"
+
+ "Thank you for your consideration.")
+ body = TextAreaField('Body:',
[validators.Length(min=4, max=9999)],
- default="""
- 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."""
+ default=body_string
)
def get_unique():
- return "get_unique"
+ import uuid
+ unique = str(uuid.uuid1().hex)[0:8]
+ 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(
@@ -65,7 +70,7 @@ def index():
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])
+ resp.set_cookie(pair[0], urllib.parse.quote(pair[1]))
return resp
return render_template('writing.html',