Skip to content

Commit

Permalink
👷 📝 template/agreement build
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Nov 21, 2024
1 parent fa20e00 commit 1fd1051
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 35 deletions.
90 changes: 62 additions & 28 deletions .github/docker-build-pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@ function run_pandoc() {
${DOCKER} run ${ARGS} "${PANDOCK}" "$@"
}

for x in "$@"; do
case "$x" in
--help)
echo "Usage: $0 [--skip-policies] [--skip-bylaws] [--skip-agreements]"
echo "OR: $0 [pandoc command arguments]"
echo "OR: $0 sh [command]"
exit 0
;;
--skip-policies)
SKIP_POLICIES=true
shift
;;
--skip-bylaws)
SKIP_BYLAWS=true
shift
;;
--skip-agreements)
SKIP_AGREEMENTS=true
shift
;;
*)
;;
esac
done

TO_CMD=${1:-noargs}
# Invoke command in the pandock container with common docker arguments
Expand Down Expand Up @@ -153,21 +177,23 @@ BYLAWS=(
./bylaws/9-amendments.md
)

# Verify that bylaws files exist
for x in "${BYLAWS[@]}"; do
if [[ ! -f ${x} ]]; then
echo "No file found at ${x}"
exit 1
fi
done
if [[ -z "${SKIP_BYLAWS}" ]]; then
# Verify that bylaws files exist
for x in "${BYLAWS[@]}"; do
if [[ ! -f ${x} ]]; then
echo "No file found at ${x}"
exit 1
fi
done

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

## POLICIES

Expand All @@ -185,30 +211,38 @@ function to_policy_pdf() {
"./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 trademark-policy "Trademark"
if [[ -z "${SKIP_POLICIES}" ]]; then
# 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 trademark-policy "Trademark"

to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List"
to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List"
fi

## AGREEMENTS

function to_agreement_doc() {
if [[ ! -f "./agreements/${1}.md" ]]; then
echo "No agreement found at ./agreements/${1}.md"
local input=${1}
if [[ ! -f "./agreements/${input}.md" ]]; then
echo "No agreement found at ./agreements/${input}.md"
exit 1
fi
if [[ -z "${2}" ]]; then
echo "No agreement name provided"
exit 1
local output=${2}
if [[ -z "${output}" ]]; then
output=$(basename ${input})
fi
run_docx \
"./output/public/${2}.docx" \
"./agreements/${1}.md"
"./output/public/${output}.docx" \
"./agreements/${input}.md"
}

to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement
if [[ -z "${SKIP_AGREEMENTS}" ]]; then
to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement
# to_agreement_doc project-contribution/asset-transfer-agreement
# to_agreement_doc project-contribution/fiscal-sponsorship-agreement
# to_agreement_doc project-contribution/fiscal-sponsorship-terms-and-conditions
fi

ls -al output/public
9 changes: 8 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ name: Build PDF and publish to commonhaus.github.io
on:
pull_request:
paths:
- 'agreements/**'
- 'bylaws/**'
- 'policies/**'
push:
branches:
- main
paths:
- 'agreements/**'
- 'bylaws/**'
Expand Down Expand Up @@ -58,7 +61,6 @@ jobs:
fetch-depth: 0

- name: convert md to pdf
if: ${{ needs.main-root.outputs.is-main || github.event_name == 'pull_request' }}
env:
GIT_COMMIT: ${{ github.sha }}
GH_TOKEN: ${{ github.token }}
Expand All @@ -71,6 +73,11 @@ jobs:
name: pdf-output
path: output/public/*.pdf

- uses: actions/upload-artifact@v4
with:
name: docx-output
path: output/public/*.docx

- name: Update snapshot tag
if: ${{ needs.main-root.outputs.is-main }}
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Validate markdown and YAML
on:
pull_request:
push:
branches:
- main
workflow_dispatch:

env:
Expand Down
Binary file modified .pandoc/content/cf-agreement-template.docx
Binary file not shown.
4 changes: 4 additions & 0 deletions .pandoc/content/docx-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ $if(lot)$
$lot$
$endif$
$body$
<w:p>
<w:pPr></w:pPr>
<w:r></w:r>
</w:p>
$for(include-after)$
$include-after$
$endfor$
Expand Down
19 changes: 13 additions & 6 deletions .pandoc/filters/agreement-form.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ local horizontalSeparator = [[<w:p>
<w:r></w:r>
</w:p>]]

local pagebreak = '<w:p><w:r><w:br w:type="page"/></w:r></w:p>'

local function HorizontalRule(elem)
print("CFLUA: Found horizontal rule ")
return pandoc.RawBlock('openxml', horizontalSeparator)
Expand All @@ -78,8 +80,13 @@ local function Header(header)
if header.level == 1 then
local content = pandoc.utils.stringify(header.content)
content = content:gsub("Commonhaus Foundation%s*(.*)", "%1")
print("CFLUA: Found header " .. content)
return pandoc.Header(1, content)
elseif header.level == 2 then
local content = pandoc.utils.stringify(header.content)
if string.match(content, 'Exhibits') or string.match(content, 'Schedules') then
print("CFLUA: Found L2 header " .. content)
return { pandoc.RawBlock('openxml', pagebreak), header }
end
end
return header
end
Expand All @@ -88,8 +95,8 @@ local function Para(para)
local content = pandoc.utils.stringify(para.content)
local insert = string.match(content, "%[Insert.*]")
if insert then
content = content:gsub("(.*)%[Insert.*](.*)", "%1______________________________%2")
print("CFLUA: Found insert " .. content)
content = content:gsub("(.*)%[Insert.*](.*)", "%1`______________________________`%2")
--print("CFLUA: Found insert " .. content)
return pandoc.read(content, 'markdown').blocks
end
return para
Expand All @@ -100,7 +107,7 @@ local function BulletList(list)
if string.match(content, "%[Insert.*]") then
for i, item in ipairs(list.content) do
local itemContent = pandoc.utils.stringify(item[1].content)
itemContent = itemContent:gsub("(.*)%[Insert.*](.*)", "%1______________________________%2")
itemContent = itemContent:gsub("(.*)%[Insert.*](.*)", "%1`______________________________`%2")
print("CFLUA: Found insert " .. itemContent)
list.content[i][1] = pandoc.Plain(itemContent)
end
Expand All @@ -109,8 +116,8 @@ local function BulletList(list)
end

return {
{ Header = Header },
{ HorizontalRule = HorizontalRule },
{ Header = Header },
{ BulletList = BulletList },
{ Para = Para }
{ Para = Para },
}

0 comments on commit 1fd1051

Please sign in to comment.