From: Max Value Date: Tue, 18 Mar 2025 02:48:51 +0000 (+0000) Subject: Built document preperation X-Git-Url: https://git.ozva.co.uk/?a=commitdiff_plain;h=8f1a901e337945b3ad3e14ee5d3230cb28c36d25;p=shopping-channel Built document preperation + added call-sheet.tex + added manifest-safe.tex + added manifest-unsafe.tex + added gfx-text.tex + added html documentation (auth) + info.json --- diff --git a/.gitignore b/.gitignore index e3e7c2c..05e655d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.wsgi data.db +docs/* diff --git a/requirements.txt b/requirements.txt index 09e14b6..3517df0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ flask_httpauth flask werkzeug +jinja2 diff --git a/static/info.json b/static/info.json new file mode 100644 index 0000000..2acba37 --- /dev/null +++ b/static/info.json @@ -0,0 +1,139 @@ +{ + "shoot": { + "date": "30th March 2025", + "location": "MediaCity UoS, Room 3.08" + }, + "crew":[ + { + "name": "William Greenwood", + "role": "Producer", + "phone": "075 9476 8180", + "email": "W.Greenwood@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Finn Downton", + "role": "Narrative enginneer", + "phone": "079 1003 1116", + "email": "E.Downton@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Jack Christian-Sims", + "role": "Director", + "phone": "075 4297 4087", + "email": "J.Christian-Sims@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Eleanor Haughton", + "role": "Vision Mixer", + "phone": "074 9127 2723", + "email": "E.V.Haughton@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Heather Digwood", + "role": "Floor manager", + "phone": "077 8817 3853", + "email": "H.Digwood@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Olivia Gillett", + "role": "Floor manager", + "phone": "073 6852 4302", + "email": "O.Gillett@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Leo Garside-Holdich", + "role": "Camera opperator", + "phone": "078 7474 0891", + "email": "L.N.Garside-Holdich@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Rebecca Dixon", + "role": "Sound opperator", + "phone": "074 3400 7701", + "email": "R.Dixon2@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Alex Roberts", + "role": "Lighting opperator", + "phone": "074 9660 1832", + "email": "A.Roberts17@edu.salford.ac.uk", + "absent": true + }, + { + "name": "Tegan Blake-Barnard", + "role": "Set-design lead", + "phone": "075 4893 0872", + "email": "T.blake-barnard@edu.Salford.ac.uk", + "absent": false + }, + { + "name": "Lydia Wilkinson", + "role": "Set-design / GFX opperator", + "phone": "078 0269 0037", + "email": "L.wilkinson14@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Leigha Blanchard", + "role": "Set-design / GFX opperator", + "phone": "074 7700 0501", + "email": "L.blanchard@salford.ac.uk", + "absent": false + }, + { + "name": "Daisy Devoe", + "role": "Set-design / GFX opperator", + "phone": "079 7056 4500", + "email": "D.Devoe@edu.salford.ac.uk", + "absent": false + }, + { + "name": "Brynn Yates", + "role": "GFX opperator", + "phone": "073 7766 9812", + "email": "M.Yates5@edu.salford.ac.uk", + "absent": false + } + ], + "cast":[ + { + "name": "David Smith", + "role": "Anchor", + "phone": "078 8839 8003", + "email": "D.Smith51@edu.salford.ac.uk", + "absent": false + } + ], + "schedule":[ + { + "time": "0000", + "title": "This is an action", + "extra": [ + "Test" + ] + }, + { + "time": "0000", + "title": "This is an action", + "extra": [ + "Test" + ] + }, + { + "time": "0000", + "title": "This is an action", + "extra": [ + "Test" + ] + } + ], + "notes": ["These are some notes on what we'll be doing"] +} diff --git a/static/static.json b/static/static.json index 0e35279..42b280b 100755 --- a/static/static.json +++ b/static/static.json @@ -29,6 +29,7 @@ "THE THREAT", "I used to be so unimaginably tall!", "Doomsday", + "Lets eat grandma", "It's here!" ], "banner":[ @@ -110,9 +111,13 @@ "rating":"★★★★★", "subtext":"Starting soon!", "description":"The show will be starting soon!", + "currency":"£", + "prefix":true, "origional_price":1, + "gallery_price":1, + "cost_price":1, "stock_count":1, - "notes":"

