Commit ce4c81ca authored by PizZaKatZe's avatar PizZaKatZe

New command line option: Add draft watermark

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