From 883ea015e48c173c81e04a26720e5875154b1cdf Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Fri, 3 May 2019 13:59:37 +0100
Subject: [PATCH] Create initial report template

---
 .gitignore           | 274 +++++++++++++++++++++++++++++++++++++++++++
 .gitmodules          |   3 +
 build                | 116 ++++++++++++++++++
 lantern-build-engine |   1 +
 4 files changed, 394 insertions(+)
 create mode 100644 .gitmodules
 create mode 100755 build
 create mode 160000 lantern-build-engine

diff --git a/.gitignore b/.gitignore
index 4e3505e..0a00e2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+Reports/*.pdf
 
 # Created by https://www.gitignore.io/api/libreoffice
 # Edit at https://www.gitignore.io/?templates=libreoffice
@@ -98,3 +99,276 @@ typings/
 .dynamodb/
 
 # End of https://www.gitignore.io/api/node
+
+# Created by https://www.gitignore.io/api/latex
+# Edit at https://www.gitignore.io/?templates=latex
+
+### LaTeX ###
+## Core latex/pdflatex auxiliary files:
+*.aux
+*.lof
+*.log
+*.lot
+*.fls
+*.out
+*.toc
+*.fmt
+*.fot
+*.cb
+*.cb2
+.*.lb
+
+## Intermediate documents:
+*.dvi
+*.xdv
+*-converted-to.*
+# these rules might exclude image files for figures etc.
+# *.ps
+# *.eps
+# *.pdf
+
+## Generated if empty string is given at "Please type another file name for output:"
+.pdf
+
+## Bibliography auxiliary files (bibtex/biblatex/biber):
+*.bbl
+*.bcf
+*.blg
+*-blx.aux
+*-blx.bib
+*.run.xml
+
+## Build tool auxiliary files:
+*.fdb_latexmk
+*.synctex
+*.synctex(busy)
+*.synctex.gz
+*.synctex.gz(busy)
+*.pdfsync
+
+## Build tool directories for auxiliary files
+# latexrun
+latex.out/
+
+## Auxiliary and intermediate files from other packages:
+# algorithms
+*.alg
+*.loa
+
+# achemso
+acs-*.bib
+
+# amsthm
+*.thm
+
+# beamer
+*.nav
+*.pre
+*.snm
+*.vrb
+
+# changes
+*.soc
+
+# comment
+*.cut
+
+# cprotect
+*.cpt
+
+# elsarticle (documentclass of Elsevier journals)
+*.spl
+
+# endnotes
+*.ent
+
+# fixme
+*.lox
+
+# feynmf/feynmp
+*.mf
+*.mp
+*.t[1-9]
+*.t[1-9][0-9]
+*.tfm
+
+#(r)(e)ledmac/(r)(e)ledpar
+*.end
+*.?end
+*.[1-9]
+*.[1-9][0-9]
+*.[1-9][0-9][0-9]
+*.[1-9]R
+*.[1-9][0-9]R
+*.[1-9][0-9][0-9]R
+*.eledsec[1-9]
+*.eledsec[1-9]R
+*.eledsec[1-9][0-9]
+*.eledsec[1-9][0-9]R
+*.eledsec[1-9][0-9][0-9]
+*.eledsec[1-9][0-9][0-9]R
+
+# glossaries
+*.acn
+*.acr
+*.glg
+*.glo
+*.gls
+*.glsdefs
+
+# gnuplottex
+*-gnuplottex-*
+
+# gregoriotex
+*.gaux
+*.gtex
+
+# htlatex
+*.4ct
+*.4tc
+*.idv
+*.lg
+*.trc
+*.xref
+
+# hyperref
+*.brf
+
+# knitr
+*-concordance.tex
+# TODO Comment the next line if you want to keep your tikz graphics files
+*.tikz
+*-tikzDictionary
+
+# listings
+*.lol
+
+# luatexja-ruby
+*.ltjruby
+
+# makeidx
+*.idx
+*.ilg
+*.ind
+*.ist
+
+# minitoc
+*.maf
+*.mlf
+*.mlt
+*.mtc[0-9]*
+*.slf[0-9]*
+*.slt[0-9]*
+*.stc[0-9]*
+
+# minted
+_minted*
+*.pyg
+
+# morewrites
+*.mw
+
+# nomencl
+*.nlg
+*.nlo
+*.nls
+
+# pax
+*.pax
+
+# pdfpcnotes
+*.pdfpc
+
+# sagetex
+*.sagetex.sage
+*.sagetex.py
+*.sagetex.scmd
+
+# scrwfile
+*.wrt
+
+# sympy
+*.sout
+*.sympy
+sympy-plots-for-*.tex/
+
+# pdfcomment
+*.upa
+*.upb
+
+# pythontex
+*.pytxcode
+pythontex-files-*/
+
+# tcolorbox
+*.listing
+
+# thmtools
+*.loe
+
+# TikZ & PGF
+*.dpth
+*.md5
+*.auxlock
+
+# todonotes
+*.tdo
+
+# vhistory
+*.hst
+*.ver
+
+# easy-todo
+*.lod
+
+# xcolor
+*.xcp
+
+# xmpincl
+*.xmpi
+
+# xindy
+*.xdy
+
+# xypic precompiled matrices
+*.xyc
+
+# endfloat
+*.ttt
+*.fff
+
+# Latexian
+TSWLatexianTemp*
+
+## Editors:
+# WinEdt
+*.bak
+*.sav
+
+# Texpad
+.texpadtmp
+
+# LyX
+*.lyx~
+
+# Kile
+*.backup
+
+# KBibTeX
+*~[0-9]*
+
+# auto folder when using emacs and auctex
+./auto/*
+*.el
+
+# expex forward references with \gathertags
+*-tags.tex
+
+# standalone packages
+*.sta
+
+### LaTeX Patch ###
+# glossaries
+*.glstex
+
+# End of https://www.gitignore.io/api/latex
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..ecc03d9
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "lantern-build-engine"]
+	path = lantern-build-engine
+	url = https://gitlab.com/sbrl/lantern-build-engine.git
diff --git a/build b/build
new file mode 100755
index 0000000..06fd006
--- /dev/null
+++ b/build
@@ -0,0 +1,116 @@
+#!/usr/bin/env bash
+# Make sure the current directory is the location of this script to simplify matters
+cd "$(dirname $(readlink -f $0))";
+################
+### Settings ###
+################
+
+# The name of this project
+project_name="Msc Summer Project";
+
+# The path to the lantern build engine git submodule
+lantern_path="./lantern-build-engine";
+
+###
+# Custom Settings
+###
+
+# Put any custom settings here.
+
+
+###############################################################################
+
+# Check out the lantern git submodule if needed
+if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
+
+source "${lantern_path}/lantern.sh";
+
+if [[ "$#" -lt 1 ]]; then
+	echo -e "${FBLE}${project_name}${RS} build script";
+	echo -e "    by Starbeamrainbowlabs";
+	echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
+	echo -e "";
+	echo -e "${CSECTION}Usage${RS}";
+	echo -e "    ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
+	echo -e "";
+	echo -e "${CSECTION}Available actions${RS}";
+	echo -e "    ${CACTION}setup${RS}    - Perform initial setup";
+	echo -e "    ${CACTION}render${RS}   - Render the LaTeX exmaples";
+	echo -e "";
+	
+	exit 1;
+fi
+
+###############################################################################
+
+task_setup() {
+	task_begin "Setting up";
+	
+	check_command git true;
+	check_command pdflatex true;
+	check_command bibtex true;
+	
+	subtask_begin "Initialising submodules";
+	git submodule update --init;
+	subtask_end $?;
+	
+	task_end 0;
+}
+
+task_render() {
+	_render-latex-pdf "Reports/Initial-Report/Initial-Report.tex";
+}
+
+# $1 - Location of top-level LaTeX file
+_render-latex-pdf() {
+	if [[ ! -f "$1" ]]; then
+		task_end 1 "Error: Couldn't find '$1'";
+	fi
+	
+	task_begin "Entering directory";
+	latex_filename="$(basename "$1")";
+	latex_directory="$(dirname "$1")";
+	
+	execute cd "${latex_directory}";
+	execute echo "${PWD}";
+	task_end $? "Failed to enter directory (does it exist?)";
+	
+	task_begin "Cleaning up";
+	find -iname "*.aux" -delete; # Ref: https://tex.stackexchange.com/q/381057
+	find -iname "*.bbl" -delete;
+	find -iname "*.blg" -delete;
+	find -iname "*.out" -delete;
+	task_end $? "Error: Failed to clean up after last build";
+	
+	# task_begin "Rendering images";
+	# # FUTURE: Do this in paralell?
+	# for svg_filename in $(find "images/" -type f -iname "*.svg"); do
+	# 	execute inkscape -e ${svg_filename%%.svg}.png ${svg_filename};
+	# 	exit_code=$?;
+	# 	[[ "${exit_code}" -eq 0 ]] || break;
+	# done
+	# task_end "${exit_code}";
+	
+	task_begin "Building Report";
+	set -e;
+	execute pdflatex --output-directory=. "${latex_filename}";
+	execute bibtex "${latex_filename%.*}";
+	execute pdflatex --output-directory=. "${latex_filename}";
+	execute pdflatex --output-directory=. "${latex_filename}";
+	execute bibtex "${latex_filename%.*}";
+	execute pdflatex --output-directory=. "${latex_filename}";
+	execute pdflatex --output-directory=. "${latex_filename}";
+	set +e;
+	task_end $? "Error: Failed to build report";
+	
+	task_begin "Moving report";
+	execute mv *.pdf ..;
+	task_end $? "Failed to move report";
+	
+	cd -;
+}
+
+
+###############################################################################
+
+tasks_run $@;
diff --git a/lantern-build-engine b/lantern-build-engine
new file mode 160000
index 0000000..617fcdb
--- /dev/null
+++ b/lantern-build-engine
@@ -0,0 +1 @@
+Subproject commit 617fcdb5b9df7f57ccb6639a87be68238f99b9ed