[autocue] Showing: test product.
Commencing shortly.

", + "notes":"[autocue] Showing: test product.
Commencing shortly.", "crew_notes":"Test crew notes" }, { @@ -120,7 +125,11 @@ "rating":"★★★★★", "subtext":"Hyperclean™! Teethpaste", "description":"Hyperclean™! Professional Dentist-grade Teethpaste with a dark shine and a matte-finish. Dentists want it off the air!", + "currency":"£", + "prefix":true, "origional_price":14.99, + "gallery_price":0.7, + "cost_price":0.9, "stock_count":230, "notes":"", "crew_notes":"Test crew notes" @@ -130,7 +139,11 @@ "rating":"★★★★★", "subtext":"Is that a hairline fracture? A crack?", "description":"Don't look too close! Detailed painting from a long time ago! Decades of a careful hand in observation of the bright and round moon.", + "currency":"£", + "prefix":true, "origional_price":4500, + "gallery_price":0.6, + "cost_price":0.8, "stock_count":5, "notes":"", "crew_notes":"Test crew notes" @@ -140,7 +153,11 @@ "rating":"★★★★★", "subtext":"Abundance Declared Cigarettes", "description":"Smoke breaks too short? borrow the time! Try royal abundance.", + "currency":"£", + "prefix":true, "origional_price":35, + "gallery_price":1, + "cost_price":0.5, "stock_count":111, "notes":"", "crew_notes":"Test crew notes" @@ -150,7 +167,11 @@ "rating":"★★★★★", "subtext":"Coffee. we killed the sheep!", "description":"Bad dreams? Never sleep again. New formula, 100x strength", + "currency":"£", + "prefix":true, "origional_price":12, + "gallery_price":0.6, + "cost_price":0.65, "stock_count":100, "notes":"", "crew_notes":"Test crew notes" @@ -160,7 +181,11 @@ "rating":"★★★★★", "subtext":"The replacement mirror", "description":"Ready to move on? Look over your shoulder to the person replacing you when you go.", + "currency":"£", + "prefix":true, "origional_price":2000, + "gallery_price":0.35, + "cost_price":0.4, "stock_count":40, "notes":"", "crew_notes":"Test crew notes" @@ -169,8 +194,12 @@ "code":"777777", "rating":"★★★★★", "subtext":"The number previously known as 7", - "description":"Ready to move on? Look over your shoulder to the person replacing you when you go.", + "description":"The Magical Number Seven, Plus or Minus Two. This is the 7 things.", + "currency":"£", + "prefix":true, "origional_price":823543, + "gallery_price":0.7, + "cost_price":0.77, "stock_count":7, "notes":"", "crew_notes":"Test crew notes" @@ -179,8 +208,12 @@ "code":"424F58", "rating":"★★★★★", "subtext":"Surprise jack-in-the-box, shock your friends!", - "description":"Surprise-Box™ Limited edition, only 100 EVER made!. Beautiful hand-painted sides.", + "description":"Surprise-Box™ Limited edition, only 100 EVER made! Beautiful hand-painted sides.", + "currency":"£", + "prefix":true, "origional_price":45, + "gallery_price":1, + "cost_price":0.8, "stock_count":99, "notes":"", "crew_notes":"Test crew notes" @@ -190,7 +223,11 @@ "rating":"★★★★★", "subtext":"Black and White Blood Chocolate Sauce", "description":"The perfect topping for Noir detectives in ice-cream bars! Sweet and thick chocolate, made from all natural ingredients.", + "currency":"£", + "prefix":true, "origional_price":8, + "gallery_price":0.5, + "cost_price":0.87, "stock_count":300, "notes":"", "crew_notes":"Test crew notes" diff --git a/teleshopping.py b/teleshopping.py index f165cfa..9bd5998 100755 --- a/teleshopping.py +++ b/teleshopping.py @@ -1,12 +1,13 @@ #!.venv/bin/python +from flask import Flask, Response, request, render_template, jsonify, send_from_directory from werkzeug.security import generate_password_hash, check_password_hash -from flask import Flask, Response, request, render_template, jsonify +from jinja2 import Environment, FileSystemLoader from flask_httpauth import HTTPBasicAuth from datetime import datetime, timezone +from os import path, environ, system from math import radians, cos, sin from ast import literal_eval -from os import path, environ import sqlite3 import json @@ -14,7 +15,10 @@ INCREMENT = 18 app = Flask(__name__) auth = HTTPBasicAuth() -app.root_path = environ["SHOPPING_PATH"] +try: + app.root_path = environ["SHOPPING_PATH"] +except KeyError: + pass # get the secrets ready with open(path.join(app.root_path, "..", "secrets.json"), "r") as f: @@ -25,6 +29,9 @@ users = {k: generate_password_hash(v) for (k, v) in users.items()} with open(path.join(app.root_path, "static", "static.json"), "r") as f: static_data = json.loads(f.read()) +with open(path.join(app.root_path, "static", "info.json"), "r") as f: + static_info = json.loads(f.read()) + @@ -54,15 +61,22 @@ def database(field: str | list): def gfx_main(): return Response(render_template("gfx.html"), mimetype="text/html") -@app.route("/") +@app.route("/autocue") def gfx_page(page): - if page in ["autocue"]: - return Response(render_template(f"{page}.html"), mimetype="text/html") - else: - return "", 404 + return Response(render_template("autocue.html"), mimetype="text/html") + +@app.route("/docs") +@auth.login_required +def web_docs(): + return Response(render_template("docs.html", data=static_data, info=static_info), mimetype="text/html") + +@app.route("/docs/") +@auth.login_required +def paper_docs(filename): + return send_from_directory("docs", filename, as_attachment=True) @app.route("/admin") @auth.login_required @@ -178,6 +192,31 @@ def api_clock(): +def generate_docs(): + latex_enviroment = Environment( + loader=FileSystemLoader(path.join(app.root_path, "templates")), + block_start_string = "|%", + block_end_string = "%|", + variable_start_string = "|~", + variable_end_string = "~|", + comment_start_string = "|#", + comment_end_string = "#|", + trim_blocks = True, + lstrip_blocks = True + ) + + for document in ["call-sheet.tex", "manifest-unsafe.tex", "manifest-safe.tex", "gfx-text.tex"]: + template = latex_enviroment.get_template(document) + docs_path = path.join(app.root_path, "docs") + + with open(path.join(docs_path, document), "w") as f: + f.write(template.render(data=static_data, info=static_info)) + + system(f"pdflatex -interaction='nonstopmode' -output-directory='{docs_path}' '{path.join(docs_path, document)}' > /dev/zero") + system(f"pdflatex -interaction='nonstopmode' -output-directory='{docs_path}' '{path.join(docs_path, document)}' > /dev/zero") + + print(f" - Generated {document}") + if __name__ == "__main__": # sanity check on the db with open(path.join(app.root_path, "schema"), "r") as f: @@ -197,4 +236,7 @@ if __name__ == "__main__": cursor.execute(load) connection.commit() - app.run(host='127.0.0.1', port=8000, debug=True) + print("Generating static documentation...") + generate_docs() + + app.run(host='192.168.0.144', port=8000, debug=True) diff --git a/templates/call-sheet.tex b/templates/call-sheet.tex new file mode 100644 index 0000000..aab6b44 --- /dev/null +++ b/templates/call-sheet.tex @@ -0,0 +1,72 @@ +\documentclass{article} + +\usepackage{tabularx} +\usepackage[ + top=1.5cm, + bottom=1.5cm, + left=1cm, + right=1cm + ]{geometry} + +\renewcommand{\arraystretch}{1.2} + +\begin{document} + +\thispagestyle{empty} + +\noindent{\Large{}\textbf{XMDV Teleshopping\hspace*{\fill}|~ info.shoot.date ~|}}\\ +Location: |~ info.shoot.location ~| + +\vspace{4mm} + +\noindent{\large{}\textbf{Production Contacts}} + +\vspace{2mm} + +\noindent\begin{tabularx}{\textwidth}{r l l X} + \hline +\textbf{Name} & \textbf{Role} & \textbf{Contact} &\\ + \hline + \hline +\textbf{Crew} &&&\\ + |% for person in info.crew %| + \hline + |~ person.name ~| & |~ person.role ~| & |~ person.phone ~| & |~ person.email ~| \\ + |% endfor %| + \hline + \hline +\textbf{Cast} &&&\\ + |% for person in info.cast %| + \hline + |~ person.name ~| & |~ person.role ~| & |~ person.phone ~| & |~ person.email ~| \\ + |% endfor %| + \hline +\end{tabularx} + +\vspace{2mm} + +\noindent\textit{First Aider: William Greenwood 075 9476 8180} + +\vspace{4mm} + +\noindent{\large{}\textbf{Schedule}} + +\vspace{2mm} + +\noindent\begin{tabularx}{\textwidth}{r X} + \hline +\textbf{Time} & \\ + \hline + |% for action in info.schedule %| + \hline + \textbf{|~ action.time ~|} & |~ action.title ~|\\ + |% if action.extra|length > 0 %| + |% for line in action.extra %| + & \textit{|~ line ~|}\\ + |% endfor %| + |% endif %| + |% endfor %| + \hline +\end{tabularx} + +\end{document} diff --git a/templates/docs.html b/templates/docs.html index 4af7662..11757b1 100644 --- a/templates/docs.html +++ b/templates/docs.html @@ -1,12 +1,188 @@ - - - - - - -
-
-
- + + + + XMDV + + + +

