Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
proto3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
protokollsystem
proto3
Commits
72e8a882
Commit
72e8a882
authored
8 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Compiling the latex version works
parent
2ba18b3f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
parser.py
+1
-1
1 addition, 1 deletion
parser.py
static/tex/protokoll2.cls
+175
-0
175 additions, 0 deletions
static/tex/protokoll2.cls
tasks.py
+50
-45
50 additions, 45 deletions
tasks.py
templates/protocol.tex
+3
-3
3 additions, 3 deletions
templates/protocol.tex
with
229 additions
and
49 deletions
parser.py
+
1
−
1
View file @
72e8a882
...
...
@@ -243,7 +243,7 @@ class Remark(Element):
class
Fork
(
Element
):
def
__init__
(
self
,
environment
,
name
,
parent
,
linenumber
,
children
=
None
):
self
.
environment
=
environment
if
environment
is
None
or
len
(
environment
)
>
0
else
None
self
.
name
=
name
if
name
is
None
or
len
(
name
)
>
0
else
None
self
.
name
=
name
.
strip
()
if
(
name
is
not
None
and
len
(
name
)
>
0
)
else
None
self
.
parent
=
parent
self
.
linenumber
=
linenumber
self
.
children
=
[]
if
children
is
None
else
children
...
...
This diff is collapsed.
Click to expand it.
static/tex/protokoll2.cls
0 → 100644
+
175
−
0
View file @
72e8a882
% protokoll.cls -- version 0.1 -- last changed: see mtime of the file ;)
%
%
% Author: Sebastian G�nther <samson@asta.rwth-aachen.de>
% zuerst mal LaTeX's formalzeug
\NeedsTeXFormat
{
LaTeX2e
}
\ProvidesClass
{
protokoll2
}
[2004/06/04 protokoll.cls v0.1 macht Protokolle (VV)]
\DeclareOption*
{
\PassOptionsToClass
{
\CurrentOption
}{
article
}}
%\ExecuteOptions{draft}
\ProcessOptions\relax
% die restlichen optionen geben wir an article weiter
\LoadClass
[a4paper]
{
article
}
% so ein paar sachen die wir eh immer brauchen
\RequirePackage
{
ngerman
}
\RequirePackage
[T1]
{
fontenc
}
\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
}
% nicht einr�cken und benutzerinnendefinierte kopfzeile
\setlength
{
\parindent
}{
0cm
}
\setlength
{
\parskip
}{
1ex
}
\pagestyle
{
myheadings
}
\renewcommand*
{
\rmdefault
}{
phv
}
\renewcommand*
{
\sfdefault
}{
phv
}
% Titel
\newcommand
{
\Kopf
}
[1]
{
\markboth
{
#1
}{
#1
}}
\newcommand
{
\Titel
}
[2]
{
\markboth
{
#2
}{
#2
}
\markright
{
#2
}
\thispagestyle
{
plain
}
\begin{center}
\textbf
{
#1
}
\end{center}
}
% Tops
\renewcommand
{
\thesection
}{
TOP~
\arabic
{
section
}}
\renewcommand
{
\thesubsection
}{
TOP~
\arabic
{
section
}
~(
\alph
{
subsection
}
)
}
\newcommand
{
\TOP
}
[1]
{
\section
{
#1
}}
\newcommand
{
\unterTOP
}
[1]
{
\subsection
{
#1
}}
% F�rs Inhaltsverzeichnisanpassen
\renewcommand
{
\l
@section
}{
\@
dottedtocline
{
1
}{
1.5em
}{
4em
}}
\renewcommand
{
\l
@subsection
}{
\@
dottedtocline
{
2
}{
5.5em
}{
5.2em
}}
\renewcommand
{
\contentsname
}{
Tagesordnung
}
\newcommand
{
\Inhalt
}{
\tableofcontents
}
% Zeilen-Numerierungen
\newcommand
{
\ZeilenNummerierung
}{
\pagewiselinenumbers\linenumbers
}
\newcommand
{
\EndeZeilenNummerierung
}{
\nolinenumbers
}
% Anwesenheit
\newenvironment
{
Anw
}{
\begin{list}
{}{
%
\renewcommand
{
\makelabel
}
[1]
{
\hfill
##1
}
%
\settowidth
{
\labelwidth
}{
Anwesenheit:~
}
%
\addtolength
{
\labelwidth
}{
\labelsep
}
%
\setlength
{
\leftmargin
}{
\labelwidth
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\setlength
{
\itemsep
}{
0pt
}
%
\setlength
{
\parsep
}{
0pt
}
%
\setlength
{
\topsep
}{
0pt
}
%
}
%
}
%
{
\end{list}
}
% Abwesenheit
\newenvironment
{
Abw
}{
\begin{list}
{}{
%
\renewcommand
{
\makelabel
}
[1]
{
\hfill
##1
}
%
\settowidth
{
\labelwidth
}{
Anwesenheit:~
}
%
\addtolength
{
\labelwidth
}{
\labelsep
}
%
\setlength
{
\leftmargin
}{
\labelwidth
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\setlength
{
\itemsep
}{
0pt
}
%
\setlength
{
\parsep
}{
0pt
}
%
\setlength
{
\topsep
}{
0pt
}
%
}
%
}
%
{
\end{list}
}
% Abk�rzungen
\newenvironment
{
Abk
}{
%
\begin{list}
{}{
%
Abkürzungen:
\renewcommand
{
\makelabel
}
[1]
{
\hfill
##1
}
%
\setlength
{
\labelwidth
}{
2cm
}
%
\addtolength
{
\labelwidth
}{
\labelsep
}
%
\setlength
{
\leftmargin
}{
\labelwidth
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\addtolength
{
\leftmargin
}{
\labelsep
}
%
\setlength
{
\itemsep
}{
0pt
}
%
\setlength
{
\parsep
}{
0pt
}
%
\setlength
{
\topsep
}{
0pt
}
%
}
%
}
%
{
\end{list}
}
% Unterschriften f�r eine und zwei Personen
\newcommand
{
\Unterschrift
}
[2]
{
\vspace*
{
1.4cm
}
\begin{center}
\rule
{
.4
\linewidth
}{
.15mm
}
\\
#1
\\
\footnotesize
{
(#2)
}
\end{center}
}
\newcommand
{
\ZweiUnterschrift
}
[4]
{
\vspace*
{
1.4cm
}
\begin{center}
\parbox
[t]
{
.4
\linewidth
}{
\rule
{
\linewidth
}{
.15mm
}
\\
\vspace*
{
-.4cm
}
\begin{center}
#1
\\
\footnotesize
{
(#2)
}
\end{center}
}
\hspace*
{
.1
\linewidth
}
\parbox
[t]
{
.4
\linewidth
}{
\rule
{
\linewidth
}{
.15mm
}
\\
\vspace*
{
-.4cm
}
\begin{center}
#3
\\
\footnotesize
{
(#4)
}
\end{center}
}
\end{center}
}
% \newcommand{\Antrag}[1]{
% % \setlength{\arrayrulewidth}{2mm}
% % \begin{longtable}{|ll}
% % \hspace{2mm} & \parbox[t]{17cm}{#1}
% % \end{longtable}
% \begingroup
% \rule{2mm}{2mm}
% \leftskip10cm
% % \rightskip\leftskip
% #1
% \par
% \endgroup
% }
\newcommand
{
\Antrag
}
[1]
{
\setlength
{
\arrayrulewidth
}{
2mm
}
\begin{longtable}
{
|ll
}
% \hspace{2mm} & \parbox[t]{17cm}{#1}
\hspace
{
2mm
}
&
\begin{minipage}
{
17cm
}
#1
\end{minipage}
\end{longtable}
}
\newenvironment
{
antrag
}
{
%
\par
%
\begingroup
%
\leftskip
1cm
%
}
{
\par\endgroup
}
\newcommand
{
\Bericht
}
[1]
{
\Antrag
{
#1
}
}
\newcommand
{
\PE
}
[2]
{
\textbf
{
Persönliche Erklärung von #1:
}
\\\emph
{
\glqq
{}
#2
\grqq
{}}
\\
}
This diff is collapsed.
Click to expand it.
tasks.py
+
50
−
45
View file @
72e8a882
...
...
@@ -3,6 +3,7 @@ from flask import render_template
import
os
import
subprocess
import
shutil
import
tempfile
from
models.database
import
Document
,
Protocol
,
Error
,
Todo
,
Decision
,
TOP
,
DefaultTOP
from
server
import
celery
,
app
...
...
@@ -49,7 +50,8 @@ def parse_protocol_async(protocol_id, encoded_kwargs):
protocol
=
Protocol
.
query
.
filter_by
(
id
=
protocol_id
).
first
()
if
protocol
is
None
:
raise
Exception
(
"
No protocol given. Aborting parsing.
"
)
for
error
in
protocol
.
errors
:
old_errors
=
list
(
protocol
.
errors
)
for
error
in
old_errors
:
protocol
.
errors
.
remove
(
error
)
db
.
session
.
commit
()
if
protocol
.
source
is
None
:
...
...
@@ -158,55 +160,58 @@ def parse_protocol_async(protocol_id, encoded_kwargs):
top
=
TOP
(
protocol
.
id
,
fork
.
name
,
index
,
False
)
db
.
session
.
add
(
top
)
db
.
session
.
commit
()
protocol
.
done
=
True
db
.
session
.
commit
()
latex_source
=
texenv
.
get_template
(
"
protocol.tex
"
).
render
(
protocol
=
protocol
,
tree
=
tree
)
compile
(
latex_source
,
protocol
)
protocol
.
done
=
True
db
.
session
.
commit
()
def
compile
(
content
,
protocol
):
compile_async
.
delay
(
content
,
protocol
.
id
)
@celery.task
def
compile_async
(
name
,
document_id
):
is_error
=
False
def
compile_async
(
content
,
protocol_id
):
with
tempfile
.
TemporaryDirectory
()
as
compile_dir
,
app
.
app_context
():
protocol
=
Protocol
.
query
.
filter_by
(
id
=
protocol_id
).
first
()
try
:
current
=
os
.
getcwd
()
os
.
chdir
(
"
latex
"
)
os
.
makedirs
(
"
bin
"
,
exist_ok
=
True
)
protocol_source_filename
=
"
protocol.tex
"
protocol_target_filename
=
"
protocol.tex
"
log_filename
=
"
protocol.log
"
with
open
(
os
.
path
.
join
(
compile_dir
,
protocol_source_filename
),
"
w
"
)
as
source_file
:
source_file
.
write
(
content
)
shutil
.
copy
(
"
static/tex/protokoll2.cls
"
,
compile_dir
)
os
.
chdir
(
compile_dir
)
command
=
[
"
/usr/bin/xelatex
"
,
"
-halt-on-error
"
,
"
-file-line-error
"
,
"
-output-directory
"
,
"
bin
"
,
"
{}.tex
"
.
format
(
name
)
protocol_source_filename
]
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
)
os
.
makedirs
(
"
documents/pdf
"
,
exist_ok
=
True
)
shutil
.
copy
(
"
latex/bin/{}.pdf
"
.
format
(
name
),
"
documents/pdf/
"
)
for
typ
in
[
"
pdf
"
,
"
log
"
,
"
aux
"
,
"
out
"
]:
silent_remove
(
"
latex/bin/{}.{}
"
.
format
(
name
,
typ
))
silent_remove
(
"
latex/{}.tex
"
.
format
(
name
))
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
()
target_filename
=
"
compiled-{}.pdf
"
.
format
(
document
.
id
)
document
.
filename
=
target_filename
shutil
.
copy
(
os
.
path
.
join
(
compile_dir
,
protocol_target_filename
),
os
.
path
.
join
(
"
documents
"
,
target_filename
))
db
.
session
.
commit
()
except
subprocess
.
SubprocessError
:
is_error
=
True
with
app
.
app_context
():
document
=
Document
.
query
.
filter_by
(
id
=
document_id
).
first
()
if
document
is
not
None
:
document
.
ready
=
False
document
.
error
=
True
log
=
""
total_log_filename
=
os
.
path
.
join
(
compile_dir
,
log_filename
)
if
os
.
path
.
isfile
(
total_log_filename
):
with
open
(
total_log_filename
,
"
r
"
)
as
log_file
:
log
=
log_file
.
read
()
else
:
log
=
"
Logfile not found.
"
error
=
protocol
.
create_error
(
"
Compiling
"
,
"
Compiling LaTeX failed
"
,
log
)
db
.
session
.
add
(
error
)
db
.
session
.
commit
()
finally
:
# TODO: activate deleting files in error case too
#for typ in ["pdf", "log", "aux", "out"]:
# silent_remove("latex/bin/{}.{}".format(name, typ))
#silent_remove("latex/{}.tex".format(name))
os
.
chdir
(
current
)
if
not
is_error
:
with
app
.
app_context
():
document
=
Document
.
query
.
filter_by
(
id
=
document_id
).
first
()
if
document
is
not
None
:
document
.
ready
=
True
db
.
session
.
commit
()
def
send_mail
(
mail
):
send_mail_async
.
delay
(
mail
.
id
)
...
...
This diff is collapsed.
Click to expand it.
templates/proto
kol
l.tex
→
templates/proto
co
l.tex
+
3
−
3
View file @
72e8a882
...
...
@@ -33,7 +33,7 @@
\begin{itemize}
\ENV
{
if protocol.decisions|length > 0
}
\ENV
{
for decision in protocol.decisions
}
\item
\VAR
{
decision
s
.content|escape
_
tex
}
\item
\VAR
{
decision.content|escape
_
tex
}
\ENV
{
endfor
}
\ENV
{
else
}
\item
Keine Beschlüsse
...
...
@@ -43,8 +43,8 @@
Beginn der Sitzung:
\VAR
{
protocol.start
_
time|timify
}
\ENV
{
for top in tree.children
}
\TOP
{
\VAR
{
top.name
}}
% here we probably have information doubly
\VAR
{
top.render()
}
\TOP
{
\VAR
{
top.name
|escape
_
tex
}}
% here we probably have information doubly
\VAR
{
top.render()
|escape
_
tex
}
\ENV
{
endfor
}
Ende der Sitzung:
\VAR
{
protocol.end
_
time|timify
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment