%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[$fontsize$, letterpaper]{article}

% LAYOUT
%--------------------------------
% Margins
\usepackage{geometry} 
\geometry{$geometry$}

% Do not indent paragraphs
\setlength\parindent{0in}

% Enable multicolumns
\usepackage{vwcol}
\usepackage{multicol}

% Colors
\usepackage{xcolor}
\definecolor{sidebar}{HTML}{$sidebar.color$}
\definecolor{content}{HTML}{$content.color$}
\definecolor{text}{HTML}{$text_color$}
\definecolor{accent}{HTML}{$accent_color$}
\color{text}

% Uncomment to suppress page numbers
\pagenumbering{gobble}

% LANGUAGE
%--------------------------------
% Set the main language
$if(lang)$
\usepackage{polyglossia}
\setmainlanguage{$lang$}
$endif$

% List Indents
\usepackage{enumitem}

% TYPOGRAPHY
%--------------------------------
\usepackage{fontawesome}   
\usepackage{fontspec} 
\usepackage{xunicode}
\usepackage{xltxtra}
% converts LaTeX specials (quotes, dashes etc.) to Unicode
\defaultfontfeatures{Mapping=tex-text}
\setromanfont [Ligatures={Common}, Numbers={OldStyle}]{$mainfont$}
% Cool ampersand
\newcommand{\amper}{{\fontspec[Scale=.95]{$mainfont$}\selectfont\itshape\&}}
% Font Awesome

% HEADINGS
%--------------------------------
\usepackage{sectsty} 
\usepackage[normalem]{ulem} 
\sectionfont{\rmfamily\mdseries} 
\subsectionfont{\rmfamily\mdseries\scshape\normalsize} 
\subsubsectionfont{\rmfamily\bfseries\upshape\normalsize} 

% SHAMELESSLY STOLEN STUFF
% ----------------------------------------------------------------------------
% based on https://tex.stackexchange.com/questions/65731
\makeatletter
\def\cv@hrulefill{{\color{accent}\leavevmode\leaders\hrule height 1pt\hfill\kern\z@}}

% line before and after text (some tweaking is required here) 
% based on https://tex.stackexchange.com/questions/15119
\NewDocumentCommand{\ruleline}{m}{\par\noindent\raisebox{\baselineskip/4}{\makebox[\linewidth]{\cv@hrulefill\hspace{1ex}\raisebox{-\baselineskip/4}{#1}\hspace{1ex}\cv@hrulefill}}}
\makeatother

% PDF SETUP
%--------------------------------
\usepackage{hyperref}
\hypersetup
{
  pdfauthor={$name$},
  pdfsubject={$name$'s CV},
  pdftitle={$name$'s CV},
  colorlinks, breaklinks, xetex, bookmarks,
  filecolor=black,
  urlcolor=[HTML]{$link_color$},
  linkcolor=[HTML]{$link_color$},
  citecolor=[HTML]{$link_color$}
}

%=============================================================================
\begin{document}

\setlength\fboxsep{0.2in}
\setlength\fboxrule{0pt}

% LEFT SIDEBAR
% ----------------------------------------------------------------------------
\noindent\fcolorbox{black}{sidebar}{%
\begin{minipage}[t][\dimexpr\textheight-2\fboxsep-2\fboxrule\relax]{\dimexpr$sidebar.width$\textwidth-2\fboxrule-2\fboxsep\relax}

  \centering
  \textbf{\textcolor{text}{{\LARGE $for(name)$$name$ $endfor$}}}\\

  \vspace{0.5em}
  %\hrule
  \vspace{0.5em}

  \small{

    \ruleline{\normalsize{Profile}}
    $if(profile)$
      $profile$
    $endif$
    \vspace{1em}

    $for(proficiencies)$
      \ruleline{\normalsize{$proficiencies.name$}}
      \vspace{-2.5em}
      \begin{multicols}{2}
        $for(proficiencies.list)$
          $proficiencies.list$\\
        $endfor$
      \end{multicols}
      \vspace{-0.5em}
    $endfor$

    \ruleline{Skills}
    \vspace {-5em}
    $for(skills)$
      \subsection*{\center{\textbf{$skills.skill$}}}
      \vspace{-0.5em}
      \flushleft{
        \emph{$skills.info$}\\
      }
      \vspace{-3.5em}
    $endfor$
  }

  \vspace{4em}
  \includegraphics[width=15em]{img/palski.png}

\end{minipage}}
\hspace{-5pt}
% MAIN CONTENT
% ----------------------------------------------------------------------------
\noindent\fcolorbox{black}{content}{%
\begin{minipage}[t][\dimexpr\textheight-2\fboxsep-2\fboxrule\relax]{\dimexpr$content.width$\textwidth-2\fboxrule-2\fboxsep\relax}
  \section*{Education}
    \vspace {-9pt}
    \hrule
    \vspace {2pt}
    \noindent
    $for(education)$
        $education.degree$ in \textbf{$education.major$}\\
        \emph{$education.university$}
        $if(education.completed)$
          \\[4pt]
        $else$
           -- Currently attending\\[4pt]
        $endif$
    $endfor$
    \vspace{-10pt}

  $if(languages)$
    \section*{Languages and Frameworks}
      \vspace {-11pt}
      \hrule
      \vspace {8pt}
      \begin{vwcol}[widths={1in, 1in, 1in}, justify=center]
        $for(languages)$
          \emph{$languages$}\\
        $endfor$
        \emph{\LaTeX}\\
      \end{vwcol}
      \vspace{10pt}
      \begin{vwcol}[widths={1in, 1in, 1in}, justify=center]
        $for(frameworks)$
          \emph{$frameworks$}\\
        $endfor$ \end{vwcol} $endif$

  \vspace{-1em}
  \section*{Experience}
  \vspace {-10pt}
  \hrule
  \vspace{2pt}
  \noindent
  $for(experience)$
    \textbf{\textsc{$experience.employer$}} -- 
    \emph{$experience.title$} -- 
    $experience.city$\\
    $experience.description$\\[$par_separation$]
  $endfor$

  \vspace{-2em}
  \section*{Research}
  \vspace {-10pt}
  \hrule
  \vspace{2pt}
  \noindent
  $for(research)$
    \textbf{\textsc{$research.university$}} -- 
    \emph{$research.title$} -- 
    $research.city$\\
    $research.description$\\[$par_separation$]
  $endfor$

  \vspace{-1em}
  \section*{Honors, Certifications, Licenses}
  \vspace {-10pt}
  \hrule
  \vspace{2pt}
  \noindent
  \begin{multicols}{3}
    \small{
      \begin{itemize}
        $for(honors)$
          \item $honors$\\
        $endfor$
      \end{itemize}
    }
  \end{multicols}
\end{minipage}}
\end{document}