XMDV Teleshopping documentation

+

Contains forbidden information

+

{{info.shoot.date}}

+

Location: {{info.shoot.location}}

+ +

Call-sheet

+ + + + + + + + + {% for person in info.crew %} + {% if not person.absent %} + + + + + + {% endif %} + {% endfor %} + + + {% for person in info.cast %} + + + + + + {% endfor %} +
NameRoleContact
Crew +
{{person.name}}{{person.role}}{{person.phone}}
{{person.email}}
Cast +
{{person.name}}{{person.role}}{{person.phone}}
{{person.email}}
+

First Aider: William Greenwood 075 9476 8180

+ + +

Schedule

+ + + + + + + + + {% for action in info.schedule %} + + + + + {% if action.extra|length > 0 %} + {% for line in action.extra %} + + + + + {% endfor %} + {% endif %} + {% endfor %} +
TimeAction
{{action.time}}{{action.title}}
{{line}}
+ +

Shoot notes

+
    + {% for line in info.notes %} +
  • {{line}}
  • + {% endfor %} +
+ + {% macro price(origional, currency, prefix, p=0) %} + {% set new_price = (origional * (1-p))|round(2) %} + {% if prefix %} + {{currency ~ new_price}} + {% else %} + {{new_price ~ currency}} + {% endif %} + {% if p != 0 %} + (~{{(p * 100)|round|int}}% off) + {% endif %} + {% endmacro %} + +

