
(% macro cdate(inp) %)(( inp | formatDate | capitalize | trim ))(% endmacro %)

\documentclass[9pt]{article}
\usepackage{extsizes}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[english,french]{babel}
\usepackage{url,parskip} 	    % other packages for formatting
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage[margin=2.5cm,top=1.5cm]{geometry}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{array}
\usepackage{enumitem}
\usepackage{longtable} 	
\usepackage{etoolbox}
\usepackage{tikz}
\usepackage[skins]{tcolorbox}
\usepackage{fancyhdr}
\usepackage[inkscapepath=./build/latex/inkscape-svg]{svg}
\usepackage{verbatimbox}
\usepackage{stackengine}

\newcommand\svgsize{10pt}

\definecolor{basecolor}{HTML}{000066}       %BLUE
\definecolor{accentcolor}{HTML}{318440}
\definecolor{darkGrey}{HTML}{989898}
\definecolor{light}{HTML}{828282}

\colorlet{linkcolor}{basecolor}
\colorlet{symbolcolor}{linkcolor!85}

\pagestyle{fancy}
\fancyhf{}
\fancyhfoffset{0em}
\fancyfoot{}
\fancyfoot[L]{(( misc.updated_at | format_date(locale=getLocale()) ))}
\fancyfoot[C]{(( firstName )) (( lastName )) - CV}
\fancyfoot[R]{\thepage}

