aboutsummaryrefslogtreecommitdiff
path: root/buildsite.sh
diff options
context:
space:
mode:
Diffstat (limited to 'buildsite.sh')
-rwxr-xr-xbuildsite.sh168
1 files changed, 168 insertions, 0 deletions
diff --git a/buildsite.sh b/buildsite.sh
index 1a1e75e6..6e24206d 100755
--- a/buildsite.sh
+++ b/buildsite.sh
@@ -3,6 +3,172 @@
rm -rf public
mkdir -p public
+html_escape() {
+ sed 's/\&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g;s/"/\&quot;/g'
+}
+
+port_version() {
+ grep '^version=' "$1/abuild" | cut -d = -f2- || true
+}
+
+port_release() {
+ grep '^release=' "$1/abuild" | cut -d = -f2- || true
+}
+
+port_depends() {
+ [ -f "$1/depends" ] || return 0
+ grep -Ev '^(#|$)' "$1/depends" | tr '\n' ' ' | sed 's/[[:space:]]*$//' || true
+}
+
+generate_ports_page() {
+ {
+ sed "s/@TITLE@/ports/g" files/header
+ cat << 'EOF'
+<style>
+.ports-toolbar {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ margin-bottom: 12px;
+}
+.ports-toolbar button,
+.ports-toolbar input {
+ font: inherit;
+ color: #fefefe;
+ background: transparent;
+ border: 0;
+ border-bottom: 1px solid rgba(231, 232, 235, 0.35);
+ padding: 6px 0;
+}
+.ports-toolbar button {
+ cursor: pointer;
+}
+.ports-toolbar button.active {
+ color: #90cbf9;
+ border-bottom-color: #90cbf9;
+}
+.ports-toolbar input {
+ flex: 1 1 18em;
+ min-width: 0;
+}
+.ports-count {
+ margin-bottom: 12px;
+}
+#ports-table th,
+#ports-table td {
+ border: 0;
+ border-bottom: 1px solid rgba(231, 232, 235, 0.28);
+ padding: 6px 4px;
+}
+#ports-table {
+ border: 0;
+ table-layout: auto;
+}
+#ports-table thead th {
+ border-bottom-color: rgba(231, 232, 235, 0.55);
+}
+#ports-table th:nth-child(1),
+#ports-table td:nth-child(1) {
+ width: 5em;
+}
+#ports-table th:nth-child(2),
+#ports-table td:nth-child(2) {
+ width: 16em;
+}
+#ports-table th:nth-child(3),
+#ports-table td:nth-child(3) {
+ white-space: nowrap;
+ width: 1%;
+}
+#ports-table th:nth-child(4),
+#ports-table td:nth-child(4) {
+ width: 100%;
+}
+#ports-table tbody tr:last-child td {
+ border-bottom: 0;
+}
+EOF
+ echo "</style>"
+ echo "<p>Package ports generated from <code>repos/core</code>, <code>repos/extra</code>, and <code>repos/community</code>.</p>"
+ echo "<div class=\"ports-toolbar\">"
+ echo "<button type=\"button\" class=\"active\" data-repo=\"all\">all</button>"
+ echo "<button type=\"button\" data-repo=\"core\">core</button>"
+ echo "<button type=\"button\" data-repo=\"extra\">extra</button>"
+ echo "<button type=\"button\" data-repo=\"community\">community</button>"
+ echo "<input id=\"ports-search\" type=\"search\" placeholder=\"filter ports\" autocomplete=\"off\">"
+ echo "</div>"
+ echo "<div class=\"ports-count\"><span id=\"ports-visible\">0</span> / <span id=\"ports-total\">0</span> ports</div>"
+ echo "<table id=\"ports-table\">"
+ echo "<thead><tr><th>repo</th><th>name</th><th>version</th><th>dependencies</th></tr></thead>"
+ echo "<tbody>"
+
+ for repo in core extra community; do
+ for port in repos/$repo/*; do
+ [ -f "$port/abuild" ] || continue
+ name=${port##*/}
+ version=$(port_version "$port")
+ release=$(port_release "$port")
+ depends=$(port_depends "$port")
+ [ "$release" ] && version=$version-$release
+ printf '<tr data-repo="%s"><td>%s</td><td><a href="https://codeberg.org/emmett1/alicelinux/src/branch/main/repos/%s/%s">%s</a></td><td>%s</td><td>%s</td></tr>\n' \
+ "$(printf '%s' "$repo" | html_escape)" \
+ "$(printf '%s' "$repo" | html_escape)" \
+ "$(printf '%s' "$repo" | html_escape)" \
+ "$(printf '%s' "$name" | html_escape)" \
+ "$(printf '%s' "$name" | html_escape)" \
+ "$(printf '%s' "$version" | html_escape)" \
+ "$(printf '%s' "$depends" | html_escape)"
+ done
+ done
+
+ echo "</tbody>"
+ echo "</table>"
+ cat << 'EOF'
+<script>
+(function () {
+ var table = document.getElementById('ports-table');
+ var rows = Array.prototype.slice.call(table.querySelectorAll('tbody tr'));
+ var search = document.getElementById('ports-search');
+ var visible = document.getElementById('ports-visible');
+ var total = document.getElementById('ports-total');
+ var buttons = Array.prototype.slice.call(document.querySelectorAll('.ports-toolbar button'));
+ var repo = 'all';
+
+ total.textContent = rows.length;
+
+ function filterPorts() {
+ var query = search.value.trim().toLowerCase();
+ var count = 0;
+
+ rows.forEach(function (row) {
+ var repoMatch = repo === 'all' || row.dataset.repo === repo;
+ var textMatch = !query || row.textContent.toLowerCase().indexOf(query) !== -1;
+ var show = repoMatch && textMatch;
+ row.style.display = show ? '' : 'none';
+ if (show) count++;
+ });
+
+ visible.textContent = count;
+ }
+
+ buttons.forEach(function (button) {
+ button.addEventListener('click', function () {
+ repo = button.dataset.repo;
+ buttons.forEach(function (b) { b.classList.remove('active'); });
+ button.classList.add('active');
+ filterPorts();
+ });
+ });
+
+ search.addEventListener('input', filterPorts);
+ filterPorts();
+}());
+</script>
+EOF
+ cat files/footer
+ } > public/ports.html
+}
+
for i in $(find . -type f -name "*.html" | sed 's|^\./||'); do
dir=${i%/*}
file=${i##*/}
@@ -19,6 +185,8 @@ for i in $(find . -type f -name "*.html" | sed 's|^\./||'); do
} > public/$dir/$file
done
+generate_ports_page
+
# docs
cat docs/readme.md > docs/index.md
for f in docs/*.md; do