diff --git a/.github/workflows/publish-docs-pr.yml b/.github/workflows/publish-docs-pr.yml new file mode 100644 index 0000000..70d7b7b --- /dev/null +++ b/.github/workflows/publish-docs-pr.yml @@ -0,0 +1,32 @@ +on: + workflow_dispatch: + pull_request: + branches: + - main + - dev + +name: "Publish preview.closeread.dev" +jobs: + publish: + runs-on: ubuntu-latest + steps: + # for accessing this repo's assets in the container + - name: Check out the repo + uses: actions/checkout@v3 + # run the container, attaching this repo as a working directory + - name: Run the build process with Docker + uses: addnab/docker-run-action@v3 + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + with: + image: stat20/stat20-docker:latest + options: -v ${{ github.workspace }}:/home/rstudio/closeread -e NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} + shell: bash + run: | + # exit if any command returns non-zero exit + set -e + + cd /home/rstudio/closeread/ + + # render and publish site + quarto publish netlify docs --id ba6ca24d-1c6b-44b3-b907-16a2bfe5f4b5 diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index d52c65b..8e37dd7 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -1,53 +1,30 @@ -# workflow to build docs site and publish to github pages - on: - workflow_dispatch: push: - branches: main - -name: closeread-publish - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: false + branches: + - main +name: "Publish closeread.dev" jobs: - build-docs: + publish: runs-on: ubuntu-latest - container: - image: ucbscf/berkeley-stat-course:latest - options: --user root - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout closeread repo - uses: actions/checkout@v4 - - - name: Check Quarto version - run: quarto check + # for accessing this repo's assets in the container + - name: Check out the repo + uses: actions/checkout@v3 + # run the container, attaching this repo as a working directory + - name: Run the build process with Docker + uses: addnab/docker-run-action@v3 + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + with: + image: stat20/stat20-docker:latest + options: -v ${{ github.workspace }}:/home/rstudio/closeread -e NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} + shell: bash + run: | + # exit if any command returns non-zero exit + set -e - - name: Render docs site - run: | - # copy closeread extension into docs - cd docs - mkdir -p _extensions/ - cp -Rf ../_extensions/closeread _extensions/ - quarto render - shell: bash + cd /home/rstudio/closeread/ - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Upload docs/ artifact - uses: actions/upload-pages-artifact@v3 - with: - path: "./docs/_site" - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 - + # render and publish site + quarto publish netlify docs --id 2a052dac-9a3d-43c1-9f3d-e37e3cb55af2 diff --git a/.github/workflows/publish-test-site.yml b/.github/workflows/publish-test-site.yml deleted file mode 100644 index 1480517..0000000 --- a/.github/workflows/publish-test-site.yml +++ /dev/null @@ -1,45 +0,0 @@ -# workflow to build docs site and publish to github pages - -on: - workflow_dispatch: - pull_request: - branches: main - -name: closeread-publish-test-site - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - build-docs: - runs-on: ubuntu-latest - container: - image: ucbscf/berkeley-stat-course:latest - options: --user root - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Checkout closeread repo - uses: actions/checkout@v4 - -# - name: Extension into docs site -# run: | -# # copy closeread extension into docs -# cd docs -# mkdir -p _extensions/ -# cp -Rf ../_extensions/closeread _extensions/ -# shell: bash - - - name: Render and Publish - uses: quarto-dev/quarto-actions/publish@v2 - with: - target: netlify - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - path: docs - diff --git a/_extensions/closeread/closeread.css.map b/_extensions/closeread/closeread.css.map index c8f70a0..b2db67a 100644 --- a/_extensions/closeread/closeread.css.map +++ b/_extensions/closeread/closeread.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["closeread.scss"],"names":[],"mappings":"AACA;AAGA;AAEA;AAEA;AAAA;AAAA;AAAA;AAAA;AAMA;EACE;EACA;;AAEA;EACE;;AAEA;EACE;EACA;;AAEA;EAEE;;AAIA;EACE;;AAOR;EACE;;AAIA;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EAGA;EAEA,YACE;;AAMJ;EACE,YACE;;AAGJ;EACE,YACE;;AAKJ;EACE;;AAIA;EACE;EAEA,YACE;;AAGF;EACE;EAEA,YACA;;AAMJ;EACE;EAEA;;AAGA;EACE;EAEA;;AAIF;EACE;EAEA;;;AASZ;AACA;EACE;AAAA;AAAA;AAAA;AAAA;IAKE;;EAEA;AAAA;AAAA;AAAA;AAAA;IACE;IACA;IACA;;EAEA;AAAA;AAAA;AAAA;AAAA;IACE;IACA;IACA;IACA;;EAIJ;AAAA;AAAA;AAAA;AAAA;IACE;;;AAQN;AAAA;AAAA;EAGE;;AAEA;AAAA;AAAA;EACE;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EACE;EACA;EACA;;AAIJ;AAAA;AAAA;EACE;;;AAMF;EACE;;;AAIF;EACE;;;AAIF;EACE;;;AAMJ;EACE;;AAEA;EACE;EACA;;AAEA;EACE;;AAIJ;EACE;;;AAGJ;EACE;;AAEA;EACE;EACA;;AAEA;EACE;;AAIJ;EACE;;;AAKJ;AAAA;AAAA;AAAA;AAAA;EAKE;;AAEA;AAAA;AAAA;AAAA;AAAA;EACE;EACA;EACA;EACA;EACA;;AAGF;AAAA;AAAA;AAAA;AAAA;EACE;;;AAKJ;AAEA;EAEE;AAEA;AAAA;EAEA;EACA;EAEA;EACA;EAGA;;AAGA;EACE;;AAGF;EACE;;;AAIJ;EAEE;EAGA;EACA;EAGA;EAEA;EACA;EAGA;;AAGA;EACE;EAEA;;AAGF;EACE;;;AAKJ;AAKE;EACE;EACA;;AAIF;EACE;;AAKA;EACE;EACA;EACA;;AAEA;EACE;;;AAOR;AAII;EACE;EACA;;AAEA;EACE","file":"closeread.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["closeread.scss"],"names":[],"mappings":"AACA;AAGA;AAEA;AAEA;AAAA;AAAA;AAAA;AAAA;AAMA;EACE;EACA;;AAEA;EACE;;AAEA;EACE;EACA;;AAEA;EAEE;;AAIA;EACE;;AAOR;EACE;;AAIA;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EAGA;EAEA,YACE;;AAMJ;EACE,YACE;;AAGJ;EACE,YACE;;AAKJ;EACE;;AAIA;EACE;EAEA,YACE;;AAGF;EACE;EAEA,YACA;;AAMJ;EACE;EAEA;;AAGA;EACE;EAEA;;AAIF;EACE;EAEA;;;AASZ;AACA;EACE;AAAA;AAAA;AAAA;AAAA;IAKE;;EAEA;AAAA;AAAA;AAAA;AAAA;IACE;IACA;IACA;;EAEA;AAAA;AAAA;AAAA;AAAA;IACE;IACA;IACA;IACA;;EAIJ;AAAA;AAAA;AAAA;AAAA;IACE;;;AAQN;AAAA;AAAA;EAGE;;AAEA;AAAA;AAAA;EACE;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EACE;EACA;EACA;;AAIJ;AAAA;AAAA;EACE;;;AAMF;EACE;;;AAIF;EACE;;;AAIF;EACE;;;AAMJ;EACE;;AAEA;EACE;EACA;;AAEA;EACE;;AAIJ;EACE;;;AAGJ;EACE;;AAEA;EACE;EACA;;AAEA;EACE;;AAIJ;EACE;;;AAKJ;AAAA;AAAA;AAAA;AAAA;EAKE;;AAEA;AAAA;AAAA;AAAA;AAAA;EACE;EACA;EACA;EACA;EACA;;AAGF;AAAA;AAAA;AAAA;AAAA;EACE;;;AAKJ;AAEA;EAEE;AAEA;AAAA;EAEA;EACA;EAEA;EACA;EAGA;;AAGA;EACE;;AAGF;EACE;;;AAIJ;EAEE;EAGA;EACA;EAGA;EAEA;EACA;EAGA;;AAGA;EACE;EAEA;;AAGF;EACE;;;AAKJ;AAKE;EACE;EACA;;AAIF;EACE;;AAKA;EACE;EACA;EACA;;AAEA;EACE;;;AAOR;AAII;EACE;EACA;;AAEA;EACE","file":"closeread.css"} diff --git a/_extensions/closeread/closeread.js b/_extensions/closeread/closeread.js index 6bb6af2..4c71d72 100644 --- a/_extensions/closeread/closeread.js +++ b/_extensions/closeread/closeread.js @@ -58,101 +58,109 @@ document.addEventListener("DOMContentLoaded", () => { // collect all sticky elements const allStickies = Array.from(document.querySelectorAll(".sticky")); - // === Set up scrolling event listeners === // - // scrollama() is accessible because scrollama.min.js is attached via closeread.lua + // scrollama() is accessible because scrollama.min.js is attached + // via closeread.lua + const triggerScrollerConfig = { + step: triggerSelector, + offset: 0.5, + progress: true, + debug: debugMode + } + const progressScrollerConfig = { + step: progressBlockSelector, + offset: 0.5, + progress: true, + debug: debugMode + } + + function crTriggerStepEnter(trigger) { + focusedStickyName = trigger.element.getAttribute("data-focus-on") + + // update ojs variables + ojsTriggerIndex?.define("crTriggerIndex", trigger.index) + ojsStickyName?.define("crActiveSticky", focusedStickyName) + + updateStickies(allStickies, focusedStickyName, trigger) + } + + function crTriggerStepProgress(trigger) { + ojsTriggerProgress?.define("crTriggerProgress", trigger.progress) + ojsDirection?.define("crDirection", trigger.direction) + } + function crProgressStepEnter(progressBlock) { + ojsProgressBlock?.define("crProgressBlock", progressBlock.progress) + } + + // set up scrollers on document load, and reset them when window zoom changes + // (they seem to misbehave on zoom change: see issue #101) + // primary scroller - const triggerScroller = scrollama(); + const triggerScroller = scrollama() triggerScroller - .setup({ - step: triggerSelector, - offset: 0.5, - progress: true, - debug: debugMode - }) - .onStepEnter((trigger) => { - - focusedStickyName = trigger.element.getAttribute("data-focus-on"); - - // update ojs variables - ojsTriggerIndex?.define("crTriggerIndex", trigger.index); - ojsStickyName?.define("crActiveSticky", focusedStickyName); - - updateStickies(allStickies, focusedStickyName, trigger); - - }) - .onStepProgress((trigger) => { - - // update ojs variables - ojsTriggerProgress?.define("crTriggerProgress", trigger.progress); - ojsDirection?.define("crDirection", trigger.direction); - - }); + .setup(triggerScrollerConfig) + .onStepEnter(crTriggerStepEnter) + .onStepProgress(crTriggerStepProgress) - // secondary scroller used for making progress blocks - const progressBlockScroller = scrollama(); - progressBlockScroller - .setup({ - step: progressBlockSelector, - offset: 0.5, - progress: true, - debug: debugMode - }) - .onStepProgress((progressBlock) => { - // update ojs variable - ojsProgressBlock?.define("crProgressBlock", progressBlock.progress); - }); + // secondary scroller used for making progress blocks + const progressBlockScroller = scrollama() + progressBlockScroller + .setup(progressScrollerConfig) + .onStepProgress(crProgressStepEnter) + + window.addEventListener("resize", (event) => { + setTimeout(() => triggerScroller.resize(), 1000) + setTimeout(() => progressBlockScroller.resize(), 1000) + }) + + // === Hotkey Listeners === // + // Add a listener for scrolling between new triggers + let currentIndex = -1; // Start before the first element + + function scrollToNewTrigger(direction) { + const triggers = document.querySelectorAll('.new-trigger'); - // Add a listener for scrolling between new triggers - let currentIndex = -1; // Start before the first element + if (triggers.length === 0) return; // do nothing if there's no triggers - function scrollToNewTrigger(direction) { - const triggers = document.querySelectorAll('.new-trigger'); - - if (triggers.length === 0) return; // do nothing if there's no triggers - - if (direction === "next") { - if (currentIndex >= triggers.length - 1) return; // exit if at end - currentIndex += 1; - } - - if (direction === "previous") { - if (currentIndex === 0) return; // exit if at start - currentIndex -= 1; - } - - const nextTrigger = triggers[currentIndex]; - nextTrigger.scrollIntoView({ behavior: 'smooth', block: 'center' }); + if (direction === "next") { + if (currentIndex >= triggers.length - 1) return; // exit if at end + currentIndex += 1; } - document.addEventListener('keydown', (event) => { - if (event.key === 'ArrowRight') { - scrollToNewTrigger("next"); - } - if (event.key === 'ArrowLeft') { - scrollToNewTrigger("previous"); - } - }); + if (direction === "previous") { + if (currentIndex === 0) return; // exit if at start + currentIndex -= 1; + } + + const nextTrigger = triggers[currentIndex]; + nextTrigger.scrollIntoView({ behavior: 'smooth', block: 'center' }); + } + + document.addEventListener('keydown', (event) => { + if (event.key === 'ArrowRight') { + scrollToNewTrigger("next"); + } + if (event.key === 'ArrowLeft') { + scrollToNewTrigger("previous"); + } + }); - }); - -// === Other Hotkey Listeners === // - -// toggle presentation mode -document.addEventListener('keydown', (event) => { - const crSections = document.querySelectorAll('.cr-section'); - crSections.forEach((el) => { - if (event.key === "p") { - if (el.classList.contains("presentation-mode")) { - el.classList.remove("presentation-mode"); - } else { - el.classList.add("presentation-mode"); + // toggle presentation mode + document.addEventListener('keydown', (event) => { + const crSections = document.querySelectorAll('.cr-section'); + crSections.forEach((el) => { + if (event.key === "p") { + if (el.classList.contains("presentation-mode")) { + el.classList.remove("presentation-mode"); + } else { + el.classList.add("presentation-mode"); + } } - } + }); }); -}); + }); //===============// @@ -393,4 +401,3 @@ function getBooleanConfig(metaFlag) { .querySelector("meta[" + metaFlag + "]")?.getAttribute(metaFlag) return option === "true" } - diff --git a/_extensions/closeread/closeread.lua b/_extensions/closeread/closeread.lua index 0ed0600..963de1a 100644 --- a/_extensions/closeread/closeread.lua +++ b/_extensions/closeread/closeread.lua @@ -515,7 +515,6 @@ return { Para = process_trigger_shortcut }, { - Div = make_section_layout, - Pandoc = add_classes_to_body + Div = make_section_layout } } diff --git a/docs/gallery/demos/_metadata.yml b/docs/gallery/_metadata.yml similarity index 100% rename from docs/gallery/demos/_metadata.yml rename to docs/gallery/_metadata.yml