commit e4a4e478285f2b8891e5ceddcf7fd43f82e00322
parent 2a9eba2e6837d95e5b8361d7f58085b72afb21a9
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 20 Sep 2018 21:28:22 +0200
Add exporthtml command, sync to adamsgaard.dk
Diffstat:
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/links/bin/bookmark b/links/bin/bookmark
@@ -1,10 +1,9 @@
 #!/usr/bin/env bash
 
 localfile="$HOME/doc/bookmark.txt"
-remotefile=/home/ad/doc/bookmark.txt
-remoteuser=ad
-hostname=idkfa.ucsd.edu
-hostfile="$remoteuser@$hostname:$remotefile"
+remoteuser=andersdc
+hostname=adamsgaard.dk
+remotefile="/home/$remoteuser/doc/bookmark.txt"
 
 function help {
     echo "Usage: ${0##*/} [OPTION | COMMAND [URL]]"
@@ -18,13 +17,13 @@ function init {
 }
 
 function upload {
-    rsync -ra -e ssh \
+    scp -q \
         "$localfile" \
         "$remoteuser@$hostname:$remotefile"
 }
 
 function download {
-    rsync -ra -e ssh \
+    scp -q \
         "$remoteuser@$hostname:$remotefile" \
         "$localfile"
 }
@@ -48,6 +47,21 @@ function printall {
     cat "$localfile"
 }
 
+function exporthtml {
+    echo "<!DOCTYPE html>"
+    echo "<html><head>"
+    echo "<title>Bookmarks</title>"
+    echo "<meta charset='utf-8'>"
+    echo "</head><body>"
+
+    printall | \
+        sed 's/ /">/' | \
+        sed 's/^/<a href="/' | \
+        sed 's/$/<\/a><\/br>/'
+
+    echo "</body></html>"
+}
+
 function add {
     echo "$@" >> $localfile
 }
@@ -74,6 +88,9 @@ case "$1" in
         clear
         init
         ;;
+    exporthtml)
+        exporthtml
+        ;;
     add)
         download
         add "${*:2}"