summaryrefslogtreecommitdiff
path: root/contrib/wikipedia-search-handler
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/wikipedia-search-handler')
-rwxr-xr-xcontrib/wikipedia-search-handler17
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/wikipedia-search-handler b/contrib/wikipedia-search-handler
new file mode 100755
index 0000000..72f051f
--- /dev/null
+++ b/contrib/wikipedia-search-handler
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+uri="$1"
+shortened="$(unshorten.sh "${uri}")"
+if [ "${shortened}" ];then
+ uri="${shortened}"
+fi
+shortened="$(unshorten.sh "${uri}")"
+if [ "${shortened}" ];then
+ uri="${shortened}"
+ uristart "$uri"
+else
+ curl -g "$uri" | grep '^<i>The page "<a href="/w/index' | sed 's|<i>\([^<]\)</i>||g' | tr '<' '\n' \
+ | grep ^a \
+ | cut '-d"' -f2 \
+ | sed 's|^/|https://en.wikipedia.org/|g' \
+ | text_uri-list
+fi