Skip to content

Commit

Permalink
✨ docx for agreements; callouts + logo in pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Nov 5, 2024
1 parent 9a34a1f commit fc842de
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 52 deletions.
89 changes: 53 additions & 36 deletions .github/docker-build-pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@
if [[ -z "${PANDOCK}" ]]; then
PANDOCK=ghcr.io/commonhaus/pandoc-pdf:3.1
fi
# Git commit information (SHA, date, repo url)

DATE=$(date "+%Y-%m-%d")
URL=$(gh repo view --json url --jq '.url')/

if [[ -z "${GITHUB_SHA}" ]]; then
GITHUB_SHA=$(git rev-parse --short HEAD)
fi

echo GITHUB_SHA=${GITHUB_SHA}

# Git commit information (SHA, date, repo url)
if [[ "${IS_PR}" == "true" ]]; then
FOOTER="${DATE}${GITHUB_REF}"
elif [[ -z "${GITHUB_SHA}" ]]; then
GITHUB_SHA=$(git rev-parse --short HEAD)
URL="${PR_URL}"
else
FOOTER="${DATE} ✧ commit ${GITHUB_SHA}"
URL="${URL}blob/${GITHUB_SHA}/"
fi
if [[ -z "${GIT_COMMIT}" ]]; then
GIT_COMMIT=$(git rev-parse HEAD)
fi
URL=$(gh repo view --json url --jq '.url')/

echo URL=${URL}
echo GIT_COMMIT=${GIT_COMMIT}
echo GITHUB_SHA=${GITHUB_SHA}

# Docker command and arguments
ARGS="--rm -e TERM -e HOME=/data -u $(id -u):$(id -g) -v $(pwd):/data -w /data"
Expand All @@ -32,15 +36,24 @@ elif [[ -z "${DOCKER}" ]]; then
DOCKER=docker
fi

TO_CMD=${1:-nope}
function run_shell() {
${DOCKER} run ${ARGS} --entrypoint="" "${PANDOCK}" "$@"
}

function run_pandoc() {
${DOCKER} run ${ARGS} "${PANDOCK}" "$@"
}


TO_CMD=${1:-noargs}
# Invoke command in the pandock container with common docker arguments
if [[ "${TO_CMD}" == "sh" ]]; then
${DOCKER} run ${ARGS} --entrypoint="" "${PANDOCK}" "$@"
run_shell "$@"
exit 0
fi
# Invoke pandoc with common docker arguments
if [[ "${TO_CMD}" != "nope" ]]; then
${DOCKER} run ${ARGS} "${PANDOCK}" "$@"
if [[ "${TO_CMD}" != "noargs" ]]; then
run_pandoc "$@"
exit 0
fi

