Save/fetch previous data. Better style. Unique IDs
This commit is contained in:
parent
42c67985a6
commit
9a7787ef69
|
@ -6,11 +6,71 @@ body {
|
|||
min-height: 90%;
|
||||
text-size: 150%;
|
||||
line-height: 200%;
|
||||
width: 40vw;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: sans;
|
||||
}
|
||||
|
||||
/* Small screens */
|
||||
@media only screen and (max-width: 1080px) {
|
||||
body {
|
||||
width: 95vw;
|
||||
font-size: 200%;
|
||||
}
|
||||
h1 {
|
||||
font-size: 400%;
|
||||
}
|
||||
h2 {
|
||||
font-size: 300%;
|
||||
line-height: 100%;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
label {
|
||||
font-size: 150%;
|
||||
}
|
||||
input {
|
||||
font-size: 200%;
|
||||
width: 100%;
|
||||
}
|
||||
form {
|
||||
width: 90%;
|
||||
}
|
||||
dd {
|
||||
margin-bottom: 2em;
|
||||
margin-left: 0;
|
||||
}
|
||||
textarea {
|
||||
width: 80vw;
|
||||
font-size: 250%;
|
||||
}
|
||||
.bigtext {
|
||||
min-height: 40vh;
|
||||
}
|
||||
}
|
||||
|
||||
/* Big screens */
|
||||
@media only screen and (min-width: 1081px) {
|
||||
body {
|
||||
width: 40vw;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3em;
|
||||
}
|
||||
.content, .ret {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
img, small {
|
||||
width: 30vw;
|
||||
}
|
||||
small {
|
||||
font-size: 100%;
|
||||
}
|
||||
#closingtext {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
|
@ -30,7 +90,6 @@ dd {
|
|||
}
|
||||
|
||||
textarea {
|
||||
width: 90%;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
|
@ -41,7 +100,3 @@ textarea {
|
|||
#body {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#closingtext {
|
||||
width: 50%;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% macro render_field(field, extra="") %}
|
||||
<dt>{{ field.label }}:
|
||||
<dt>{{ field.label }}
|
||||
<dd {{extra}}>{{ field(**kwargs)|safe }}
|
||||
{% if field.errors %}
|
||||
<ul class=errors>
|
||||
|
|
|
@ -3,6 +3,45 @@
|
|||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="
|
||||
{{ url_for('static', filename='styles.css') }}">
|
||||
<meta name="viewport" content="user-scalable=no">
|
||||
<script type="text/javascript">
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
let ca = decodedCookie.split(';');
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
function loadCookies() {
|
||||
console.log(document.cookie);
|
||||
cookies = [
|
||||
'username',
|
||||
'company',
|
||||
'jobandpronoun',
|
||||
'skilltypes',
|
||||
'myskills',
|
||||
'closingtext',
|
||||
'body',
|
||||
]
|
||||
for(let i = 0; i < cookies.length; i++) {
|
||||
console.log(cookies[i]);
|
||||
c = getCookie(cookies[i]);
|
||||
console.log(c);
|
||||
if (c) {
|
||||
document.getElementById(cookies[i]).value=c
|
||||
}
|
||||
}
|
||||
}
|
||||
window.onload = loadCookies;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>UnderCover</h1>
|
||||
|
|
9
latty.py
9
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())
|
||||
|
|
43
writing.py
43
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',
|
||||
|
|
Loading…
Reference in New Issue