\newcommand\link[2]{\color{linkcolor}\href{#1}{#2}\color{Black} }

% Remove head rule
\renewcommand{\headrulewidth}{0pt}
%\fancyfoot[C]{\thepage}

% Configure list
\setlist[itemize,1]{label=-, nosep, leftmargin=2em} 
\setlist[itemize,2]{label=-, nosep, leftmargin=1.5em} 

% Setup Array : new column type
\newcolumntype{R}[1]{>{\hfill}m{#1}}

%Italian hyphenation for the word: ''corporations''
\hyphenation{im-pre-se}

\newlength{\rightcolumnlength}
\setlength{\rightcolumnlength}{12.5cm}

\newlength{\leftcolumn}
\setlength{\leftcolumn}{3cm}


\newcommand{\cvtag}[1]{
    \tikz[baseline]\node[anchor=base,draw=darkGrey!70,rounded corners=0.5ex,inner xsep=1ex,inner ysep=0.55ex,text height=1.59ex,text depth=.25ex]{\color{light}#1};\hspace{-.5em}
}

% \newcommand{\sectionTitle}[1]{
%     \color{accentcolor}\textsc{\Large{#1}}
%     \\
%     \color{darkGrey}\rule{\textwidth}{0.4pt} 
%     \color{black}
% }

\titleformat{\section}{\Large\raggedright}{}{0em}{}[\titlerule]
\titlespacing{\section}{0pt}{2pt}{2pt}

% \newcommand\sectionTitle[2]{\section{\texorpdfstring{\color{accentcolor}#2\enspace \textsc{#1}}{#1}}}
\newcommand\sectionTitle[1]{\section{\texorpdfstring{\color{accentcolor}\textsc{#1}}{#1}}\vspace{5px}}

% Define the 'keywords' environment
\newenvironment{keywords}{%
  \renewcommand{\arraystretch}{1.1}

  \begin{tabular}{>{}r>{}p{13cm}} 
}{%
  \end{tabular}
}

\newcommand\keywordsentry[2]{
  \textbf{#1} &   #2\\ 
}


\def\@photo{./public/imgs/profile-512.jpg}

\newcolumntype{E}{>{\raggedright\arraybackslash}p{\rightcolumnlength}}

\newenvironment{experiences}{%
  \begin{longtable}{R{\leftcolumn}|E}
}{%
  \end{longtable}
}


\newcommand\emptySeparator{\multicolumn{2}{c}{}\\}

\newlength\myheight
\newlength\mydepth
\settototalheight\myheight{Xygp}
\settodepth\mydepth{Xygp}
\setlength\fboxsep{0pt}
\newcommand*\inlinegraphics[1]{%
  \settototalheight\myheight{Xygp}%
  \settodepth\mydepth{Xygp}%
  \raisebox{-\mydepth}{\includesvg[height=\myheight]{public/imgs/#1}}%
}


\newcommand{\sociallink}[3]{\mbox{\textcolor{symbolcolor}{#1}\hspace{0.5em}\link{#2}{#3}\hspace{1em}}}
% \newcommand{\iconwithtext}[2]{\bottominset{\small#1}{\includesvg[width=10pt]{./public/imgs/#2}}{2pt}{26pt}}
\newcommand{\iconwithtext}[2]{\inlinegraphics{#1}\hspace{0.3em}#2\hspace{0.5em}}

\begin{document}
    % \section{\color{accentcolor} \textsc{Hello World}}{Hello world}
    \begin{minipage}{\dimexpr\linewidth-3cm}
        \noindent{\huge{((firstName)) \textbf{((lastName))}}}
        \vspace{5px}
        \\
        \noindent\color{accentcolor}\textbf{\large{(( getDynLocalizedStr(label) ))}}\color{black}
        \vspace{5px}\\
        \iconwithtext{icons/map-pin.svg}{(( location.city.name )), (( location.country.name ))}
        \\
        \iconwithtext{icons/cake.svg}{(( getLocalizedStr('intro.age-raw') | format(age) ))}
        \\
        % \sociallink{\includesvg[width=10pt,height=9pt]{./public/imgs/icons/robot.svg}}{https://matthieubessat.fr}{matthieubessat.fr}
        \iconwithtext{icons/at.svg}{\link{mailto:(( email ))}{(( email ))}}
        \iconwithtext{icons/phone.svg}{\link{(( phone | replace({' ':''}) ))}{(( phone ))}}
        \\
        \iconwithtext{icons/link.svg}{\link{(( website ))}{(( website_alt ))}}
        \iconwithtext{logos/github.svg}{\link{(( links_by_ids.github.url ))}{(( links_by_ids.github.username ))}}
        \iconwithtext{logos/gitlab.svg}{\link{(( links_by_ids.gitlab.url ))}{(( links_by_ids.gitlab.username ))}}
        % Website, Email, Location, Age
        
        % \includesvg[width=\svgsize]{./public/imgs/icons/robot.svg}
    \end{minipage}
    \begin{minipage}{3cm}
        \tikz\path[fill overzoom image={\@photo}]circle[radius=0.45\linewidth];
    \end{minipage}
    \\
    \vspace{8px}
    \par{(( getDynLocalizedStr(intro) | raw ))}
    \\

    % Section: Skills
    \sectionTitle{(( getLocalizedStr('skills.title') ))}
    \begin{keywords}
        (% for skill in skills %)
        \keywordsentry{(( getDynLocalizedStr(skill.name) ))}{(% for k in skill.keywords %)(( k ))(% if not loop.last %), (% endif %)(% endfor %)}
        (% endfor %)
    \end{keywords}
    \vspace{.5em}
    
    % Section: Professionals experiences
    \sectionTitle{(( getLocalizedStr('experience.pro') ))}
    \begin{longtable}{R{\leftcolumn}|E}
    (% for exp in pro_projects %)
    \textbf{(( _self.cdate(exp.to) ))} & 
        (% if exp.detailled %)
            \link{(( website ))/(( getLocale() ))/projects/(( exp.id )).html}{%
        (% endif %)
        \textbf{(( getDynLocalizedStr(exp.name) ))}(% if exp.detailled %)}(% endif %) \\*
    \textbf{(( _self.cdate(exp.from) ))} & \textsc{(( exp.organization.name ))} (% if exp.organization.location is defined %), (( exp.organization.location ))(% endif %) \\*
                          & \par{(( getDynLocalizedStr(exp.description) | raw ))} \\
         (% if exp.highlights is defined %)
         & \begin{minipage}[t]{\rightcolumnlength}
                    \begin{itemize}
                        (% for h in exp.highlights[getLocale()] %)
                        \item{(( h | raw ))}
                        (% endfor %)
                    \end{itemize}
                   \end{minipage} \\*
        (% endif %)
        \vspace{.5em} 
         & \hspace{-.2em}\footnotesize{(% for t in exp.technologies %)\cvtag{(( t.name ))}(% endfor %)} \\
        \emptySeparator
    (% endfor %)
    \end{longtable}

    % Section: Side projects
    \sectionTitle{(( getLocalizedStr('projects.side.title') | raw ))}
    \par{(( getLocalizedStr('projects.side.description') | raw ))}
    \begin{longtable}{l}
        (% for exp in side_projects %)
        \begin{minipage}[t]{\dimexpr(\linewidth) - 1.5em}
        
        (% if exp.detailled %)
            \link{(( website ))/(( getLocale() ))/projects/(( exp.id )).html}{%
        (% endif %)
        \textbf{\textsc{(( getDynLocalizedStr(exp.name) | raw ))}}%
        (% if exp.detailled %)}(% endif %)
        \hfill \textsc{(( exp.date | format_date(locale=getLocale(), pattern='YYYY') ))}\smallskip\\
        \iconwithtext{(( exp.link_icon ))}{\link{(( exp.link ))}{(( exp.link_alt ))}}
        \vspace{.4em} 
        \\
        (( getDynLocalizedStr(exp.description) | raw ))\vspace{.4em}\\
        \footnotesize{(% for t in exp.technologies %)\cvtag{(( t.name ))}(% endfor %)}\\
        \end{minipage}
        (% if not loop.last %) 
        \vspace{.5em}
        \\*
        (% endif %)
        (% endfor %)
    \end{longtable}

    % Section: Volunteering experiences
    \sectionTitle{(( getLocalizedStr('projects.volunteering.title') ))}
    \begin{longtable}{R{\leftcolumn}|E}
    (% for exp in volunteering %)
    \textbf{(( _self.cdate(exp.date) ))} & \textbf{(( getDynLocalizedStr(exp.name) ))} \\*
                                       & \textsc{(( exp.organization.name ))} \\
                                       & \par{(( getDynLocalizedStr(exp.description) | raw ))} \\
        (% if not loop.last %)
        \emptySeparator
        (% endif %)
    (% endfor %)
    \end{longtable}


    \vspace{1em}
    \pagebreak

    % Section: Education
    \sectionTitle{(( getLocalizedStr('education.title') ))}
    \begin{longtable}{R{\leftcolumn}|E}
    (% for exp in education %)
    \textbf{(( _self.cdate(exp.to) ))} & \textbf{(( getDynLocalizedStr(exp.name) ))} \\*
    \textbf{(( _self.cdate(exp.from) ))} & \textsc{(( exp.facility.name ))}, (( exp.facility.city )), (( exp.facility.country )) \\*
         % & \begin{minipage}[t]{\rightcolumnlength}
         %            \begin{itemize}
         %                \item{hello}
         %                \item{hello}
         %                \item{hello}
         %            \end{itemize}
         %           \end{minipage} \\
           & (% if exp.degree is defined %)(( getLocalizedStr('education.degree-got') | format(exp.degree.name) | raw )) (% if exp.degree.title is defined %) (( getLocalizedStr('education.degree-title') | format(exp.degree.title) | raw ))(% endif %)(% endif %) \\*
        (% if not loop.last %)
        \emptySeparator
        (% endif %)
    (% endfor %)
    \end{longtable}
    \vspace{.5em}

    \sectionTitle{(( getLocalizedStr('interests.title') | raw ))}
    \begin{itemize}
        (% for item in interests %)
        \item{\iconwithtext{icons/(( item.icon ))}{(( getDynLocalizedStr(item.name) ))}}
        (% endfor %)
    \end{itemize}
    \vspace{1.1em}
    % Section: Langues
    \sectionTitle{(( getLocalizedStr('languages.title') ))}
    \begin{keywords}
        (% for lang in languages %)
        \keywordsentry{(( getLocalizedStr(lang.long) ))}{(( getLocalizedStr('fluency.' ~ lang.level) ))}
        (% endfor %)
    \end{keywords}

\end{document}
