chore(letter): improve certificate interpolation and styling
This commit is contained in:
parent
db0eadc746
commit
879b8a72be
@ -21,7 +21,7 @@ import qualified Data.CaseInsensitive as CI
|
||||
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
-- import qualified Data.ByteString.Lazy as LBS
|
||||
-- import qualified Data.Time.Zones as TZ
|
||||
|
||||
import Database.Esqueleto.Experimental ((:&)(..))
|
||||
@ -134,7 +134,10 @@ postTUsersR tid ssh csh tutn = do
|
||||
apcIdent <- letterApcIdent l encRcvr now
|
||||
renderLetter rcvr l apcIdent >>= \case
|
||||
Left err -> sendResponseStatus internalServerError500 $ "PDF generation failed: \n" <> err
|
||||
Right pdf -> void $ sendByteStringAsFile "demoPDF.pdf" (LBS.toStrict pdf) now
|
||||
Right pdf -> do -- void $ sendByteStringAsFile "demoPDF.pdf" (LBS.toStrict pdf) now
|
||||
let typePDF :: ContentType
|
||||
typePDF = "application/pdf"
|
||||
sendResponse (typePDF, toContent pdf)
|
||||
_ -> addMessageI Error MsgErrorUnknownFormAction
|
||||
(TutorialUserGrantQualificationData{..}, selectedUsers)
|
||||
| tuQualification `Set.member` courseQids -> do
|
||||
|
||||
@ -138,7 +138,7 @@ renderLetter rcvrEnt@Entity{entityVal=rcvr} mdl apcIdent = do
|
||||
formatter@DateTimeFormatter{ format } <- getDateTimeFormatterUser' rcvr
|
||||
let lang = selectDeEn $ rcvr & userLanguages -- select either German or English only, default de; see Utils.Lang
|
||||
kind = getLetterKind $ pure mdl
|
||||
tmpl = getTemplate $ pure mdl
|
||||
tmpl = getTemplate mdl
|
||||
meta = addApcIdent apcIdent
|
||||
<> letterMeta mdl formatter lang rcvrEnt
|
||||
<> mkMeta
|
||||
|
||||
@ -9,7 +9,7 @@ module Utils.Print.CourseCertificate where
|
||||
import Import
|
||||
|
||||
-- import Data.Char as Char
|
||||
-- import qualified Data.Text as Text
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
|
||||
import Data.FileEmbed (embedFile)
|
||||
@ -37,6 +37,9 @@ instance MDLetter LetterCourseCertificate where
|
||||
encrypPDFfor _ = NoPassword
|
||||
getLetterKind _ = Plain
|
||||
getLetterEnvelope _ = 'c'
|
||||
getTemplate LetterCourseCertificate{ccCourseContent = Just ccc} =
|
||||
Text.replace "%%%course-content%%%" (unlines ccc) $
|
||||
decodeUtf8 $(Data.FileEmbed.embedFile "templates/letter/fraport_qualification.md")
|
||||
getTemplate _ = decodeUtf8 $(Data.FileEmbed.embedFile "templates/letter/fraport_qualification.md")
|
||||
|
||||
letterMeta LetterCourseCertificate{..} DateTimeFormatter{ format } lang _rcvrEnt =
|
||||
|
||||
@ -225,7 +225,7 @@ class MDLetter l where
|
||||
getPJId :: l -> PrintJobIdentification
|
||||
getLetterEnvelope :: l -> Char
|
||||
getLetterKind :: Proxy l -> LetterKind
|
||||
getTemplate :: Proxy l -> Text
|
||||
getTemplate :: l -> Text
|
||||
encrypPDFfor :: Proxy l -> EncryptPDFfor
|
||||
|
||||
letterApcIdent :: (MDLetter l, MonadHandler m) => l -> CryptoUUIDUser -> UTCTime -> m Text
|
||||
|
||||
@ -1,49 +1,69 @@
|
||||
---
|
||||
### Metaddaten, welche hier eingestellt werden:
|
||||
|
||||
# keine
|
||||
### Metadaten, welche automatisch ersetzt werden:
|
||||
lang: de-de
|
||||
is-de: true
|
||||
date: 11.11.1111
|
||||
test1: this **is really** a test
|
||||
test2: 'this **is another** test'
|
||||
test3: |
|
||||
<h1>First</h1>
|
||||
<p>Here is some text with <em>emphasis</em> to see.
|
||||
...
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
$if(is-de)$
|
||||
|
||||
# Teilnahmebescheinigung
|
||||
\medskip
|
||||
|
||||
## $participant$
|
||||
\begin{huge}\sffamily\textbf{Teilnahmebescheinigung}\end{huge}
|
||||
|
||||
\vspace{\fill}
|
||||
|
||||
# $participant$ {-}
|
||||
$if(fra-number)$
|
||||
### $fra-number$ $fra-department$
|
||||
## $fra-number$ $fra-department$ {-}
|
||||
$endif$
|
||||
|
||||
$if(company)$
|
||||
### $company$
|
||||
## $company$ {-}
|
||||
$endif$
|
||||
|
||||
Hat
|
||||
hat
|
||||
$if(course-begin)$
|
||||
von $course-begin$ bis $course-end$
|
||||
$endif$
|
||||
an der Veranstaltung
|
||||
|
||||
## $course-name$
|
||||
|
||||
\centerline{\sffamily\LARGE{$course-name$}}
|
||||
der Fahrerausbildung der Fraport AG teilgenommen.
|
||||
|
||||
$if(course-content)$
|
||||
### Inhalte:
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
|
||||
$if(course-content)$
|
||||
## Inhalte: {-}
|
||||
|
||||
|
||||
%%%course-content%%%
|
||||
|
||||
|
||||
$course-content$
|
||||
$endif$
|
||||
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
|
||||
Mit Aushändigung der Teilnahmebescheinigung wird der erfolgreiche Abschluss des Kurses bestätigt.
|
||||
Dieses Zertifikat wurde maschinell erstellt.
|
||||
|
||||
\medskip
|
||||
|
||||
Frankfurt am Main, $date$
|
||||
|
||||
Fraport College
|
||||
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
\vspace{\fill}
|
||||
|
||||
<!-- deutsche version -->
|
||||
|
||||
$else$
|
||||
|
||||
@ -57,8 +57,9 @@ $endif$
|
||||
\usepackage{DejaVuSansMono} % better monofont
|
||||
\else
|
||||
% if luatex or xetex
|
||||
\usepackage{fontspec}
|
||||
\usepackage{fontspec}
|
||||
\setmonofont{DejaVu Sans Mono}
|
||||
%\renewcommand{\familydefault}{\sfdefault}
|
||||
\fi
|
||||
|
||||
$if(mathspec)$
|
||||
@ -96,6 +97,8 @@ $endif$
|
||||
\providecommand{\tightlist}{%
|
||||
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\begin{document}%
|
||||
$if(apc-ident)$
|
||||
\begin{textblock}{200}(5,5)%hpos,vpos
|
||||
|
||||
@ -942,11 +942,11 @@ fillDb = do
|
||||
, courseTerm = tk
|
||||
, courseSchool = avn
|
||||
, courseCapacity = capacity
|
||||
, courseVisibleFrom = jtt TermDayStart 0 Nothing toMidnight
|
||||
, courseVisibleTo = jtt TermDayEnd 0 Nothing beforeMidnight
|
||||
, courseRegisterFrom = jtt TermDayStart 0 Nothing toMidnight
|
||||
, courseRegisterTo = jtt TermDayLectureStart (-1) Nothing toMidnight
|
||||
, courseDeregisterUntil = jtt TermDayLectureStart (-5) (Just Monday) toMidnight
|
||||
, courseVisibleFrom = jtt TermDayStart 1 Nothing toMidnight
|
||||
, courseVisibleTo = jtt TermDayEnd 10 Nothing beforeMidnight
|
||||
, courseRegisterFrom = jtt TermDayLectureStart 0 Nothing toMidnight
|
||||
, courseRegisterTo = jtt TermDayLectureStart 1 Nothing toMidnight
|
||||
, courseDeregisterUntil = jtt TermDayLectureStart 5 (Just Monday) toMidnight
|
||||
, courseRegisterSecret = Nothing
|
||||
, courseMaterialFree = True
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user