@@ 1,52 0,0 @@
-#!/bin/sh
-# Copyright (c) 2021 Sebastian LaVine <mail@smlavine.com>
-# SPDX-License-Identifier: MPL-2.0
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# File: todo
-# Description: Parse a todo.sr.ht issue tracker and display it in Markdown.
-# Arguments: Issue tracker to display, for example '~smlavine/navipage'.
-
-prefix='https://todo.sr.ht/'
-
-# If $1 contains $prefix, then use it as the entire url;
-# otherwise, concatenate it to $prefix to get the full url.
-test "${1#*$prefix}" != "$1" &&
- url="$1" ||
- url="$prefix$1"
-
-curl -s "$url" |
- grep '[0-9]*">#[0-9]*</a>' |
- sed -e 's:^<a href="/::' -e 's:">.*</a>$::' |
- xargs -L1 printf '%s%s\n' "$prefix" |
- grep -v "^$prefix$" | # Don't pipe if tracker isn't found
- xargs curl -s |
- awk -v url="$url" '
- BEGIN { print "# " url "\n" }
- /<title>/ {
- title = !title;
- next;
- }
- title {
- # We are only reading the first line of the title because the
- # next two lines are just " - \nsourcehut todo".
- title = !title;
- gsub("^ *", "# ");
- print $0;
- }
- /<div class="markdown">/ {
- desc = !desc;
- gsub("^.*<p>","");
- }
- desc {
- if ($0 ~ /^<\/div>/) {
- desc = !desc;
- next;
- }
- gsub("^<p>","");
- gsub("</p>$","");
- print $0;
- }
- /<\/html>/ { print "" }'