]> git.g-eek.se Git - users/gustav/scripts.git/commitdiff
[folkets] Initail on Fokets Lexikon wrapper.
authorGustav Eek <gustav.eek@fripost.org>
Fri, 6 Sep 2019 17:58:01 +0000 (19:58 +0200)
committerGustav Eek <gustav.eek@fripost.org>
Fri, 6 Sep 2019 17:58:04 +0000 (19:58 +0200)
The program works as expected. Some improvements possible:

 * Use w3m also for calling (limit complexity)

 * Consider make a short version for std out

 * Force w3m quit without confirmation (that is how mutt is using w3m)

Makefile
folkets [new file with mode: 0755]

index 76052729623bfff0d02581ac9b9c8bf3ee0185ec..1f707f9f83ddf4fc1be619f2ea915c3d37ad8a36 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,7 @@ confluence-tk \
 json2yaml \
 yaml2json \
 ip-check \
+folkets \
 
 
 bash-completion = \
diff --git a/folkets b/folkets
new file mode 100755 (executable)
index 0000000..9f69e81
--- /dev/null
+++ b/folkets
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# provides translatsions with Folkets lexicon
+
+set -e
+
+BASE="https://folkets-lexikon.csc.kth.se"
+LOC="folkets/service"
+LANG="both"
+INTERFACE="sv"
+LOG="/tmp/folkets/error.out"
+HTML="/tmp/folkets/out.html"
+
+word="$1"
+
+url="$BASE/$LOC"
+
+form="
+  --data-urlencode word=$word
+  --data-urlencode lang=$LANG
+  --data-urlencode interface=$INTERFACE
+"
+
+mkdir -p $(dirname $LOG $HTML)
+
+curl -v -L --get ${form} ${url} 2> $LOG | w3m -T text/html
+
+# Consider make also the call with w3m
+# Consider put on stdout