diff --git a/flaskr/__init__.py b/flaskr/__init__.py index 5a93cc4..089524d 100644 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -17,7 +17,7 @@ def optimize_css(): static_dir = root + '/undercover/flaskr/static/' css = open(static_dir + 'styles.css', 'r').read() minified_with_comments = "".join(list(map( - lambda line: line if 'media' in line else line.replace(' ', ''), + lambda line: line if 'media' in line or 'padding' in line or 'transition' in line else line.replace(' ', ''), css.split('\n') ))) minified = re.sub( r'/\*[\s\S]*?\*/', "", minified_with_comments) diff --git a/flaskr/db.py b/flaskr/db.py index b33c6ae..82a6e17 100644 --- a/flaskr/db.py +++ b/flaskr/db.py @@ -1,6 +1,6 @@ import bcrypt import os -import psycopg2 +import psycopg from dataclasses import dataclass @@ -25,7 +25,7 @@ class UserWithHash: def connect(): - return psycopg2.connect( + return psycopg.connect( host=os.environ['UNDERCOVER_POSTGRES_HOST'], dbname=os.environ['UNDERCOVER_POSTGRES_DBNAME'], port=os.environ['UNDERCOVER_POSTGRES_PORT'], @@ -90,8 +90,8 @@ def edit_letter(letter_id: int, letter_title: str, letter_content: str): def get_user_letters(user_id: int) -> [Letter]: with connect() as con: cur = con.cursor() - cur.execute("SELECT id, letter_name, letter_data FROM letter_data WHERE user_id = %s", str(user_id)) - return map(lambda row: Letter(row[0], row[1], row[2]), cur.fetchall()) + cur.execute("SELECT id, letter_name, letter_data FROM letter_data WHERE user_id = %s", (str(user_id),)) + return list(map(lambda row: Letter(row[0], row[1], row[2]), cur.fetchall())) def get_user(email: str) -> User: diff --git a/flaskr/static/styles.css b/flaskr/static/styles.css index aec1a20..7d2b8e2 100644 --- a/flaskr/static/styles.css +++ b/flaskr/static/styles.css @@ -11,17 +11,20 @@ body { font-family: sans; } +h1, h2 { + text-align: center; +} + /* Small screens */ @media only screen and (max-width: 1080px) { body { - width: 95vw; - font-size: 200%; + width: 85vw; } h1 { - font-size: 400%; + font-size: 300%; } h2 { - font-size: 300%; + font-size: 200%; line-height: 100%; margin-top: 0; margin-bottom: 0.5em; diff --git a/flaskr/templates/writing.html b/flaskr/templates/writing.html index d81909e..4de21dd 100644 --- a/flaskr/templates/writing.html +++ b/flaskr/templates/writing.html @@ -1,9 +1,10 @@ + - + + -

UnderCover

-

The secret cover letter generator

-{% from "_formhelpers.html" import render_field %} -
-
- {{ render_field(form.username) }} - {{ render_field(form.company) }} - {{ render_field(form.jobandpronoun) }} - {{ render_field(form.skilltypes) }} - {{ render_field(form.myskills) }} - {{ render_field(form.body, 'class=bigtext') }} - {{ render_field(form.closingtext) }} -
- {% if errors %} -
-

Your letter has errors.

-

There is likely a typo in one of your variables (the {\blabla} bits). -
Make sure each is spelled correctly, and has the correct brackets on either - side

-

- {% for error in errors %} - {{ error }}
- {% endfor %} -

-
- {% endif %} - -
+

UnderCover

+

The secret cover letter generator

+ {% from "_formhelpers.html" import render_field %} +
+
+ {{ render_field(form.username) }} + {{ render_field(form.company) }} + {{ render_field(form.jobandpronoun) }} + {{ render_field(form.skilltypes) }} + {{ render_field(form.myskills) }} + {{ render_field(form.body, 'class=bigtext') }} + {{ render_field(form.closingtext) }} +
+ {% if errors %} +
+

Your letter has errors.

+

There is likely a typo in one of your variables (the {\blabla} bits). +
Make sure each is spelled correctly, and has the correct brackets on either + side

+

+ {% for error in errors %} + {{ error }}
+ {% endfor %} +

+
+ {% endif %} + +
diff --git a/latty.py b/latty.py index b29fc47..6cb1c5b 100644 --- a/latty.py +++ b/latty.py @@ -82,7 +82,7 @@ class CLData(): return (send_from_directory( output_dir, output_file, - attachment_filename=self.username.replace(" ", "") + "_CoverLetter.pdf", + download_name=self.username.replace(" ", "") + "_CoverLetter.pdf", as_attachment=True ), None) else: diff --git a/requirements.txt b/requirements.txt index 03b32b7..5d9fa7b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ Jinja2==3.1.2 MarkupSafe==2.1.1 psycopg==3.1.1 Werkzeug==2.2.2 -WTForms==3.0.1 \ No newline at end of file +WTForms==3.0.1 diff --git a/start b/start index 58c4259..dcda877 100755 --- a/start +++ b/start @@ -14,7 +14,7 @@ fi if [[ "$1" == "prod" ]]; then echo "Starting gunicorn production server..." - gunicorn -b 0.0.0.0:1312 "flaskr:create_app()" + gunicorn -b 0.0.0.0:443 "flaskr:create_app()" else echo "Starting local dev server..." export FLASK_ENV=development diff --git a/writing.py b/writing.py index 2803a9e..1a0e6d7 100644 --- a/writing.py +++ b/writing.py @@ -7,6 +7,7 @@ import urllib.parse from latty import CLData import flaskr import flaskr.db as db +import os writing_blueprint = Blueprint('writing', __name__,) @@ -71,8 +72,22 @@ def index_get(): @writing_blueprint.route('/dbtest', methods=['GET']) -def index_get(): - return db.get_user_letters(1)[0].contents +def dbtest_get(): + response = make_response(db.get_user_letters(1)[0].contents, 200) + response.mimetype = "text/plain" + return response + + +@writing_blueprint.route('/update', methods=['POST']) +def update_get(): + if os.environ['GITLAB_HOOK_TOKEN'] == request.headers['X-Gitlab-Token'] and request.headers['X-Gitlab-Event'] == "Push Hook": + print("Update notification received.") + # TODO: Git clone + response = make_response("", 200) + response.mimetype = "text/plain" + return response + else: + return make_response("", 404) @writing_blueprint.route('/', methods=['POST'])