% Copyright (C) 2018-2019 Mohammad Akhlaghi <mohammad@akhlaghi.org>
%
% This LaTeX source is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation, either version 3 of the
% License, or (at your option) any later version.
%
% This LaTeX source is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this LaTeX source.  If not, see <https://www.gnu.org/licenses/>.

\begin{columns}[t]
  \column{5cm}
  \vspace{-0.4cm}

  \begin{tikzpicture}

    \draw [white] (0,0) -- (0,7.4);

    %% Template branch.
    \ifdefined\tofuture
      \draw[->, line width=2mm] (0,0) -- (0,7.3);
    \else
      \ifdefined\tempevolve
        \draw[->, line width=2mm] (0,0) -- (0,5.5);
      \else
        \draw[->, line width=2mm] (0,0) -- (0,2.3);
      \fi
    \fi

    %% Project branch.
    \ifdefined\projinit
      \draw[line width=2mm] (0,1.5) -- (1,2);
      \ifdefined\tofuture
        \draw[->, line width=2mm] (0.95,1.92) -- (0.95,7.3);
      \else
        \ifdefined\mergewithtemp
          \draw[->, line width=2mm] (0.95,1.92) -- (0.95,5.7);
        \else
          \ifdefined\projwork
            \draw[->, line width=2mm] (0.95,1.92) -- (0.95,5);
          \else
            \draw[->, line width=2mm] (0.95,1.92) -- (0.95,3);
          \fi
        \fi
      \fi
    \fi

    %% Merge link
    \ifdefined\mergewithtemp
    \draw[line width=2mm] (0,4.5) -- (0.95,5.05);
    \fi

    %% COMMITS: Note that commits have to come after the branches,
    %% otherwise the black lines are going to be over the commit
    %% circles.

    %% Template commits.
    \draw[anchor=north] (0,0) node {\textbf{Template}};
    \draw [fill=green!80!blue, opacity=0.5] (0,0.55cm) circle [radius=2.1mm];
    \draw[anchor=east] (-5pt,0.55cm) node {\tiny\texttt{ad2c476}};
    \draw [fill=green!80!blue, opacity=0.5] (0,1.55cm) circle [radius=2.1mm];
    \draw[anchor=east] (-5pt,1.55cm) node {\tiny\texttt{706c644}};
    \ifdefined\tempevolve
      \draw [fill=green!80!blue, opacity=0.5] (0,2.55cm) circle [radius=2.1mm];
      \draw[anchor=east] (-5pt,2.55cm) node {\tiny\texttt{fa2ac10}};
      \draw [fill=green!80!blue, opacity=0.5] (0,3.55cm) circle [radius=2.1mm];
      \draw[anchor=east] (-5pt,3.55cm) node {\tiny\texttt{1e06fe2}};
      \draw [fill=green!80!blue, opacity=0.5] (0,4.55cm) circle [radius=2.1mm];
      \draw[anchor=east] (-5pt,4.55cm) node {\tiny\texttt{32043ee}};
      \ifdefined\tofuture
        \draw [fill=green!80!blue, opacity=0.5] (0,5.55cm) circle [radius=2.1mm];
        \draw[anchor=east] (-5pt,5.55cm) node {\tiny\texttt{2d808f2}};
        \draw [fill=green!80!blue, opacity=0.5] (0,6.55cm) circle [radius=2.1mm];
        \draw[anchor=east] (-5pt,6.55cm) node {\tiny\texttt{a4d96c0}};
      \fi
    \fi


    %% Project commits.
    \ifdefined\projinit
      \draw[anchor=north] (1,1.7) node {\textbf{Project}};
      \draw [fill=red!60!green, opacity=0.5] (0.95,2) circle [radius=2.1mm];
      \draw[anchor=west] (1.1,2) node {\tiny\texttt{53b53d6}};
      \ifdefined\projwork
        \draw [fill=red!60!green, opacity=0.5] (0.95,3) circle [radius=2.1mm];
        \draw[anchor=west] (1.1,3) node {\tiny\texttt{9f8cc74}};
        \draw [fill=red!60!green, opacity=0.5] (0.95,4) circle [radius=2.1mm];
        \draw[anchor=west] (1.1,4) node {\tiny\texttt{8ebb784}};
        \ifdefined\mergewithtemp
          \draw [fill=red!60!green, opacity=0.5] (0.95,5) circle [radius=2.1mm];
          \draw[anchor=west] (1.1,5) node {\tiny\texttt{01ce2cc}};
          \ifdefined\tofuture
            \draw [fill=red!60!green, opacity=0.5] (0.95,6) circle [radius=2.1mm];
            \draw[anchor=west] (1.1,6) node {\tiny\texttt{b52cc6f}};
          \fi
        \fi
      \fi
    \fi

    %% Happy scientist
    \ifdefined\githappy
    \node [inner sep=0pt] at (3.5,4) {\includegraphics[width=2cm]{img/happy.jpg}};
    \node [inner sep=0pt] at (4.15,5.3) {\includegraphics[width=0.2cm]{img/checkmark.png}};
    \draw [<->, red, line width=0.2mm] plot [smooth, tension=2] coordinates
          { (1.9,6.15) (4,6) (4.8,5.25) };
    \draw[anchor=south] (4.5,5) node [rotate=20] {\tiny\texttt{b52cc6f}};

    \ifdefined\gitverified
      \node [inner sep=0pt] at (3.5,1.5) {\includegraphics[width=3cm]{img/verified.png}};
    \fi
    \fi

  \end{tikzpicture}

  \column{8cm}
  \vspace{-1cm}
  \begin{itemize}
    \setlength\itemsep{0.2cm}
  \item Template's history is recorded in Git.
  \ifdefined\projinit
    \item New project: a branch from the template.\\
      Recall that \alert{every commit} contains the following:
      \begin{itemize}
      \item Instructions to download, verify and build \alert{software}.
      \item Instructions to download and verify input \alert{data}.
      \item Instructions to run software on data (do the \alert{analysis}).
      \item Narrative description of project's purpose/\alert{context}.
      \end{itemize}
  \fi
  \ifdefined\projwork
    \item Research progresses in the project branch.
  \fi
  \ifdefined\tempevolve
    \item Template will evolve (improved infrastructure).
  \fi
  \ifdefined\mergewithtemp
    \item Template can be imported/merged back into project.
  \fi
  \ifdefined\tofuture
    \item The template and project will \alert{evolve}.
    \item During research this \alert{encourages creative tests}\\
      (previous research states can easily be retrieved).
    \item \alert{Coauthors} can work on same project in parallel
      \\(separate project branches).
  \fi
  \ifdefined\githappy
    \item Upon \alert{publication}, the \alert{Git checksum} is enough
      to verify the integrity of the result.
  \fi
  \end{itemize}

  \ifdefined\gitverified
  \vspace{3mm}
  \hfill\tiny ``Verified'' image from \href{https://www.vectorstock.com/royalty-free-vector/red-vintage-verified-stamp-retro-style-on-white-vector-22770076}{vectorstock.com}
  \fi
\end{columns}