Expand Down Expand Up @@ -100,18 +113,28 @@ function to_pdf() {
function run_pdf() {
${DOCKER} run ${ARGS} \
"${PANDOCK}" \
-H ./.pandoc/header.tex \
-A ./.pandoc/afterBody.tex \
-d ./.pandoc/bylaws.yaml \
-M date-meta:"$(date +%B\ %d,\ %Y)" \
--metadata-file=CONTACTS.yaml \
-V footer-left:"${FOOTER}" \
-V github:"${URL}blob/${GIT_COMMIT}/" \
-V github:"${URL}" \
"$@"

echo "$?"
}

# Convert markdown to DOCX
function run_docx() {
${DOCKER} run ${ARGS} \
"${PANDOCK}" \
-d ./.pandoc/agreements.yaml \
-M date-meta:"$(date +%B\ %d,\ %Y)" \
-V github:"${URL}" \
-o "$1" \
"$2"

echo "$?"
}

mkdir -p output/tmp
mkdir -p output/public

Expand All @@ -138,12 +161,12 @@ for x in "${BYLAWS[@]}"; do
fi
done

# Convert bylaws to PDF
# # Convert bylaws to PDF
to_pdf_pattern \
bylaws \
"cf-bylaws.pdf" \
"./bylaws/" \
-M title:"Commonhaus Foundation Bylaws" \
-M title:"Bylaws" \
"${BYLAWS[@]}"

## POLICIES
Expand All @@ -158,40 +181,34 @@ function to_policy_pdf() {
"${1}" \
"${1}.pdf" \
"./policies/" \
-M title:"Commonhaus Foundation ${2} Policy" \
-M title:"${2} Policy" \
"./policies/${1}.md"
}

# Convert all policies to PDF
to_policy_pdf code-of-conduct "Code of Conduct"
to_policy_pdf conflict-of-interest "Conflict of Interest"
to_policy_pdf ip-policy "Intellectual Property"
to_policy_pdf security-policy "Security Vulnerability Reporting"
to_policy_pdf succession-plan "Continuity and Administrative Access"
to_policy_pdf trademark-policy "Trademark"

to_pdf ./TRADEMARKS.md trademark-list ./ "Commonhaus Foundation Trademark List"
to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List"

## AGREEMENTS

function to_agreement_pdf() {
function to_agreement_doc() {
if [[ ! -f "./agreements/${1}.md" ]]; then
echo "No agreement found at ./agreements/${1}.md"
exit 1
fi
local name=$(basename ${1})
sed -E 's/\[Insert [^]]* here\]/______________________________________/g' \
"./agreements/${1}.md" > "./output/tmp/${name}.md"

to_pdf_pattern \
"${1}" \
"$(basename ${1}).pdf" \
"./agreements/$(dirname ${1})/" \
-M title:"Commonhaus Foundation ${2} Agreeement" \
"./output/tmp/${name}.md"
if [[ -z "${2}" ]]; then
echo "No agreement name provided"
exit 1
fi
run_docx \
"./output/public/${2}.docx" \
"./agreements/${1}.md"
}

# Very redundant, but .. whatever. ;)
to_agreement_pdf bootstrapping/bootstrapping Bootstrapping
to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement

ls -al output/public
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
GIT_COMMIT: ${{ github.sha }}
GH_TOKEN: ${{ github.token }}
IS_PR: ${{ github.event_name == 'pull_request' }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: ./.github/docker-build-pdf.sh

- uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.DS_Store
*~
.~*
.cache
.config
.idea
.vscode
node_modules
Expand Down
13 changes: 13 additions & 0 deletions .pandoc/agreements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from: gfm+emoji+alerts
reader: gfm+emoji+alerts
number-sections: true
file-scope: true
filters:
- .pandoc/filters/fix-links.lua
- .pandoc/filters/agreement-form.lua
metadata-file: CONTACTS.yaml
reference-doc: .pandoc/content/cf-agreement-template.docx
template: .pandoc/content/docx-template.txt
shift-heading-level-by: -1
variables:
website: https://www.commonhaus.org/
14 changes: 10 additions & 4 deletions .pandoc/bylaws.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from: gfm+emoji
reader: gfm+emoji
from: gfm+emoji+alerts
reader: gfm+emoji+alerts
number-sections: true
file-scope: true
filters:
- .pandoc/fix-links.lua
- .pandoc/filters/alerts.lua
- .pandoc/filters/fix-links.lua
include-in-header:
- .pandoc/content/header.tex
include-after-body:
- .pandoc/content/afterBody.tex
metadata-file: CONTACTS.yaml
pdf-engine: lualatex
pdf-engine-opts:
- '-shell-escape'
template: .pandoc/templates/commonhaus-eisvogel
template: .pandoc/content/commonhaus-eisvogel
toc: true
toc-depth: 3
variables:
Expand Down
Binary file not shown.
48 changes: 48 additions & 0 deletions .pandoc/content/CF_logo_horizontal_single_default_svg-tex.pdf_tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
%% Creator: Inkscape 1.3.2 (091e20ef0f, 2023-11-25), www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'CF_logo_horizontal_single_default_svg-tex.pdf' (pdf, eps, ps)
%%
%% To include the image in your LaTeX document, write
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics{<filename>.pdf}
%% To scale the image, write
%% \def\svgwidth{<desired width>}
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics[width=<desired width>]{<filename>.pdf}
%%
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%% \usepackage{import}
%% in the preamble, and then including the image with
%% \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%% \graphicspath{{<path to file>/}}
%%
%% For more information, please see info/svg-inkscape on CTAN:
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
%%
\begingroup%
\makeatletter%
\providecommand\color[2][]{%
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
\renewcommand\color[2][]{}%
}%
\providecommand\transparent[1]{%
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
\renewcommand\transparent[1]{}%
}%
\providecommand\rotatebox[2]{#2}%
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
\def\svgwidth{150px}
\setlength{\unitlength}{150px}
\makeatother%
\begin{picture}(1,0.10569674)%
\lineheight{1}%
\setlength\tabcolsep{0pt}%
\put(0,0){\includegraphics[width=\unitlength,page=1]{./.pandoc/content/CF_logo_horizontal_single_default_svg-tex.pdf}}%
\end{picture}%
\endgroup%
File renamed without changes.
7 changes: 7 additions & 0 deletions .pandoc/content/agreement-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
mc:Ignorable="w14 wp14 w15"
Binary file added .pandoc/content/cf-agreement-template.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ $if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
\usepackage{xcolor}
\definecolor{default-linkcolor}{HTML}{4077C0}
\definecolor{default-filecolor}{HTML}{4077C0}
\definecolor{default-citecolor}{HTML}{4077C0}
\definecolor{default-urlcolor}{HTML}{4077C0}
\definecolor{default-linkcolor}{HTML}{4D7343}
\definecolor{default-filecolor}{HTML}{4D7343}
\definecolor{default-citecolor}{HTML}{4D7343}
\definecolor{default-urlcolor}{HTML}{4D7343}
$if(footnotes-pretty)$
% load footmisc in order to customize footnotes (footmisc has to be loaded before hyperref, cf. https://tex.stackexchange.com/a/169124/144087)
\usepackage[hang,flushmargin,bottom,multiple]{footmisc}
Expand Down Expand Up @@ -677,7 +677,7 @@ $endif$
%
% heading color
%
\definecolor{heading-color}{RGB}{40,40,40}
\definecolor{heading-color}{HTML}{1A402A}
$if(beamer)$
$else$
\addtokomafont{section}{\color{heading-color}}
Expand Down Expand Up @@ -875,10 +875,10 @@ $else$
$if(disable-header-and-footer)$
$else$
\usepackage[headsepline,footsepline]{scrlayer-scrpage}

\newpairofpagestyles{eisvogel-header-footer}{
\newcommand{\headertext}{$if(header-left)$$header-left$$else$$title$$endif$}
\clearpairofpagestyles
\ihead*{\textcolor{gray}{$if(header-left)$$header-left$$else$$title$$endif$}}
\ihead*{\raisebox{-.7ex}{\input{./.pandoc/content/CF_logo_horizontal_single_default_svg-tex.pdf_tex}} \hspace{2px} \headertext}
\chead*{\textcolor{gray}{$if(header-center)$$header-center$$else$$endif$}}
\ohead*{\textcolor{gray}{$if(header-right)$$header-right$$else$$date$$endif$}}
\ifoot*{\textcolor{gray}{$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$}}
Expand Down
84 changes: 84 additions & 0 deletions .pandoc/content/docx-template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
mc:Ignorable="w14 wp14 w15">
<w:body>
$if(title)$
<w:p>
<w:pPr>
<w:pStyle w:val="Title" />
</w:pPr>
$title$
</w:p>
$endif$
$if(subtitle)$
<w:p>
<w:pPr>
<w:pStyle w:val="Subtitle" />
</w:pPr>
$subtitle$
</w:p>
$endif$
$for(author)$
<w:p>
<w:pPr>
<w:pStyle w:val="Author" />
</w:pPr>
$author$
</w:p>
$endfor$
$if(date)$
<w:p>
<w:pPr>
<w:pStyle w:val="Date" />
</w:pPr>
$date$
</w:p>
$endif$
$if(abstract)$
$if(abstract-title)$
<w:p>
<w:pPr>
<w:pStyle w:val="AbstractTitle" />
</w:pPr>
<w:r><w:t xml:space="preserve">$abstract-title$</w:t></w:r>
</w:p>
$endif$
$abstract$
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
$toc$
$endif$
$if(lof)$
$lof$
$endif$
$if(lot)$
$lot$
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
$-- sectpr will be set to the last sectpr in a reference.docx, if present
$if(sectpr)$
$sectpr$
$else$
<w:sectPr />
$endif$
</w:body>
</w:document>
Loading

0 comments on commit fc842de

Please sign in to comment.