diff --git a/.devcontainer.json b/.devcontainer/devcontainer.json similarity index 66% rename from .devcontainer.json rename to .devcontainer/devcontainer.json index 87acf06..46a74fc 100644 --- a/.devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,4 @@ -// This file was automatically generated with PreTeXt 2.15.1. +// This file was automatically generated with PreTeXt 2.17.1. // If you modify this file, PreTeXt will no longer automatically update it. // ////////////////////////////////////////////////////////////// @@ -13,22 +13,18 @@ // /////////////////////////////////////////////////////////////// { - "name": "PreTeXt-Codespaces", + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": {}, - // This Docker image includes some LaTeX support, but is still not to large. Note that if you keep your codespace running, it will use up your GitHub free storage quota. Additional options are listed below. - // "image": "oscarlevin/pretext:small", - // If you need to generate more complicated assets (such as sageplots) or use additional fonts when building to PDF, comment out the above line and uncomment the following line. - "image": "oscarlevin/pretext:full", - // If you only intend to build for web and don't have any latex-image generated assets, you can use a smaller image: - // "image": "oscarlevin/pretext:lite", - - // Add gh cli as a feature (to support codechat) - "features": { - "ghcr.io/devcontainers/features/github-cli:1": {} - }, + // 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)" + }, - // Respect the project's designated dependencies - "postCreateCommand": "pip install -r requirements.txt", // Port forwarding // --------------- @@ -61,6 +57,7 @@ } }, + // Configure tool-specific properties. "customizations": { "codespaces": { @@ -76,13 +73,9 @@ "CodeChat.CodeChatServer.Command": "CodeChat_Server" }, "extensions": [ - "ms-vscode.live-server", "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/installLatex.sh b/.devcontainer/installLatex.sh new file mode 100644 index 0000000..6f7eb92 --- /dev/null +++ b/.devcontainer/installLatex.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.17.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 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 \ No newline at end of file diff --git a/.devcontainer/installPandoc.sh b/.devcontainer/installPandoc.sh new file mode 100644 index 0000000..c87a43f --- /dev/null +++ b/.devcontainer/installPandoc.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.17.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 0000000..07b6892 --- /dev/null +++ b/.devcontainer/installPretext.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.17.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] --only-binary {greenlet} --break-system-packages + +pip install codechat-server --break-system-packages + +playwright install-deps + +playwright install + +# Install mermaid for diagrams +npm install -g @mermaid-js/mermaid-cli + +# echo '/usr/lib/python3/dist-packages' > /usr/local/lib/python3.8/dist-packages/louis.pth + +prefig init diff --git a/.devcontainer/installSage.sh b/.devcontainer/installSage.sh new file mode 100644 index 0000000..7166c09 --- /dev/null +++ b/.devcontainer/installSage.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# This file was automatically generated with PreTeXt 2.17.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 + +eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)" +conda activate sage diff --git a/.github/workflows/pretext-cli.yml b/.github/workflows/pretext-cli.yml index 880a287..64eeec4 100644 --- a/.github/workflows/pretext-cli.yml +++ b/.github/workflows/pretext-cli.yml @@ -1,48 +1,49 @@ -# This file was automatically generated with PreTeXt 2.15.1. +# This file was automatically generated with PreTeXt 2.17.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 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 + - name: Install the things run: | - eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)" - conda activate sage - pip install -r requirements.txt + bash ./.devcontainer/installSage.sh + bash ./.devcontainer/installLatex.sh + bash ./.devcontainer/installPretext.sh + git config --global --add safe.directory $(pwd) - name: build deploy targets run: | eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)" conda activate sage - version="$(pretext --version)" # also installs local ptx files - 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 + pretext build --deploys + - name: stage deployment - run: pretext deploy --stage-only + run: | + eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)" + conda activate sage + pretext deploy --stage-only - name: Bundle output/stage as artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pretext-deploy.yml b/.github/workflows/pretext-deploy.yml new file mode 100644 index 0000000..1a86526 --- /dev/null +++ b/.github/workflows/pretext-deploy.yml @@ -0,0 +1,64 @@ +# This file was automatically generated with PreTeXt 2.17.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 b8c3814..dc41491 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# This file was automatically generated with PreTeXt 2.15.1. +# This file was automatically generated with PreTeXt 2.17.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 diff --git a/project.ptx b/project.ptx index 427f538..2e4755c 100644 --- a/project.ptx +++ b/project.ptx @@ -1,5 +1,5 @@ - + diff --git a/requirements.txt b/requirements.txt index 4e2a1b0..dd9ebea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -# This file was automatically generated with PreTeXt 2.15.1. -pretext == 2.15.1 +# This file was automatically generated with PreTeXt 2.17.1. +pretext == 2.17.1