[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-178-ge521c5f

Ian Beckwith ianb at erislabs.net
Wed Mar 23 00:51:16 UTC 2011


The following commit has been merged in the master branch:
commit e521c5f43db936c85d2c3972ec1009ce4f337533
Author: Ian Beckwith <ianb at erislabs.net>
Date:   Mon Mar 21 21:35:50 2011 +0000

    google: added -safe= option for safesearch

diff --git a/ChangeLog b/ChangeLog
index e806918..6e7de5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-21  Ian Beckwith  <ianb at erislabs.net>
+
+	* google: Added -safe=default|off|moderate|strict
+	  option for Safe Search.
+
 2011-03-21  Ivy Foster  <joyfulgirl at archlinux.us>
 
 	* Added Google Translate to elvi/translate.
diff --git a/elvi/google b/elvi/google
index a5dcd7c..12eb4a5 100755
--- a/elvi/google
+++ b/elvi/google
@@ -8,6 +8,7 @@ w3_config_hook () {
     def   SURFRAW_google_search search
     defyn SURFRAW_google_lucky 0
     def   SURFRAW_google_country us
+    def   SURFRAW_google_safe default
 }
 
 w3_usage_hook () {
@@ -38,6 +39,11 @@ Local options:
   -v, -videos                   Video Search (same as -search=videos)
   -m, -maps                     Map Search (same as -search=maps)
   -n, -news                     News Search (same as -search-news)
+  -safe=                        Safe Search level
+        default         |       Default: $SURFRAW_google_safe
+	off             |       Environment: SURFRAW_google_safe
+	moderate        |
+	strict          |
 EOF
     w3_global_usage
 }
@@ -47,6 +53,7 @@ w3_parse_option_hook () {
     optarg="$2"
     case "$opt" in
     -r*=*)      setopt   SURFRAW_google_results "$optarg" ;;
+    -sa*=*)     setopt   SURFRAW_google_safe    "$optarg" ;;
     -s*=*)      setopt   SURFRAW_google_search  "$optarg" ;;
     -l|-lu*)    setoptyn SURFRAW_google_lucky   1         ;;
     -c=*) 	setopt	 SURFRAW_google_country "$optarg" ;;
@@ -75,6 +82,13 @@ case "$SURFRAW_google_country" in
   *)  domain="$SURFRAW_google_country" ;;
 esac
 
+safe=""
+case "$SURFRAW_google_safe" in
+  strict)   safe="&safe=strict"   ;;
+  moderate) safe="&safe=moderate" ;;
+  off)      safe="&safe=off"      ;;
+esac
+
 url="http://"
 
 if test -z "$w3_args" ; then
@@ -103,7 +117,7 @@ else
 	button=`w3_url_escape "I'm Feeling Lucky"`
 	url="${url}&btnI=$button"
     fi
-    url="${url}${extra}"
+    url="${url}${safe}${extra}"
 fi
 
 w3_browse_url "$url"

-- 
surfraw -  a fast unix command line interface to WWW



More information about the Surfraw-commits mailing list