Make the sidebar show the most recent patches

Fri Apr 11 2025

Tucker McKnight

Shows the three most recent patches, with a working
"copy pull command" button underneath each one.

7709cb53cc555176a2c4d6dda954c457402f5e64

darcs pull https://repos.tuckerm.us/repos/eleventy-darcs/branches/main -h 7709cb53cc555176a2c4d6dda954c457402f5e64
_includes/main.njk:4
Before
After
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
repo.njk:28
Before
After
        {% for patch in repos[repo].patches | batch(3) | first %}
repo.njk:31
Before
            <h5 class="card-title ">Card title</h5>
            <h6 class="card-subtitle mb-2 text-body-secondary">Card subtitle</h6>
            <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            <a href="#" class="card-link">Card link</a>
After
            <a href="/repos/{{repo}}/patches/{{patch.hash}}" class="text-primary d-inline-block card-title text-decoration-none fs-5">{{patch.name}}</a>
            <p class="card-subtitle fs-6 mb-2 text-body-secondary">{{patch.date}}</p>
            <p class="card-subtitle fs-6 mb-2 text-body-secondary">{{patch.author}}</p>
            <p class="card-text">{{patch.description | truncate(150)}}</p>
repo.njk:36
Before
          </div>
        <div class="card my-3">
            <div class="card-body" &gt;&lt;h5 class="card-title">Card title</h5><h6 class="card-subtitle mb-2 text-body-secondary" &gt;Card subtitle&lt;/h6>
            <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card&#39;s content.&lt;/p>
            <a href="#" class=&quot;card-link&quot;>Card link</a>
After
          <div class="card-footer">
            <span class="card-link font-monospace" data-hash=&quot;{{patch.hash}}&quot; id="copy-pull-{{loop.index}}">{{patch.hash | truncate(8, true, &quot;")}}&lt;/span><button id="pull-button-{{loop.index}}" onclick=&quot;copyPull({{loop.index}})&quot; class="btn btn-sm btn-outline-primary ms-2"><i class="bi-copy bi me-1"&gt;&lt;/i>Pull</button>
repo.njk:40
Before
After
        {% endfor %}
repo.njk:53
Before
After
  }

  const copyPull = (index) => {
    const spanElem = document.getElementById(`copy-pull-${index}`)
    const hash = spanElem.attributes["data-hash"].value
    const button = document.getElementById(`pull-button-${index}`)
    navigator.clipboard.writeText(`darcs clone {{url}} -h ${hash}`).then(() => {
      button.innerHTML = button.innerHTML.replace("Pull", "Copied")
    })