Init commit

TODO: Collect form data, process data into latex renderables, generate unique
id when submitting, styling, etc.
This commit is contained in:
Sage Vaillancourt 2021-07-23 17:30:15 -04:00
commit 8a15cc524f
8 changed files with 285 additions and 0 deletions

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
venv/
*.pyc
__pycache__/
*.aux
*.log
*.pdf
instance/
outputs
.pytest_cache/
.coverage
htmlcov/
dist/
build/
*.egg-info/

44
flaskr/__init__.py Normal file
View File

@ -0,0 +1,44 @@
# Copyright Sage Vaillancourt 2021
import os
from flask import (
Flask, redirect, url_for, render_template, send_from_directory
)
import subprocess
import time
from writing import writing_blueprint
from latty import generate
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY='dev',
DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
)
if test_config is None:
app.config.from_pyfile('config.py', silent=True)
else:
app.config.from_mapping(test_config)
try:
os.makedirs(app.instance_path)
except OSError:
pass
@app.route('/outputs/<unique>')
def output(unique):
root_dir = os.path.dirname(os.getcwd())
download = root_dir + '/undercover/outputs/'
generate(unique)
return send_from_directory(download, unique + ".pdf", as_attachment=True)
app.register_blueprint(
writing_blueprint,
#url_prefix='/writing',
)
return app

View File

@ -0,0 +1,12 @@
{% macro render_field(field) %}
<dt>{{ field.label }}
<dd>{{ field(**kwargs)|safe }}
{% if field.errors %}
<ul class=errors>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</dd>
{% endmacro %}

View File

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
</head>
<body>
<h1>UnderCover: The secret cover letter generator</h1>
{% from "_formhelpers.html" import render_field %}
<form method=post>
<dl>
{{ render_field(form.username) }}
{{ render_field(form.company) }}
{{ render_field(form.jobandpronoun) }}
{{ render_field(form.skilltypes) }}
{{ render_field(form.myskills) }}
{{ render_field(form.body) }}
{{ render_field(form.closingtext) }}
</dl>
<p><input type=submit value="Submit"></p>
</form>
</body>
</html>

29
latty.py Normal file
View File

@ -0,0 +1,29 @@
# Copyright Sage Vaillancourt 2021
import os
import subprocess
from dataclasses import dataClass
# latex /home/sage/Documents/latex/coverLetter/temp.tex'
# dvipdf /home/sage/Documents/latex/coverLetter/temp.dvi ~/Documents/SageVaillancourt_CoverLetter.pdf'
# rm -r /home/sage/Documents/latex/coverLetter/temp*'
# cp "$HOME/Documents/SageVaillancourt_CoverLetter.pdf" "$HOME/Documents/CoverLetters/.pdf"'
# qpdfview $HOME/Documents/SageVaillancourt_CoverLetter.pdf'
@dataclass
class CLData():
username: str
company: str
jobandpronoun: str
skilltypes: str
myskills: str
closingtext: str
body: str
def generate(unique):
template_dir = os.path.dirname(os.getcwd()) + '/undercover/writing_templates'
base_tex = template_dir + '/base.tex'
com = "pdflatex -jobname=outputs/" + unique + " " + base_tex
subprocess.run(['bash', '-c', com])
return base_tex

76
writing.py Normal file
View File

@ -0,0 +1,76 @@
# Copyright Sage Vaillancourt 2021
from flask import (Blueprint, render_template, request)
from wtforms import Form, BooleanField, StringField, TextAreaField, validators
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)],
default="Sage Bongos"
)
company = StringField('Company',
[validators.Length(min=4, max=99)],
default="BananaCorp"
)
jobandpronoun = StringField('Job and Pronoun',
[validators.Length(min=4, max=99)],
default="Banana Stocker"
)
skilltypes = StringField('Skill Type',
[validators.Length(min=4, max=99)],
default="practical"
)
myskills = StringField('My Skills',
[validators.Length(min=4, max=99)],
default="stocking"
)
closingtext = StringField('Closing Text',
[validators.Length(min=4, max=99)],
default="I am looking forward to hearing from you"
)
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."""
)
@writing_blueprint.route('/', methods=('GET', 'POST'))
def index():
form = CLForm(request.form)
if request.method == 'POST' and form.validate():
username = form.username.data
return 'Thank ' + username
for define in default_defines:
print("\\def \\" + define[0] + " {xxx}")
return render_template('writing.html',
form=form,
unique="abcdef",
defines=default_defines
)

View File

@ -0,0 +1,34 @@
\def \username {Sage Vaillancourt}
\def \thecompany {BananCorp}
\def \jobandpronoun {PusherBoy }
\def \skilltypes {broad, practical }
\def \myskills {software design principles }
\def \closingtext {I am looking forward to hearing from you}
\def \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.
}
\documentclass[12pt]{letter}
\signature{\username}
\longindentation=0pt
\begin{document}
\begin{letter}{}
\opening{Dear \thecompany,}
\body
\closing{\closingtext,}
\end{letter}
\end{document}

View File

@ -0,0 +1,48 @@
\def \thecompany {BananCorp}
\def \jobandpronoun {PusherBoy }
\def \skilltypes {broad, practical }
\def \myskills {software design principles}
% CoverLetter.tex - Create a cover letter using an included vars.tex
% \def \username {Sage Vaillancourt}
% \def \thecompany {Travelers}
% \def \jobandpronoun {a Software Engineer }
% \def \skilltypes {broad, practical }
% \def \myskills {computer systems}
\include{vars}
\documentclass[12pt]{letter}
\signature{Sage Vaillancourt}
\longindentation=0pt
\begin{document}
\begin{letter}{}
\opening{Dear \thecompany,}
My name is Sage Vaillancourt. I'm excited for the opportunity to work as
\jobandpronoun with your company. It's clear that you're looking for a hard worker who
has a \skilltypes knowledge of \myskills, so I'm certain that I'd be a
perfect fit to work with you.
I am someone who has been passionate about computers my whole life, and I have
spent a substantial amount of my own time working to make them better. I've
endeavored to learn about programming, hardware, and networking, as well as
running Linux on my own machines, and helping others with theirs. With this
knowledge, Im more than capable of solving my own problems on the job, and I
pride myself on an ability to work quickly and calmly through difficult
situations. I hope I can further utilize these skills with your company.
After looking over my resume, I hope that you will find me to be the type
of person you're looking for. I would be happy to elaborate on any of my
information or provide some references if it would be useful to you. I can be
contacted by phone at (850) 405-7164 or via email at sagev9000@tutanota.com.
Thank you for your consideration.
\closing{I look forward to hearing from you,}
\end{letter}
\end{document}