Commit d558fb90 authored by Robin Sonnabend's avatar Robin Sonnabend

The compiled document looks fine

parent 72e8a882
......@@ -210,6 +210,8 @@ class Todo(db.Model):
def get_state(self):
return "[Erledigt]" if self.done else "[Offen]"
def get_state_tex(self):
return "Erledigt" if self.done else "Aktiv"
def render_html(self):
parts = [
......
......@@ -2,6 +2,8 @@ import regex as re
import sys
from collections import OrderedDict
from shared import escape_tex
class ParserException(Exception):
name = "Parser Exception"
has_explanation = False
......@@ -143,7 +145,7 @@ class Text:
self.linenumber = linenumber
def render(self):
return self.text
return escape_tex(self.text)
def dump(self, level=None):
if level is None:
......@@ -169,7 +171,10 @@ class Tag:
self.linenumber = linenumber
def render(self):
return r"\textbf{{{}:}} {}".format(self.name, "; ".join(self.values));
if self.name == "url":
return r"\url{{{}}}".format(self.values[0])
#return r"\textbf{{{}:}} {}".format(escape_tex(self.name.capitalize()), "; ".join(map(escape_tex, self.values)));
return r"\textbf{{{}:}} {}".format(escape_tex(self.name.capitalize()), escape_tex(self.values[0]))
def dump(self, level=None):
if level is None:
......@@ -255,8 +260,8 @@ class Fork(Element):
for child in self.children:
child.dump(level + 1)
def render(self):
return ((self.name if self.name is not None and len(self.name) > 0 else "")
def render(self, toplevel=False):
return ((self.name if self.name is not None and len(self.name) > 0 and not toplevel else "")
+ r"\begin{itemize}" + "\n"
+ "\n".join(map(lambda e: r"\item {}".format(e.render()), self.children)) + "\n"
+ r"\end{itemize}" + "\n")
......
......@@ -72,6 +72,9 @@ def date_filter_long(date):
def time_filter(time):
return time.strftime("%H:%m")
def class_filter(obj):
return obj.__class__.__name__
from auth import LdapManager, SecurityManager
ldap_manager = LdapManager(config.LDAP_PROVIDER_URL, config.LDAP_BASE)
security_manager = SecurityManager(config.SECURITY_KEY)
......@@ -14,15 +14,34 @@
\LoadClass[a4paper]{article}
% so ein paar sachen die wir eh immer brauchen
\RequirePackage{ngerman}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
%\RequirePackage[T1]{fontenc}
%\RequirePackage{ngerman}
\RequirePackage[ngerman]{babel}
%\RequirePackage[utf8]{inputenc}
\RequirePackage[vmargin=1.5cm,hmargin={1.5cm,1.2cm},bindingoffset=8mm]{geometry}
%\RequirePackage{lineno}
\RequirePackage{longtable}
\RequirePackage{framed}
\RequirePackage{eurosym}
\RequirePackage{csquotes}
\RequirePackage[babel]{csquotes}
%\RequirePackage{fontspec}
\RequirePackage{polyglossia}
\setmainlanguage[babelshorthands=true]{german}
\RequirePackage{fontspec}
%\setromanfont[Scale=0.925]{DejaVu Serif}
%\setsansfont[Scale=0.925]{DejaVu Sans}
%\setmonofont[Scale=0.925]{DejaVu Sans Mono}
%\setmainfont[Scale=0.925]{DejaVu Sans}
\setromanfont{Nimbus Roman}
\setsansfont{Nimbus Sans}
\setmonofont{Nimbus Mono PS}
\setmainfont[
BoldFont={NimbusSans},
ItalicFont={NimbusSans},
BoldItalicFont={NimbusSans}
]{Nimbus Sans} % TODO: make configurable
% nicht einr�cken und benutzerinnendefinierte kopfzeile
......@@ -30,8 +49,8 @@
\setlength{\parskip}{1ex}
\pagestyle{myheadings}
\renewcommand*{\rmdefault}{phv}
\renewcommand*{\sfdefault}{phv}
%\renewcommand*{\rmdefault}{phv}
%\renewcommand*{\sfdefault}{phv}
% Titel
\newcommand{\Kopf}[1]{\markboth{#1}{#1}}
......
......@@ -7,7 +7,7 @@ import tempfile
from models.database import Document, Protocol, Error, Todo, Decision, TOP, DefaultTOP
from server import celery, app
from shared import db, escape_tex, unhyphen, date_filter, datetime_filter, date_filter_long, time_filter
from shared import db, escape_tex, unhyphen, date_filter, datetime_filter, date_filter_long, time_filter, class_filter
from utils import mail_manager, url_manager, encode_kwargs, decode_kwargs
from parser import parse, ParserException, Element, Content, Text, Tag, Remark, Fork
......@@ -29,6 +29,7 @@ texenv.filters["datify"] = date_filter
texenv.filters["datify_long"] = date_filter_long
texenv.filters["datetimify"] = datetime_filter
texenv.filters["timify"] = time_filter
texenv.filters["class"] = class_filter
mailenv = app.create_jinja_environment()
mailenv.trim_blocks = True
......@@ -177,7 +178,7 @@ def compile_async(content, protocol_id):
try:
current = os.getcwd()
protocol_source_filename = "protocol.tex"
protocol_target_filename = "protocol.tex"
protocol_target_filename = "protocol.pdf"
log_filename = "protocol.log"
with open(os.path.join(compile_dir, protocol_source_filename), "w") as source_file:
source_file.write(content)
......@@ -192,6 +193,9 @@ def compile_async(content, protocol_id):
subprocess.check_call(command, universal_newlines=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.check_call(command, universal_newlines=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.chdir(current)
for old_document in [document for document in protocol.documents if document.is_compiled]:
protocol.documents.remove(old_document)
db.session.commit()
document = Document(protocol.id, name="protokoll_{}_{}.pdf".format(protocol.protocoltype.short_name, date_filter(protocol.date)), filename="", is_compiled=True)
db.session.add(document)
db.session.commit()
......@@ -199,6 +203,7 @@ def compile_async(content, protocol_id):
document.filename = target_filename
shutil.copy(os.path.join(compile_dir, protocol_target_filename), os.path.join("documents", target_filename))
db.session.commit()
shutil.copy(os.path.join(compile_dir, log_filename), "/tmp")
except subprocess.SubprocessError:
log = ""
total_log_filename = os.path.join(compile_dir, log_filename)
......
......@@ -4,9 +4,9 @@
%\usepackage{palatino}
\usepackage{pdfpages}
\usepackage{eurosym}
\usepackage[utf8]{inputenc}
%\usepackage[utf8]{inputenc}
\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage{ngerman}
%\usepackage{ngerman}
% \usepackage[left]{lineno}
%\usepackage{footnote}
%\usepackage{times}
......@@ -15,17 +15,18 @@
%\renewcommand{\familydefault}{\sfdefault}
\newcommand{\einrueck}[1]{\hfill\begin{minipage}{0.95\linewidth}#1\end{minipage}}
\begin{document}
%\thispagestyle{plain} %ggf kommentarzeichen entfernen
\Titel{
\large Protokoll: \VAR{protocol.protocoltype.name|escape_tex}
\\\normalsize \VAR{protocol.protocoltype.organization|escape_tex}
}{}
\begin{tabular}{rp{15.5cm}}
\begin{tabular}{rp{14cm}}
{\bf Datum:} & \VAR{protocol.date|datify_long|escape_tex}\\
{\bf Ort:} & \VAR{protocol.location|escape_tex}\\
{\bf Protokollant:} & \VAR{protocol.author|escape_tex}\\
{\bf Anwesend:} & \VAR{protocol.participants|join(", ")|escape_tex}\\
{\bf Anwesend:} & \VAR{protocol.participants|escape_tex}\\
\end{tabular}
\normalsize
......@@ -43,8 +44,20 @@
Beginn der Sitzung: \VAR{protocol.start_time|timify}
\ENV{for top in tree.children}
\TOP{\VAR{top.name|escape_tex}} % here we probably have information doubly
\VAR{top.render()|escape_tex}
\ENV{if top|class == "Fork"}
\TOP{\VAR{top.name|escape_tex}} % here we probably have information doubly
\ENV{if top.name == "Todos"}
\ENV{if protocol.todos|length > 0}
\begin{itemize}
\ENV{for todo in protocol.todos}
\item \VAR{todo.who}: \VAR{todo.description} -- \VAR{todo.get_state_tex()}
\ENV{endfor}
\end{itemize}
\ENV{endif}
\ENV{else}
\VAR{top.render(toplevel=True)}
\ENV{endif}
\ENV{endif}
\ENV{endfor}
Ende der Sitzung: \VAR{protocol.end_time|timify}
......
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