%% Package declaration
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fripost}
\RequirePackage{calc}
\RequirePackage{graphicx}
%    \end{macrocode}
%% Colours
%    \begin{macrocode}
\PassOptionsToPackage{svgnames}{xcolor}
\RequirePackage{xcolor}
\colorlet{fpgray}{white!30!black}
\definecolor{grayFri}{gray}{.3}
%    \end{macrocode}
%% Font macros and basic paragraph formatting
%    \begin{macrocode}
\RequirePackage{lmodern}
\RequirePackage{helvet}
\RequirePackage{soul}
\PassOptionsToPackage{hyphens}{url}
\RequirePackage{url}
\RequirePackage{parskip}
\RequirePackage{multicol}
\RequirePackage{hyphenat}
\newcommand \textemail [1] {\texttt{\small #1}}
\newcommand \texturl [1] {\texttt{\small #1}}
\newcommand \textpath [1] {\texturl{#1}}
\newcommand \texthost [1] {\textit{#1}}
\newcommand \titlefont {\Large\sffamily\mdseries\color{grayFri}}
\newcommand \descriptionfont {\bfseries\color{grayFri}}
\newcommand \textestemate [1] {{\small\sffamily\mdseries\color{grayFri} #1}}
%    \end{macrocode}
%% Options
%    \begin{macrocode}
\newif\if@minutes\@minutesfalse
\newif\if@bylaws\@bylawsfalse
\newif\if@report\@reportfalse
\newcommand\resetopts{\@minutesfalse\@bylawsfalse\@reportfalse}
\DeclareOption{standalone}{\resetopts}
\DeclareOption{minutes}{\resetopts\@minutestrue}
\DeclareOption{by-laws}{\resetopts\@bylawstrue}
\DeclareOption{report}{\resetopts\@reporttrue}
\ExecuteOptions{report}
\ProcessOptions\relax
%    \end{macrocode}
%% Titling
%    \begin{macrocode}
\RequirePackage{titling}
\pretitle{\titlefont\centering}
\posttitle{%
  \if@minutes~--~\fi%
  \if@bylaws~--~\fi%
  \if@report\\[.2\baselineskip]\fi}
\preauthor{%
  \titlefont\centering%
  \if@report\normalsize\fi}
\postauthor{
  \if@minutes\\\fi%
  \if@bylaws\\\fi%
  \if@report~--~\fi}
\predate{%
  \titlefont\centering%
  \if@bylaws\color{white}\fi%
  \if@report\normalsize\fi}
\postdate{%
  \par%
  \if@minutes\vspace{-0.5\baselineskip}\fi%
  \if@bylaws\vspace{-1.4\baselineskip}\fi%
  \if@report\vspace{-0.5\baselineskip}\fi}
\setlength{\droptitle}{-4\baselineskip}
%    \end{macrocode}
%% Sections
%    \begin{macrocode}
\@ifclassloaded{article}{
  \RequirePackage{sectsty}
  \setcounter{secnumdepth}{3} % section numbering by default
  \allsectionsfont{%
    \sffamily\mdseries\color{grayFri}%
    \if@minutes\normalsize\fi
    \if@bylaws\normalsize\fi
  }
  \paragraphfont{\rmfamily\normalsize}
  \subparagraphfont{\rmfamily\normalsize}
  \def\@seccntformat#1{ % section formatting
    \if@bylaws\S\ \fi % paragraph sign for policy
    \csname the#1\endcsname % numbering
    \quad % space
  }
  
}{}
\@ifclassloaded{leaflet}{
  \RequirePackage{sectsty}
  \allsectionsfont{%
    \sffamily\mdseries\color{grayFri}%
    \centering}
}{}
%    \end{macrocode}
%% Enumeration
%    \begin{macrocode}
\RequirePackage{enumerate}
\newcommand \enumiform {\quad\sffamily\small\color{grayFri}}
\newcommand \textenumerate [1] {{\quad\sffamily\small\color{grayFri} #1}}
\renewcommand{\labelitemi}{\textenumerate{$\bullet$}}
\renewcommand{\labelitemii}{\textenumerate{$\circ$}}
\renewcommand{\labelenumi}{\textenumerate{\arabic{enumi}\,\,}}
\renewcommand{\labelenumii}{\textenumerate{(\alph{enumii})}}
\renewcommand{\descriptionlabel}[1]{%
  \hspace{\labelsep}{\descriptionfont #1}}
%    \end{macrocode}
%% Abstract
%%
%% Note that the fancy page style is issued as part of the
%% abstract. That is due to that \maketitle command issues the plain
%% page style.
%    \begin{macrocode}
\@ifclassloaded{article}{
  \def\abstract{%
    \if@minutes\thispagestyle{fancy}\fi%
    {\descriptionfont \abstractname}\par
    }
}{}
%    \end{macrocode}
%% Headers
%    \begin{macrocode}
\@ifclassloaded{article}{
  \RequirePackage{authoraftertitle}
  \RequirePackage{fancyhdr}
  \RequirePackage{lastpage}
  \setlength {\headheight} {30pt}

  \renewcommand{\headrule}{{%
      \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}

  \renewcommand{\footrule}{{%
      \vskip-\footruleskip\vskip-\footrulewidth
      \hrule width\headwidth height\headrulewidth\vskip\footruleskip}}

  \pagestyle{fancy}
  \lhead{\footnotesize{\sffamily{\bfseries fripost} | demokratisk e-post}}
  \chead{\footnotesize}
  \rhead{\footnotesize \MyTitle, \MyDate}
  \lfoot{\footnotesize \url{fripost.org}}
  \cfoot{\footnotesize \thepage}
  \rfoot{\footnotesize utskr.\ \today}
}{}
%    \end{macrocode}
%% Time estimations in meeting agendas
%    \begin{macrocode}
\newcommand \itemtime [2] {%
  \hfill\textestemate{#1\quad{}#2}\hspace{2cm}\mbox{}%
}
%    \end{macrocode}
%% Signature line
%    \begin{macrocode}
\newcommand{\signatureline}[1]{%
  \noindent%
    \parbox{6.5cm}{%
      \mbox{}\vspace{1.5cm}\\%
      \rule{\linewidth}{0.4pt}\\%
      #1%
    }%
}%
%    \end{macrocode}
