diff --git a/.github/workflows/update-cslib-docs.yaml b/.github/workflows/update-cslib-docs.yaml index 32c2e83..9a5adfc 100644 --- a/.github/workflows/update-cslib-docs.yaml +++ b/.github/workflows/update-cslib-docs.yaml @@ -1,72 +1,40 @@ -name: Update cslib documentation +name: Build and deploy website on: push: branches: - main + pull_request: workflow_dispatch: - schedule: - - cron: '0 */12 * * *' - -# env: -# LAKE_NO_CACHE: true jobs: - build-docs: + build: runs-on: ubuntu-latest steps: - - name: Checkout cslib-community.github.io + - name: Checkout uses: actions/checkout@v6 - - name: Checkout cslib - uses: actions/checkout@v6 + - name: Install Lean and build + uses: leanprover/lean-action@v1 with: - repository: leanprover/cslib - path: cslib - - - name: Install elan - run: | - set -o pipefail - curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- --default-toolchain none -y - echo "$HOME/.elan/bin" >> $GITHUB_PATH - - - name: Set up elan for website - run: | - elan default $(cat lean-toolchain) + build-args: --wfail + test: false + lint: false - - name: Build website + - name: Generate website run: | lake run generate - # - name: Set up elan for cslib docs - # working-directory: cslib/docs - # run: | - # elan default $(cat lean-toolchain) - - # - name: Get cache - # working-directory: cslib/docs - # run: | - # lake exe cache get - - # - name: Build cslib docs - # working-directory: cslib/docs - # run: | - # env LEAN_ABORT_ON_PANIC=1 lake build Cslib:docs - - # - name: Prepare docs in api folder - # run: | - # mkdir -p _cslib.org/api - # cp -r cslib/docs/doc/* _cslib.org/api/ - - name: Upload pages artifact uses: actions/upload-pages-artifact@v5 with: path: '_cslib.org' deploy: - needs: build-docs + needs: build + if: github.ref == 'refs/heads/main' permissions: pages: write @@ -80,6 +48,5 @@ jobs: steps: - name: Deploy to GitHub Pages - if: github.ref == 'refs/heads/main' id: deployment uses: actions/deploy-pages@v5 diff --git a/Lang/Components/ArchiveEntry.lean b/Lang/Components/ArchiveEntry.lean index fe20d50..34c9484 100644 --- a/Lang/Components/ArchiveEntry.lean +++ b/Lang/Components/ArchiveEntry.lean @@ -2,7 +2,7 @@ import Verso.Doc.Html import VersoBlog import Lang.Components.Icon -open Verso.Output Html +open Verso.Output open Verso.Genre.Blog Template namespace Lang @@ -10,9 +10,9 @@ namespace Components private def extractText (html : Html) : String := match html with - | Html.text _ content => content - | Html.tag _ _ contents => extractText contents - | Html.seq contents => + | .text content | .raw content => content + | .element _ _ contents => extractText contents + | .seq contents => contents.foldl (fun acc h => acc ++ extractText h) "" private def htmlTextLength (html : Html) : Nat := @@ -35,40 +35,39 @@ private def truncateHtml (html : Html) (maxLength : Nat) : Html := else acc ++ "..." else buildResult newAcc rest let truncatedText := buildResult "" words - Html.text false truncatedText + Lean.Html.raw truncatedText def archiveEntry (target : String) (metadata : Option Post.PartMetadata) (title : String) (summary : Option Html) (image : Option (String × String)) : Html := - {{ + html%{
  • - {{ image.map (fun x => {{{{x.snd}}}}) }} + {image.map (fun x => html%{{x.snd}/})}
    - {{ match metadata with + {match metadata with | none => Html.empty - | some md => {{ + | some md => html%{ }} - }} - - {{title}} + + {title} - {{truncateHtml summary 200}} + {truncateHtml summary 200} - - "Read more" - {{ Icon.arrowForward (width := "20px") (fill := "#000") }} + + Read more + {Icon.arrowForward (width := "20px") (fill := "#000")}
  • - }} + } end Components end Lang diff --git a/Lang/Components/Aside.lean b/Lang/Components/Aside.lean index 15928b1..ef72da9 100644 --- a/Lang/Components/Aside.lean +++ b/Lang/Components/Aside.lean @@ -2,7 +2,7 @@ import Verso.Doc.Html import VersoBlog import Lang.Components.Icon -open Verso.Output Html +open Verso.Output open Verso.Genre.Blog Template namespace Lang @@ -12,13 +12,13 @@ namespace Components The `aside` component is used to create a sidebar with a title and content. -/ def aside (_title : String) (content : Html): Html := - {{ + html%{ - }} + } end Components end Lang diff --git a/Lang/Components/Basic.lean b/Lang/Components/Basic.lean index e5ed308..c29fb75 100644 --- a/Lang/Components/Basic.lean +++ b/Lang/Components/Basic.lean @@ -3,7 +3,7 @@ import Verso.Doc.Html import VersoBlog open Verso.Genre.Blog -open Verso.Output Html +open Verso.Output open Verso.Doc Html open Verso ArgParse open Verso.Genre @@ -40,12 +40,7 @@ partial defmethod Array.chunk (array : Array α) (size : Nat) : Array (Array α) Sets or updates the given attribute on the first HTML tag node. -/ def setAttribute (attr : String) (value : String) (html : Html) : Html := - match html with - | .tag name attrs children => - match attrs.findIdx? ((· == attr) ∘ Prod.fst) with - | none => .tag name (attrs.push (attr, value)) children - | some i => .tag name (attrs.set! i (attr, value)) children - | _ => html + html.setAttribute attr value /-- Sets an attribute on an HTML element only if the value is defined. diff --git a/Lang/Components/Citation.lean b/Lang/Components/Citation.lean index 2ae8cba..f1f4733 100644 --- a/Lang/Components/Citation.lean +++ b/Lang/Components/Citation.lean @@ -2,7 +2,7 @@ import Lean.Elab import VersoBlog open Verso Genre -open Verso.Output Html +open Verso.Output namespace Lang namespace Components @@ -19,15 +19,15 @@ deriving Lean.ToJson, Lean.FromJson This is a method of grouping things inside of a `.seq` inside a Page or Post. -/ def citation (citation : Citation) : Html := - {{ + html%{
    - {{ citation.authors }} - {{ citation.title }} - {{ citation.venue }} - {{ citation.date }} - {{ citation.pages }} + {citation.authors} + {citation.title} + {citation.venue} + {citation.date} + {citation.pages}
    - }} + } end Components end Lang diff --git a/Lang/Components/CodeBlock.lean b/Lang/Components/CodeBlock.lean index 3d04e7f..4a94de7 100644 --- a/Lang/Components/CodeBlock.lean +++ b/Lang/Components/CodeBlock.lean @@ -5,7 +5,7 @@ import Lean import Lang.Components.Icon open Lean Elab Term -open Verso.Output Html +open Verso.Output open Lang Components Icon open Verso Genre Blog ArgParse Doc Elab @@ -23,48 +23,48 @@ block_component codeGallery where let chunks := content.chunk 4 let tabs ← chunks.mapIdxM fun idx chunk => do - return {{ -