Item manifest

+ + {% for item in data['items'] %} + {% if loop.index0 > 0 %} + + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} +
Item code{{item.code}}
Name{{item.subtext|safe}}
+ Initial {{price(item.origional_price, item.currency, item.prefix)}} + Gallery price {{price(item.origional_price, item.currency, item.prefix, p=item.gallery_price)}} + Purchase price {{price(item.origional_price, item.currency, item.prefix, p=item.cost_price)}} +
Description{{item.description|safe}}
Notes{{item.notes|safe}}
Forbidden +
+ Reveal + {{item.crew_notes}} +
+
+ +

Text options

+ + + + + {% for line in data.text.crawler_top %} + + + {% endfor %} + + + + {% for line in data.text.crawler_bottom %} + + + {% endfor %} + + + + {% for line in data.text.banner %} + + + {% endfor %} +
Crawler top text
{{line}} +
Crawler bottom text
{{line}} +
Banner text
{{line}} +
+ + +

PDF Documents

+ diff --git a/templates/gfx-text.tex b/templates/gfx-text.tex new file mode 100644 index 0000000..2beede8 --- /dev/null +++ b/templates/gfx-text.tex @@ -0,0 +1,30 @@ +\documentclass{article} + +\usepackage{tabularx} +\usepackage[ + top=1.5cm, + bottom=1.5cm, + left=1cm, + right=1cm + ]{geometry} + +\renewcommand{\arraystretch}{1.2} + +\begin{document} + +\thispagestyle{empty} + +\noindent{\Large{}\textbf{XMDV Teleshopping\hspace*{\fill}|~ info.shoot.date ~|}} + +\vspace{4mm} + +\subsection*{Crawler top text} +|% for line in data.text.crawler_top %||~ line ~|\\|% endfor %| + +\subsection*{Crawler bottom text} +|% for line in data.text.crawler_bottom %||~ line ~|\\|% endfor %| + +\subsection*{Banner text} +|% for line in data.text.banner %||~ line ~|\\|% endfor %| + +\end{document} diff --git a/templates/manifest-safe.tex b/templates/manifest-safe.tex new file mode 100644 index 0000000..d315b2d --- /dev/null +++ b/templates/manifest-safe.tex @@ -0,0 +1,75 @@ +\documentclass{article} + +\usepackage{calc} +\usepackage{newtx} +\usepackage[ + top=1.5cm, + bottom=1.5cm, + inner=1cm, + outer=1cm + ]{geometry} + +\usepackage{tabularx} +\usepackage{ltablex} + +\begin{document} + + \noindent{\Large{}\textbf{XMDV Teleshopping\hspace*{\fill}|~ info.shoot.date ~|}} + + \begin{tabularx}{\textwidth}{| l || X || l | l | l | l | } + % HEADER SETUP + \hline + \textbf{Code} & \textbf{Description} & \textbf{Qty} & \textbf{Start price} & \textbf{Gallery price} & \textbf{Cost price} \\ + \hline + \hline + \endhead + + % FOOTER SETUP + \hline + \textbf{Code} & \textbf{Description} & \textbf{Qty} & \textbf{Start price} & \textbf{Gallery price} & \textbf{Cost price} \\ + \hline + \endfoot + + % TABLE BODY + |% macro price(origional, currency, prefix, p=0) %| + |% set new_price = (origional * (1-p))|round(2) %| + |% if prefix %| + |~ currency ~ new_price ~| + |% else %| + |~ new_price ~ currency ~| + |% endif %| + |% if p != 0 %| + (~ |~ (p * 100)|round|int ~|\% off) + |% endif %| + |% endmacro %| + + |% macro format(string) %| + |~ string|replace("#", "~")|replace("&", "~")|replace("%", "\%") ~| + |% endmacro %| + + |% macro html(string) %| + |~ string + |replace("
    ", " ") + |replace("
", " ") + |replace("
  • ", " ") + |replace("
    ", " ") + |replace("
  • ", ". ") + |replace("", " ") + |replace("", " ") + ~| + |% endmacro %| + + |% for item in data['items'] %| + |~ item.code ~| & |~ format(item.subtext) ~| & |~ item.stock_count ~| & + |~ price(item.origional_price, item.currency, item.prefix) ~| & + |~ price(item.origional_price, item.currency, item.prefix, p=item.gallery_price) ~| & + |~ price(item.origional_price, item.currency, item.prefix, p=item.cost_price) ~| \\ + \hline + \multicolumn{6}{|p{\textwidth - 13pt}|}{|~ html(format(item.description)) ~|}\\ + \hline + \multicolumn{6}{|p{\textwidth - 13pt}|}{|~ html(format(item.notes)) ~|}\\ + \hline + \hline + |% endfor %| + \end{tabularx} +\end{document} diff --git a/templates/manifest-unsafe.tex b/templates/manifest-unsafe.tex new file mode 100644 index 0000000..723352a --- /dev/null +++ b/templates/manifest-unsafe.tex @@ -0,0 +1,80 @@ +\documentclass{article} + +\usepackage{calc} +\usepackage{xcolor} +\usepackage{newtx} +\usepackage[text=FORBIDDEN, scale=0.5]{draftwatermark} +\usepackage[ + top=1.5cm, + bottom=1.5cm, + inner=1cm, + outer=1cm + ]{geometry} + +\usepackage{tabularx} +\usepackage{ltablex} + +\begin{document} + + \noindent{\Large{}\textbf{XMDV Teleshopping\hspace*{\fill}|~ info.shoot.date ~|}}\\ + \textcolor{red}{\textbf{Contains forbidden information}} + + \begin{tabularx}{\textwidth}{| l || X || l | l | l | l | } + % HEADER SETUP + \hline + \textbf{Code} & \textbf{Description} & \textbf{Qty} & \textbf{Start price} & \textbf{Gallery price} & \textbf{Cost price} \\ + \hline + \hline + \endhead + + % FOOTER SETUP + \hline + \textbf{Code} & \textbf{Description} & \textbf{Qty} & \textbf{Start price} & \textbf{Gallery price} & \textbf{Cost price} \\ + \hline + \endfoot + + % TABLE BODY + |% macro price(origional, currency, prefix, p=0) %| + |% set new_price = (origional * (1-p))|round(2) %| + |% if prefix %| + |~ currency ~ new_price ~| + |% else %| + |~ new_price ~ currency ~| + |% endif %| + |% if p != 0 %| + (~ |~ (p * 100)|round|int ~|\% off) + |% endif %| + |% endmacro %| + + |% macro format(string) %| + |~ string|replace("#", "~")|replace("&", "~")|replace("%", "\%") ~| + |% endmacro %| + + |% macro html(string) %| + |~ string + |replace("
      ", " ") + |replace("
    ", " ") + |replace("
  • ", " ") + |replace("
    ", " ") + |replace("
  • ", ". ") + |replace("", " ") + |replace("", " ") + ~| + |% endmacro %| + + |% for item in data['items'] %| + |~ item.code ~| & |~ format(item.subtext) ~| & |~ item.stock_count ~| & + |~ price(item.origional_price, item.currency, item.prefix) ~| & + |~ price(item.origional_price, item.currency, item.prefix, p=item.gallery_price) ~| & + |~ price(item.origional_price, item.currency, item.prefix, p=item.cost_price) ~| \\ + \hline + \multicolumn{6}{|p{\textwidth - 13pt}|}{|~ html(format(item.description)) ~|}\\ + \hline + \multicolumn{6}{|p{\textwidth - 13pt}|}{|~ html(format(item.notes)) ~|}\\ + \hline + \multicolumn{6}{|p{\textwidth - 13pt}|}{\textcolor{red}{\textbf{|~ format(item.crew_notes) ~|}}}\\ + \hline + \hline + |% endfor %| + \end{tabularx} +\end{document}