Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions .github/scripts/add-home-banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,9 @@ def add_page_banner(html_path, html_dir, changed_pages):

# Calculate relative link from current page to changed page
try:
# Get relative path from current HTML to changed HTML
current_dir = html_path.parent
link_path = os.path.relpath(page_html_path, current_dir)

# Get tracked changes DOCX path
tracked_docx_name = f"{page_info['stem']}-tracked-changes.docx"
tracked_docx_path = page_html_path.parent / tracked_docx_name

if tracked_docx_path.exists():
# Make tracked DOCX link relative to current page
tracked_docx_link = os.path.relpath(tracked_docx_path, current_dir)
page_links.append(
f'<a href="{link_path}">{page_info["title"]}</a> '
f'(<a href="{tracked_docx_link}" download>tracked changes</a>)'
)
page_links.append(f'<a href="{link_path}">{page_info["title"]}</a>')
Comment thread
d-morrison marked this conversation as resolved.
except Exception as e:
print(f" Warning: Could not create link to {page_rel_path}: {e}", file=sys.stderr)

Expand Down
16 changes: 10 additions & 6 deletions .github/scripts/create-docx-tracked-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import sys
import subprocess
import shutil
from pathlib import Path

def checkout_base_docx(base_ref='origin/gh-pages', target_dir='/tmp/base-docx'):
Expand Down Expand Up @@ -173,12 +174,16 @@ def process_docx_file(new_docx_path, base_docx_dir, docx_dir):
"""Process a single DOCX file: fetch old version, compare, and create tracked changes version."""
print(f"Processing {new_docx_path}...")

new_path = Path(new_docx_path)
output_path = new_path.parent / f"{new_path.stem}-tracked-changes.docx"

if not base_docx_dir:
print(" No base DOCX directory available")
print(" (New page - creating tracked changes DOCX with all content marked as new)")
shutil.copy2(new_path, output_path)
print(f" ✓ Copied DOCX as tracked changes: {output_path}")
return

# Get the relative path from the docx_dir
new_path = Path(new_docx_path)
docx_dir_path = Path(docx_dir)

try:
Expand All @@ -192,12 +197,11 @@ def process_docx_file(new_docx_path, base_docx_dir, docx_dir):

if not base_path.exists():
print(f" Base DOCX not found: {base_path}")
print(f" (This is normal for new pages)")
print(f" (New page - creating tracked changes DOCX with all content marked as new)")
shutil.copy2(new_path, output_path)
print(f" ✓ Copied DOCX as tracked changes: {output_path}")
return

# Create output path with tracked changes in the same directory structure
output_path = new_path.parent / f"{new_path.stem}-tracked-changes.docx"

print(f" Output will be: {output_path}")

# Create the tracked changes version
Expand Down
43 changes: 24 additions & 19 deletions .github/scripts/detect-changed-chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import sys
import json
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -105,39 +106,43 @@ def main():
print(" 3. Network or permissions issue\n")

# Treat all files as changed
html_files = list(rendered_dir.glob("*.html"))
changed_chapters = [f.stem for f in html_files if f.stem != 'index']
html_files = list(rendered_dir.rglob("*.html"))
changed_chapters = [
str(f.relative_to(rendered_dir).with_suffix(''))
for f in html_files
if f.stem != 'index' and not f.stem.endswith('-slides')
]
else:
print(f"Base files checked out successfully to {base_dir}\n")

# Find all HTML files in rendered output
html_files = list(rendered_dir.glob("*.html"))
# Find all HTML files in rendered output recursively
html_files = list(rendered_dir.rglob("*.html"))

changed_chapters = []
for html_file in html_files:
# Skip index.html - we'll handle that separately
if html_file.stem == 'index':
# Skip index.html and slides files
if html_file.stem == 'index' or html_file.stem.endswith('-slides'):
continue

# Check if HTML changed
base_html = base_dir / f"docs/{html_file.name}"
if not base_html.exists():
base_html = base_dir / html_file.name
# Get relative path from rendered_dir
rel_path = html_file.relative_to(rendered_dir)

# Check if HTML changed (base uses same relative path)
base_html = base_dir / rel_path

html_changed = files_differ(html_file, base_html)

# Check if corresponding DOCX changed
docx_file = html_file.with_suffix('.docx')
base_docx = base_dir / f"docs/{docx_file.name}"
if not base_docx.exists():
base_docx = base_dir / docx_file.name
base_docx = base_dir / rel_path.with_suffix('.docx')

docx_changed = docx_file.exists() and files_differ(docx_file, base_docx)

# If either changed, mark this chapter as changed
if html_changed or docx_changed:
changed_chapters.append(html_file.stem)
print(f" Changed: {html_file.stem} (HTML: {html_changed}, DOCX: {docx_changed})")
chapter_id = str(rel_path.with_suffix(''))
changed_chapters.append(chapter_id)
print(f" Changed: {chapter_id} (HTML: {html_changed}, DOCX: {docx_changed})")

if not changed_chapters:
print("No chapters changed")
Expand All @@ -148,8 +153,8 @@ def main():
f.write("PREVIEW_SHOW_HIGHLIGHTS=false\n")

# Still create the JSON file for home banner
import json
with open('./_site/changed-chapters.json', 'w') as f:
json_path = rendered_dir / 'changed-chapters.json'
with open(json_path, 'w') as f:
json.dump({
'changed_chapters': [],
'count': 0
Expand All @@ -175,8 +180,8 @@ def main():
f.write("PREVIEW_SHOW_HIGHLIGHTS=true\n")

# Also create a JSON file for easy access
import json
with open('./_site/changed-chapters.json', 'w') as f:
json_path = rendered_dir / 'changed-chapters.json'
with open(json_path, 'w') as f:
json.dump({
'changed_chapters': changed_chapters,
'count': len(changed_chapters)
Expand Down
4 changes: 0 additions & 4 deletions _quarto-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ format:
number-sections: true
number-depth: 3
df-print: paged
date: last-modified
date-format: "[Last modified:] YYYY-MM-DD HH:mm:ss (z)"
docx:
toc: true
toc-depth: 3
number-sections: true
number-depth: 3
df-print: tibble
Expand Down
8 changes: 7 additions & 1 deletion chapters/chapter1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ ggplot(mtcars, aes(x = wt, y = mpg)) +

Include citations using `@citationkey` format, which references entries in your `references.bib` file.

I'm adding some new content here:

```{r}
1 + 1
```


## References {.unnumbered}

::: {#refs}
:::

{{< include ../appendix-document-metadata.qmd >}}
1 change: 0 additions & 1 deletion chapters/chapter2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ This is an important callout. Emphasize critical information.
::: {#refs}
:::

{{< include ../appendix-document-metadata.qmd >}}
3 changes: 2 additions & 1 deletion index.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: "Quarto Website Template"
date: last-modified
date-format: "[Last modified:] YYYY-MM-DD HH:mm:ss (z)"
format:
html: default
revealjs:
Expand Down Expand Up @@ -76,4 +78,3 @@ Add your license information here.
::: {#refs}
:::

{{< include appendix-document-metadata.qmd >}}
5 changes: 5 additions & 0 deletions qbt.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

UseNativePipeOperator: Yes
Loading