% vim: set ft=tex
\ProvidesClass{podcastproto}

\LoadClass[
 DIV=20,
 parskip=half,
]{scrartcl}

% hyphenation
\RequirePackage[ngerman]{babel}

% cretion of nice dates from numbers
\RequirePackage[useregional]{datetime2}

% if conditions for commands
\RequirePackage{etoolbox}

% key-value pairs for command options
\RequirePackage{xkeyval}

% attachments
\RequirePackage{pdfpages}

% links/pdf toc
\RequirePackage[unicode, hidelinks]{hyperref}

% roman font for title
\addtokomafont{disposition}{\rmfamily}

% No dots in TOC
% https://tex.stackexchange.com/a/53899
\makeatletter
\renewcommand\@dotsep{1000}
\makeatother

% no page numbers
\pagenumbering{gobble}

% only subsection in agenda
\setcounter{tocdepth}{\sectiontocdepth}

\makeatletter
\define@key{meta}{number}{\def\Number{#1}}
\define@key{meta}{date}{\def\Date{#1}}
\define@key{meta}{present}{\def\PeoplePresent{#1}}
\define@key{meta}{absent}{\def\PeopleAbsent{#1}}
\define@key{meta}{duration}{\def\Duration{#1}}
\define@key{meta}{location}{\def\Location{#1}}
\define@key{meta}{chairperson}{\def\Chairperson{#1}}
\define@key{meta}{secretary}{\def\Secretary{#1}}
\define@key{meta}{secretaryAddress}{\def\SecretaryAddress{#1}}
\define@key{meta}{attachments}{\def\Attachments{#1}}
\setkeys{meta}{
 duration=15:55 bis 17:25,
 location=Raum 126 der Christian-von-Bomhard-Schule Uffenheim,
 chairperson=redigiert
}
\makeatother

% header
\newcommand*{\header}[1][]{
 \begingroup
  \setkeys{meta}{#1}

  {\DTMsetstyle{pdf}
  \hypersetup{
   pdftitle={P-Seminar „Einen Podcast erstellen“ -- Niederschrift über die \Number. Sitzung},
   pdfauthor={\Secretary},
   pdfinfo={
    CreationDate={\Date}
   }
  }}

  \begin{center}
   {\bfseries
    {\Large
     Christian-von-Bomhard Schule \\
     P-Seminar „Einen Podcast erstellen“
    }

    \vspace{2em}

    Niederschrift \\
    über die \\
    \Number. Sitzung \\
    am \Date
   }
  \end{center}

  \vspace{2em}

  \begin{tabular}{l l}
   Anwesend:          & \PeoplePresent\ Seminarteilnehmende \\
   \ifdef{\PeopleAbsent}{Abwesend: & \PeopleAbsent \\}{}
   Zeit:              & \Duration\\
   Ort:               & \Location \\
   Vorsitzende:       & \Chairperson \\
   \SecretaryAddress: & \Secretary \\
   \ifdef{\Attachments}{Anlagen: & \Attachments \\}{}
  \end{tabular}
 \endgroup

 % End (needs to access variables from header)
 \newcommand*\protoend{
  \begingroup
   \setkeys{meta}{#1}
   \filbreak % rather break here than somewhere we don’t need it

   \vspace{5mm}
   Uffenheim, \Date
   \vspace{5mm}

   \makebox[6cm][c]{\textbf{\SecretaryAddress:}}\hfill
   \makebox[6cm][c]{\textbf{Vorsitzende:}}
   \vspace{1.5cm}\par
   \makebox[6cm]{\hrulefill} \hfill\makebox[6cm]{\hrulefill} \\
   \makebox[6cm][c]{(\Secretary)}    \hfill\makebox[6cm][c]{(\Chairperson)}
  \endgroup
 }
}

% Agenda
\newcommand*{\agenda}{
 \DeclareTOCStyleEntry[]{undottedtocline}{section}
 \renewcommand*{\contentsname}{Tagesordnung}
 \tableofcontents
}
