\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{class/nitonepage}[2024/11/14 NIT One Page Report Class]

\LoadClass[
    a4paper,12pt
]{ltjsarticle}

\RequirePackage[utf8]{luainputenc}
\RequirePackage{luacode}
\RequirePackage[T1]{fontenc}
\RequirePackage{babel}

\RequirePackage[
    a4paper,
    total={180mm, 270mm},
    left=15mm,
    right=15mm,
    top=30mm,
    headheight=10mm,
    headsep=5mm,
    marginparwidth=25mm,
    footnotesep=5mm,
    footskip=7.5mm,
    bottom=20mm
]{geometry}

\RequirePackage[unicode, colorlinks=true, allcolors=blue]{hyperref}
\urlstyle{same}

\RequirePackage{amsmath, amssymb, amsthm}
\RequirePackage{mathtools}

\RequirePackage[dvipdfm]{graphicx}
\RequirePackage{wrapfig}
\RequirePackage{here}
\graphicspath{{./assets}}

% ============================== FONT CONFIG ==================================

\RequirePackage{luatexja-fontspec}
\RequirePackage[T1]{fontenc}
\RequirePackage{fontspec}
\newjfontfamily{\notoserifjp}{NotoSerifJP}[
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ScaleAgain=1.2,
        CJKShape=JIS1990,
        CharacterWidth=Full
]
\newjfontfamily{\notosansjp}{NotoSansJP}[
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ScaleAgain=1.2,
        CJKShape=JIS1990,
        CharacterWidth=Full
]
\newfontfamily{\notoserif}{NotoSerif}[
        ScaleAgain=\Cjascale,
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ItalicFont=*-Italic,
        BoldItalicFont=*-BoldItalic
]
\newfontfamily{\notosans}{NotoSans}[
        ScaleAgain=\Cjascale,
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ItalicFont=*-Italic,
        BoldItalicFont=*-BoldItalic
]
\setmainfont{NotoSerif}
\setsansfont{NotoSans}
\setmainjfont{NotoSerifJP}
\setsansjfont{NotoSansJP}
\newcommand{\serif}{\notoserif\notoserifjp}
\newcommand{\sans}{\notosans\notosansjp}

\setmonofont{0xProtoNerdFontMono}[
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular
]
\newcommand{\zeroxproto}{\ttfamily}

% =========================== FONT CONFIG (END) ===============================

\RequirePackage{enumitem}
\RequirePackage{tabularray}
\RequirePackage{tabularx}
\RequirePackage{framed}

% =============================== LISTINGS CONFIG =============================

\RequirePackage{listings}
\RequirePackage{xcolor}

\definecolor{draculabg}{RGB}{40,42,54}
\definecolor{draculafg}{RGB}{248,248,242}
\definecolor{draculacomment}{RGB}{98,114,164}
\definecolor{draculacurrentline}{RGB}{68, 71, 90}
\definecolor{draculaorange}{RGB}{255,184,108}
\definecolor{draculacyan}{RGB}{139,244,253}
\definecolor{draculagreen}{RGB}{80,250,123}

\lstdefinestyle{codestyle}{
    backgroundcolor=\color{draculabg},
    commentstyle=\color{draculacomment},
    keywordstyle={\color{draculaorange}},
    identifierstyle=\color{draculacyan},
    numberstyle=\small\color{draculacurrentline},
    stringstyle=\bfseries\color{draculagreen},
    basicstyle=\ttfamily\normalsize\color{draculafg},
    breakatwhitespace=false,
    breaklines=true,
    captionpos=t,
    keepspaces=true,
    numbers=left,
    numbersep=14pt,
    showspaces=false,
    showstringspaces=true,
    showtabs=false,
    tabsize=4,
    lineskip=-3pt,
    xrightmargin=32pt,
    xleftmargin=32pt,
    frame=single,
    framerule=1pt,
    rulesepcolor=\color{draculacyan},
    framexleftmargin=4pt,
    framexrightmargin=4pt,
    framextopmargin=4pt,
    framexbottommargin=4pt,
    xleftmargin=5px,
    xrightmargin=5px
}

\lstset{style=codestyle}
\renewcommand{\lstlistingname}{\fontspec{NotoSerifJP} コードリスティング}

% ============================ LISTINGS CONFIG (END) ==========================

\usepackage[backend=biber,bibencoding=utf8,firstinits=false,style=numeric-comp,date=short,dateabbrev=false]{biblatex}
\addbibresource{references.bib}

\newcommand{\reporttitle}[1]{
    \def\@title{#1}
    \title{#1}
}

\newcommand{\reportauthor}[1]{
    \def\@author{#1}
    \author{#1}
}

\newcommand{\reportdate}[3]{
    \def\@year{#1}
    \def\@month{#2}
    \def\@day{#3}
    \date{\@year \@month \@day}
}

\newcommand{\schoolname}[1]{\def\@schoolname{#1}}
\newcommand{\studentid}[1]{\def\@studentid{#1}}
\newcommand{\department}[1]{\def\@department{#1}}
\newcommand{\subject}[1]{\def\@subject{#1}}

\newcommand{\compiledTime}{\sans \directlua{tex.sprint("Last Compiled(UN*X Time Seconds): " .. tostring(os.time()))}}

\newcommand{\titleheading}{
    \begin{flushleft}
        \Huge
        {\serif \@title}
        
        \normalsize
        {\serif \@year \@month \@day}
    \end{flushleft}
}

\RequirePackage{fancyhdr}
\pagestyle{fancy}
%\renewcommand{\headwidth}{240mm}
\fancyhf{}
\lhead{\@author (\@studentid)}
\chead{\@schoolname}
\rhead{\@subject}

\lfoot{\footnotesize Made With \LaTeX{} + vim}
\cfoot{}
\rfoot{\footnotesize \compiledTime}

