...
 
Commits (2)
......@@ -40,6 +40,8 @@ def parse_arguments(args):
parser.add_argument('-p', '--print',
help='print filtered data of session with index PRINT, starting at 1; '
'0 prints all sessions')
parser.add_argument('-r', '--draft', action='store_true',
help='add draft watermark')
parser.add_argument('-t', '--tex', action='store_true',
help='print tex document to stdout')
parser.add_argument('output', nargs='?',
......@@ -72,6 +74,7 @@ def main():
sessions = None
if args.url:
sessions = fetch_data(args.url)
#print(dumps(sessions, indent=4))
elif args.path:
sessions = read_data(args.path)
sessions = process_sessions(sessions, int(args.day))
......@@ -80,7 +83,7 @@ def main():
end = int(args.print)
pretty_print(sessions[0 : end if end else None])
tex = generate_tex(sessions, args.homepage, args.links)
tex = generate_tex(sessions, args.homepage, args.links, args.draft)
if args.tex:
print(tex)
flyer = render(tex)
......
......@@ -40,13 +40,14 @@ def fetch_data(url: str) -> List[Dict]:
results: Dict = load(urlopen(url))['results']
return list(results.values())
def generate_tex(sessions: List[Dict], homeurl: str, links=True) -> str:
def generate_tex(sessions: List[Dict], homeurl: str, links=True, draft=False) -> str:
"""Generates a LaTeX document from self-organized session data.
Args:
sessions: processed self-organized session data
homeurl: URL of JHT homepage
links: if set, QR codes with links to session wiki page are generated
draft: if set, adds a draft watermark
Returns:
a LaTeX document
......@@ -54,7 +55,11 @@ def generate_tex(sessions: List[Dict], homeurl: str, links=True) -> str:
libpath = dirname(__file__)
env = make_env(loader=FileSystemLoader(libpath))
template = env.get_template('template.tex')
tex = template.render(libpath=libpath, sessions=sessions, homeurl=homeurl, links=links)
tex = template.render(libpath=libpath,
sessions=sessions,
homeurl=homeurl,
links=links,
draft=draft)
return tex
def process_sessions(sessions: List[Dict], day: int) -> List[Dict]:
......
......@@ -9,6 +9,13 @@
\usepackage{graphicx}
\graphicspath{{\VAR{libpath}/}}
%- if draft
\usepackage{draftwatermark}
\SetWatermarkText{DRAFT}
\SetWatermarkColor{red!40}
\SetWatermarkScale{4}
%- endif
\setlength{\parindent}{0pt}
\setcounter{secnumdepth}{0}
\pagestyle{empty}
......
This diff is collapsed.