diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6c11acbcf..45e239475 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,33 +1,67 @@ +// This file was automatically generated with PreTeXt 2.18.1. +// If you modify this file, PreTeXt will no longer automatically update it. +// +////////////////////////////////////////////////////////////// +// +// This file provides configuration options so that a PreTeXt +// project can be edited and built using GitHub's Codespaces. +// It is recommended to keep this in your repository even if you +// do not use this feature, as it will allow other to explore +// your project easily. +// This file will be automatically generated by PreTeXt with the +// latest updates unless you remove the first comment line above. +// +/////////////////////////////////////////////////////////////// { - "name": "PreTeXt-Lite", - "image": "mcr.microsoft.com/devcontainers/python:3", - "features": { - "ghcr.io/devcontainers/features/node:1": {}, - "ghcr.io/rocker-org/devcontainer-features/pandoc:1": {} + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": {}, + + // Comment or uncomment lines below if you don't or do need that feature. + "postCreateCommand": { + // "install sagemath": "bash ./.devcontainer/installSage.sh", + "install pandoc": "bash ./.devcontainer/installPandoc.sh", + "install latex": "bash ./.devcontainer/installLatex.sh", + "install pretext": "bash ./.devcontainer/installPretext.sh", + "mark repo as safe": "git config --global --add safe.directory $(pwd)" + }, + + + // Port forwarding + // --------------- + // This is needed by the CodeChat Server. + "forwardPorts": [ + // The port used for a Thrift connection between the VSCode CodeChat + // extension and the CodeChat Server. + 27376, + // The port used for an HTTP connection from the CodeChat Client to + // the CodeChat Server. + 27377, + // The port used by a websocket connection between the CodeChat + // Server and the CodeChat Client. + 27378 + ], + // See the [docs](https://containers.dev/implementors/json_reference/#port-attributes). + "portsAttributes": { + "27376": { + "label": "VSCode extension <-> CodeChat Server", + "requireLocalPort": true + }, + "27377": { + "label": "CodeChat Client", + "requireLocalPort": true + }, + "27378": { + "label": "CodeChat Client<->Server websocket", + "requireLocalPort": true + // This port needs to be public; however, there's no way to specify port visibility here. See `server.py` in the CodeChat Server for details. + } }, - // "forwardPorts": [ - // 27377, - // 27378 - // ], - // "portsAttributes": { - // "27378": { - // "label": "CodeChat", - // "onAutoForward": "openPreview", - // "requireLocalPort": true, - // "elevateIfNeeded": true, - // "protocol": "https" - // } - // }, - "onCreateCommand": "pip install pretext", - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "sudo bash ./.devcontainer/postCreateCommand.sh", + // Configure tool-specific properties. "customizations": { "codespaces": { - "openFiles": [ - "source/main.ptx" - ] + "openFiles": ["source/main.ptx"] }, "vscode": { "settings": { @@ -35,12 +69,14 @@ "other": "off" }, "editor.snippetSuggestions": "top", - "xml.validation.enabled": false + "xml.validation.enabled": false, + "redhat.telemetry.enabled": false, + "CodeChat.CodeChatServer.Command": "CodeChat_Server" }, - "extensions": ["ms-vscode.live-server", "oscarlevin.pretext-tools"] + "extensions": [ + "oscarlevin.pretext-tools", + "CodeChat.codechat" + ] } } - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" } diff --git a/.devcontainer/devcontainer.json.bak b/.devcontainer/devcontainer.json.bak new file mode 100644 index 000000000..6c11acbcf --- /dev/null +++ b/.devcontainer/devcontainer.json.bak @@ -0,0 +1,46 @@ +{ + "name": "PreTeXt-Lite", + "image": "mcr.microsoft.com/devcontainers/python:3", + "features": { + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/rocker-org/devcontainer-features/pandoc:1": {} + }, + // "forwardPorts": [ + // 27377, + // 27378 + // ], + // "portsAttributes": { + // "27378": { + // "label": "CodeChat", + // "onAutoForward": "openPreview", + // "requireLocalPort": true, + // "elevateIfNeeded": true, + // "protocol": "https" + // } + // }, + "onCreateCommand": "pip install pretext", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sudo bash ./.devcontainer/postCreateCommand.sh", + + // Configure tool-specific properties. + "customizations": { + "codespaces": { + "openFiles": [ + "source/main.ptx" + ] + }, + "vscode": { + "settings": { + "editor.quickSuggestions": { + "other": "off" + }, + "editor.snippetSuggestions": "top", + "xml.validation.enabled": false + }, + "extensions": ["ms-vscode.live-server", "oscarlevin.pretext-tools"] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/installLatex.sh b/.devcontainer/installLatex.sh new file mode 100644 index 000000000..39213dcd8 --- /dev/null +++ b/.devcontainer/installLatex.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. + +# We use TinyTeX (https://yihui.org/tinytex/) +wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh + +tlmgr install adjustbox amscdx bold-extra braket bussproofs cancel carlisle cases chessfss circuitikz colortbl enumitem extpfeil fontawesome5 fontaxes gensymb imakeidx jknapltx kastrup lambda-lists listings listingsutf8 marvosym mathalpha mathtools menukeys mhchem microtype musicography newpx newtx nicematrix pdfcol pdfpages pdflscape pgfplots phaistos physics polyglossia pstricks realscripts relsize siunitx skak skaknew smartdiagram snapshot stmaryrd tcolorbox tikz-cd tikzfill titlesec txfonts ulem upquote was xfrac xltxtra xpatch xstring + +tlmgr path add + +# Ensure fonts provided by TinyTeX are available, as suggested in the pretext guide +fontconfig=" + + + ~/.TinyTeX/texmf-dist/fonts + ~/.TinyTeX/texmf-local/fonts +" + +fontconfig_path="/etc/fonts/conf.d/09-texlive-fonts.conf" +if [ ! -f "$fontconfig_path" ]; then + echo "Creating fontconfig file at $fontconfig_path" + echo "$fontconfig" | sudo tee "$fontconfig_path" > /dev/null +else + echo "Fontconfig file already exists at $fontconfig_path" +fi +# Update font cache +fc-cache -f -v diff --git a/.devcontainer/installPandoc.sh b/.devcontainer/installPandoc.sh new file mode 100644 index 000000000..1edcc5640 --- /dev/null +++ b/.devcontainer/installPandoc.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. + +wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb + +# wait for 60 second and then double check that no other script is using apt-get: +sleep 60 +while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do + echo "Waiting for apt-get to be free..." + sleep 15 +done +# Install pandoc +sudo apt-get install -y --no-install-recommends ./pandoc.deb + +rm pandoc.deb diff --git a/.devcontainer/installPretext.sh b/.devcontainer/installPretext.sh new file mode 100644 index 000000000..fe9ccc09b --- /dev/null +++ b/.devcontainer/installPretext.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. + +sudo apt-get update +sudo apt-get install -y --no-install-recommends \ + python3-louis \ + libcairo2-dev \ + librsvg2-bin + +pip install --upgrade pip --break-system-packages + +pip install pretext[homepage,prefigure] pycairo --only-binary {greenlet} --break-system-packages + +pip install codechat-server --break-system-packages + +playwright install-deps + +playwright install + + +# echo '/usr/lib/python3/dist-packages' > /usr/local/lib/python3.8/dist-packages/louis.pth +prefig init + +# Install mermaid for diagrams +npm install -g @mermaid-js/mermaid-cli + +echo "PreTeXt installation complete." diff --git a/.devcontainer/installSage.sh b/.devcontainer/installSage.sh new file mode 100644 index 000000000..7f71c273c --- /dev/null +++ b/.devcontainer/installSage.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. + +# Conda should already be installed in the codespace. We need to add the conda-forge channel + +conda config --add channels conda-forge +conda config --set channel_priority strict + +# We don't want conda to open the base environment always: +conda config --set auto_activate_base false + +# Now create a conda environment for sage (called sage): +conda create --yes -n sage sage python=3.12 + +conda init + +echo 'conda activate sage' >> ~/.bashrc + +source ~/.bashrc diff --git a/.github/workflows/pretext-cli.yml b/.github/workflows/pretext-cli.yml new file mode 100644 index 000000000..2d8d72398 --- /dev/null +++ b/.github/workflows/pretext-cli.yml @@ -0,0 +1,112 @@ +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. +# +# This workflow file can be used to automatically build a project and create +# an artifact for deployment. It can also be used to deploy the project to +# GitHub Pages or Cloudflare Pages. +# +# The workflow is triggered on pull requests or can be run manually. You can uncomment +# the `push` event to have it run on pushes to the main branch as well. +name: PreTeXt-CLI Actions +on: + # Runs on pull requests + pull_request: + branches: ["*"] + ## Runs on pushes to main + #push: + # branches: ["main"] + # Runs on demand + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + container: oscarlevin/pretext:full + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: install deps + run: pip install -r requirements.txt + + - name: install local ptx files + run: pretext --version + + - name: build deploy targets + run: | + version="$(pretext --version)" + major="$(echo $version | cut -d '.' -f 1)" + minor="$(echo $version | cut -d '.' -f 2)" + if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then + echo "PreTeXt version is 2.5 or greater; using new build command" + pretext build --deploys + else + echo "PreTeXt version is less than 2.5, using old build command" + pretext build + fi + - name: stage deployment + run: pretext deploy --stage-only + + - name: Bundle output/stage as artifact + uses: actions/upload-artifact@v4 + with: + name: deploy + path: output/stage + + deploy-cloudflare: + runs-on: ubuntu-latest + needs: build + if: vars.CLOUDFLARE_PROJECT_NAME != '' + permissions: + contents: read + deployments: write + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: deploy + path: deploy + - name: Create 404.html + run: echo "404 page not found" >> deploy/404.html + - name: Publish to Cloudflare + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.head_ref || github.ref_name }} + directory: deploy + + deploy-ghpages: + runs-on: ubuntu-latest + needs: build + if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + permissions: + contents: read + pages: write + id-token: write + concurrency: + group: "page" + cancel-in-progress: false + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Download website artifact + uses: actions/download-artifact@v4 + with: + name: deploy + path: deploy + - name: Setup GitHub Pages + id: check + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: deploy + - name: Deploy to Github Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/pretext-deploy.yml b/.github/workflows/pretext-deploy.yml new file mode 100644 index 000000000..622be87d7 --- /dev/null +++ b/.github/workflows/pretext-deploy.yml @@ -0,0 +1,64 @@ +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. +# + +name: Build and Deploy +on: + # Currently, this workflow only runs when manually selected (the `workflow_dispatch` event). + # If you would like it to run on other events, uncomment some of the lines below. + + # # Runs on pull requests + # pull_request: + # branches: ["*"] + + # # Runs on pushes to main + # push: + # branches: ["main"] + + # # Runs every day at 00:00 UTC + # schedule: + # - cron: '0 0 * * *' + + # Runs on demand + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: oscarlevin/pretext:small + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: add gh-cli + run: | + apt-get update + apt-get install gh jq -y + + - name: setup git config + run: | + git config --global --add safe.directory $(pwd) + git config user.name "${{ github.actor }} via GitHub Actions" + git config user.email "${{ github.actor }}@github_actions.no_reply" + + - name: install deps + run: pip install -r requirements.txt --break-system-packages + + - name: install local ptx files + run: pretext --version + + - name: build deploy targets + run: pretext build --deploys + + - name: run deploy + run: pretext deploy --no-push + + - name: push gh-pages branch + run: git push origin gh-pages --force + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/.gitignore b/.gitignore index b449ab5e6..918b7b539 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,17 @@ +# This file was automatically generated with PreTeXt 2.18.1. +# If you modify this file, PreTeXt will no longer automatically update it. +# # Boilerplate list of files in a PreTeXt project for git to ignore # ensure this file is tracked !.gitignore -# don't track unpublished builds or stage +# don't track unpublished builds or stage (note: Runestone uses `published`) output +published # don't track assets generated from source -generated generated-assets +.cache # don't track the executables.ptx file executables.ptx @@ -17,7 +21,7 @@ node_modules # don't track error logs .error_schema.log -cli.log +logs # don't track OS related files (windows/macos/linux) .DS_Store @@ -87,9 +91,17 @@ bh_unicode_properties.cache # https://packagecontrol.io/packages/sublime-github GitHub.sublime-settings +# Don't track common virtual environment directories +venv/ # Don't include Dropbox settings and caches .dropbox .dropbox.attr .dropbox.cache +# Don't track codechat config (will be generated automatically) +codechat_config.yaml + +# Don't track deprecated workflows +.github/workflows/deploy.yml +.github/workflows/test-build.yml diff --git a/.gitignore.bak b/.gitignore.bak new file mode 100644 index 000000000..b449ab5e6 --- /dev/null +++ b/.gitignore.bak @@ -0,0 +1,95 @@ +# Boilerplate list of files in a PreTeXt project for git to ignore +# ensure this file is tracked +!.gitignore + +# don't track unpublished builds or stage +output + +# don't track assets generated from source +generated +generated-assets + +# don't track the executables.ptx file +executables.ptx + +# don't track node packages +node_modules + +# don't track error logs +.error_schema.log +cli.log + +# don't track OS related files (windows/macos/linux) +.DS_Store +.DS_Store? +._* +.AppleDouble +.LSOverride +.Spotlight-V100 +.Trashes +Icon +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.stackdump +*.lnk +*.cab +*.msi +*.msix +*.msm +*.msp +[Dd]esktop.ini +.directory +.fuse_hidden* +.Trash-* +.nfs* + +# Don't include VSCode generated files +.vscode +*.code-workspace + +# Don't inlucde SublimeText files +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +*.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + + +# Don't include Dropbox settings and caches +.dropbox +.dropbox.attr +.dropbox.cache + diff --git a/project.ptx b/project.ptx index 715eea0a9..ed84f3acd 100644 --- a/project.ptx +++ b/project.ptx @@ -52,3 +52,99 @@ file2brl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project.ptx.bak b/project.ptx.bak new file mode 100644 index 000000000..715eea0a9 --- /dev/null +++ b/project.ptx.bak @@ -0,0 +1,54 @@ + + + + + + html + src/orcca.ptx + publication/publication.xml + output/html + + + latex + src/orcca.ptx + publication/publication.xml + output/latex + + + pdf + src/orcca.ptx + publication/publication.xml + output/pdf + + + webwork-sets + src/orcca.ptx + publication/publication.xml + output/pg + + + html + src/orcca.ptx + publication/publication-runestone.xml + published/orcca + + + + latex + pdflatex + xelatex + pdf2svg + asy + sage + convert + pdftops + pdf-crop-margins + pageres + node + file2brl + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..263cf0459 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# This file was automatically generated with PreTeXt 2.18.1. +pretext == 2.18.1