diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 0000000..7952df2
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1,2 @@
+# The roar-irb-maintainers team will own all markdown files.
+*.md @yeatmanlab/roar-irb-maintainers
diff --git a/.github/workflows/markdown-diff.yml b/.github/workflows/markdown-diff.yml
new file mode 100644
index 0000000..1d1eb41
--- /dev/null
+++ b/.github/workflows/markdown-diff.yml
@@ -0,0 +1,71 @@
+name: Generate Diff PDFs
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+ branches:
+ - main
+
+jobs:
+ generate_pdfs:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0 # Fetch full history to compare branches
+ - name: Set up Node.js
+ uses: actions/setup-node@v3
+ with:
+ node-version: '16'
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y wkhtmltopdf
+ npm install -g diff2html-cli
+ - name: Fetch main branch
+ run: |
+ git fetch origin main
+ - name: Generate diffs and PDFs
+ run: |
+ # Get list of modified markdown files
+ MODIFIED_FILES=$(git diff --name-only origin/main...HEAD -- '*.md')
+ echo "Modified markdown files:"
+ echo "$MODIFIED_FILES"
+ mkdir -p pdfs
+ # Generate individual PDFs
+ for FILE in $MODIFIED_FILES; do
+ echo "Processing $FILE"
+ # Generate diff and convert to HTML
+ git diff origin/main...HEAD -- "$FILE" | diff2html -i stdin -s line -o stdout > diff.html
+ # Convert HTML to PDF
+ OUTPUT_FILE="pdfs/${FILE//\//_}.pdf"
+ wkhtmltopdf diff.html "$OUTPUT_FILE"
+ done
+ # Generate combined PDF
+ COMBINED_HTML="combined_diff.html"
+ echo "
" > $COMBINED_HTML
+ for FILE in $MODIFIED_FILES; do
+ echo "Diff for $FILE
" >> $COMBINED_HTML
+ git diff origin/main...HEAD -- "$FILE" | diff2html -i stdin -s line -o stdout >> $COMBINED_HTML
+ echo "" >> $COMBINED_HTML
+ done
+ echo "" >> $COMBINED_HTML
+ # Convert combined HTML to PDF
+ wkhtmltopdf $COMBINED_HTML "pdfs/combined_diff.pdf"
+ - name: Upload PDFs
+ uses: actions/upload-artifact@v3
+ with:
+ name: diff_pdfs
+ path: pdfs/
+ - name: Comment on PR with download link
+ uses: actions/github-script@v6
+ with:
+ script: |
+ const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}`;
+ github.rest.issues.createComment({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: `📄 Diff PDFs have been generated and uploaded as artifacts for this workflow run. You can download them from the [Artifacts section of the workflow run](${artifactUrl}).`
+ });
diff --git a/.github/workflows/pdf-diff.yml b/.github/workflows/pdf-diff.yml
new file mode 100644
index 0000000..7e7fd5b
--- /dev/null
+++ b/.github/workflows/pdf-diff.yml
@@ -0,0 +1,97 @@
+name: Generate Rendered Diff PDFs
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+ branches:
+ - main
+
+jobs:
+ generate_pdfs:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0 # Fetch full history to compare branches
+
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y pandoc texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-xetex texlive-fonts-extra latexdiff latexmk ghostscript
+ mkdir -p old_version new_version diffs pdfs
+
+ - name: Fetch main branch
+ run: |
+ git fetch origin main
+
+ - name: Generate rendered diffs and PDFs
+ run: |
+ # Create a LaTeX preamble with necessary packages
+ echo "\usepackage{fontspec}
+ \setmainfont{DejaVu Serif}
+ \setsansfont{DejaVu Sans}
+ \setmonofont{DejaVu Sans Mono}" > preamble.tex
+
+ # Get list of modified markdown files
+ MODIFIED_FILES=$(git diff --name-only origin/main...HEAD -- '*.md')
+ echo "Modified markdown files:"
+ echo "$MODIFIED_FILES"
+ mkdir -p pdfs
+ COMBINED_DIFFS=""
+ for FILE in $MODIFIED_FILES; do
+ echo "Processing $FILE"
+
+ # Extract old version from main branch
+ git show origin/main:"$FILE" > old_version/"$(basename "$FILE")"
+
+ # Copy new version
+ cp "$FILE" new_version/
+
+ # Convert both versions to LaTeX with preamble
+ pandoc old_version/"$(basename "$FILE")" --include-in-header=preamble.tex -o old_version/"$(basename "$FILE" .md)".tex
+ pandoc new_version/"$(basename "$FILE")" --include-in-header=preamble.tex -o new_version/"$(basename "$FILE" .md)".tex
+
+ # Run latexdiff to get the diffed LaTeX file, including preamble
+ latexdiff --encoding=utf8 --preamble "\input{preamble.tex}" old_version/"$(basename "$FILE" .md)".tex new_version/"$(basename "$FILE" .md)".tex > diffs/"$(basename "$FILE" .md)"_diff.tex
+
+ # Compile the diffed LaTeX file to PDF using xelatex
+ cd diffs
+ latexmk -pdf -xelatex -interaction=nonstopmode -quiet "$(basename "$FILE" .md)"_diff.tex
+ cd ..
+
+ # Move the generated PDF to the pdfs directory
+ mv diffs/"$(basename "$FILE" .md)"_diff.pdf pdfs/
+
+ # Append to combined diffs
+ COMBINED_DIFFS="$COMBINED_DIFFS \includepdf[pages=-]{pdfs/$(basename "$FILE" .md)_diff.pdf}"
+ done
+
+ # Generate combined PDF if there are diffs
+ if [ -n "$COMBINED_DIFFS" ]; then
+ echo "\documentclass{article}
+ \usepackage{pdfpages}
+ \begin{document}
+ $COMBINED_DIFFS
+ \end{document}" > combined_diff.tex
+ latexmk -pdf -xelatex -interaction=nonstopmode -quiet combined_diff.tex
+ mv combined_diff.pdf pdfs/
+ fi
+
+ - name: Upload PDFs
+ uses: actions/upload-artifact@v3
+ with:
+ name: rendered_diff_pdfs
+ path: pdfs/
+
+ - name: Comment on PR with download link
+ uses: actions/github-script@v6
+ with:
+ script: |
+ const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}`;
+ github.rest.issues.createComment({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: `📄 Rendered diff PDFs have been generated and uploaded as artifacts for this workflow run. You can download them from the [Artifacts section of the workflow run](${artifactUrl}).`
+ });
diff --git a/README.md b/README.md
index 0f13f31..b24bb4e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,13 @@
# roar-legal-documents
+
A repository that hosts all relevant legal documents for ROAR research. This repository currently includes:
+
- Consolidated Assent
- Terms of Service
- District 2 Consent Form
- Web-Based Behavioral Consent
- Web-Based Behavioral Consent (Eye-Tracking)
+
+## Deployment
+
+Insert steps here for how to modify a markdown file.