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.
This commit is contained in:
Sage Vaillancourt 2021-07-25 14:59:01 -04:00
parent 1ad6f56e14
commit 3cdbfdcb04
4 changed files with 22 additions and 25 deletions

View File

@ -44,11 +44,10 @@ body {
}
textarea {
width: 80vw;
font-size: 250%;
font-size: 200%;
}
.bigtext {
min-height: 40vh;
font-size: 80%;
}
}

View File

@ -21,6 +21,9 @@
return "";
}
function loadCookies() {
if (document.getElementById('company').value === "BananaCorp") {
return
}
console.log(document.cookie);
cookies = [
'username',

View File

@ -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()

View File

@ -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(),
)