Commit 47535504 authored by PizZaKatZe's avatar PizZaKatZe

Add cmdline switch for printing QR codes

parent 4896733f
......@@ -30,7 +30,9 @@ def parse_arguments(args):
"""Parses command-line arguments.
"""
parser = ArgumentParser()
parser.add_argument('-p', '--print',
parser.add_argument('-l', '--links', action='store_true',
help='generate QR codes with links to sessions\'s wiki pages')
parser.add_argument('-p', '--print', action='store_true',
help='print filtered data of session with index PRINT, starting at 1; ' +
'0 prints all sessions')
parser.add_argument('output', nargs='?',
......@@ -65,8 +67,9 @@ def main():
end = int(args.print)
pretty_print(sessions[0 : end if end else -1])
flyer = generate_flyer(sessions, args.links)
if args.output:
with open(args.output, 'wb') as output:
output.write(generate_flyer(sessions))
output.write(flyer)
else:
stdout.buffer.write(generate_flyer(sessions))
stdout.buffer.write(flyer)
......@@ -40,12 +40,12 @@ def fetch_data(url: str) -> List[Dict]:
results: Dict = load(urlopen(url))['results']
return list(results.values())
def generate_flyer(sessions: List[Dict]) -> bytes:
def generate_flyer(sessions: List[Dict], links=True) -> bytes:
"""Generates a PDF from self-organized session data.
"""
env = make_env(loader=FileSystemLoader(dirname(__file__)))
template = env.get_template('template.tex')
pdf = build_pdf(template.render(sessions=sessions))
pdf = build_pdf(template.render(sessions=sessions, links=links))
return pdf.__bytes__()
def process_sessions(sessions: List[Dict]) -> List[Dict]:
......
\documentclass[10pt,a4paper,DIV=16]{scrartcl}
\documentclass[12pt,a4paper,DIV=16]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
......@@ -9,30 +9,43 @@
\setlength{\parindent}{0pt}
\setcounter{secnumdepth}{0}
\newcommand{\thetitle}{Junghackertag: Angebote}
\newcommand{\thetitle}{Angebote für Junghacker*innen}
\newcommand{\theauthor}{Chaos macht Schule}
\title{\thetitle}
\author{\theauthor}
\hypersetup{
pdftitle = {\thetitle},
pdfauthor = {\theauthor},
pdfsubject = {Junghackertag},
pdfsubject = {Junghacker*innentag},
pdfborder = {0 0 0},
}
\begin{document}
\maketitle
\begin{longtable}{|p{0.45\linewidth}|p{0.2\linewidth}|l|l|}
%- if links
\begin{longtable}{|l|p{0.45\linewidth}|p{0.2\linewidth}|l|}
\hline
\textbf{Was?} & \textbf{Wo?} & \textbf{Wann?} & \textbf{URL}
\textbf{Wann?} & \textbf{Was?} & \textbf{Wo?} & \textbf{URL}
\\ \hline \hline
%- for session in sessions
\VAR{session.title | e} & \VAR{session.providers | e} & \VAR{session.start | e}
\VAR{session.start | e} & \VAR{session.title | e} & \VAR{session.providers | e}
& \qrcode{\VAR{session.url | e}}
\\ \hline
%- endfor
\end{longtable}
%- else
\begin{longtable}{|l|p{0.55\linewidth}|p{0.3\linewidth}|}
\hline
\textbf{Wann?} & \textbf{Was?} & \textbf{Wo?}
\\ \hline \hline
%- for session in sessions
\VAR{session.start | e} & \VAR{session.title | e} & \VAR{session.providers | e}
\\ \hline
%- endfor
\end{longtable}
%- endif
\end{document}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment