[Surfraw-devel] searchable_bookmarks

Thomas Zervogiannis tzervo at gmail.com
Sun Jul 1 07:12:32 UTC 2012


Hi Ivy,

> I found a couple of issues; specifically, non-searchable
> bookmarks are likely to consist of more than just a domain.
> Therefore, I've modified that logic to again only simplify
> searchable bookmarks.

What was I thinking, this is why I put the case construct in the first
patch. Sorry for that! Anyway, I made one more correction on that
section because if there is a bookmark with multiple URL's, it was not
functioning correctly if there were no search terms (that was why I
oversimplified). Now it should work correctly for both cases.

Also, I made one
minor modification in the order the arguments are passed to the search
engine, I felt it was better to first give the search terms and then the
domains since its easier to change them afterwards in the browser if
needed.

You can see these minor modifications in the attached patch. I also send an
update for the google elvi, which searches for google/usenet groups, in
case you wanted to add it.

I will try to work next on the autocompletion to make this more
practical (it may take some time since I haven't written autocompletion
rules before and I will have to do some reading on that first!)

Regards,

Thomas
-------------- next part --------------
--- surfraw.IN	2012-07-01 09:46:00.460208086 +0300
+++ ../surfraw-build/surfraw.IN	2012-07-01 09:40:20.630186492 +0300
@@ -507,10 +507,16 @@
 parse_bookmark()
 {
     if [ -z "$w3_args" ]; then
-        # Keep only the domain address, the rest could be garbage.
-        # This bookmark was probably meant to be used like that anyway.
-        echo "$bookmark" | grep -q '%s' && \
-            bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}')
+        case "$bookmark" in
+            *"%s"*)
+                # Keep only the domain address, the rest contains %s which should be filtered.
+                bookmark=$(echo $bookmark | @AWK@ -F '/' '{print $1 "//" $3}')
+                ;;
+            *)
+                # Keep the first URL (if multiple-URL bookmark) as-is, no %s here...
+                bookmark=$(echo $bookmark | cut -f 1 -d ' ')
+                ;;
+        esac
     else
         escaped_args=$(w3_url_of_arg $w3_args)
 
@@ -522,8 +528,8 @@
                 [ -z $SURFRAW_bookmark_search_elvis ] && SURFRAW_bookmark_search_elvis=google
                 bookmark=$(echo $bookmark | sed -e 's|^|site:|' \
                                                 -e 's|\ |\ OR\ site:|g' \
-                                                -e "s|^|$SURFRAW_bookmark_search_elvis |" \
-                                                -e "s|$| $w3_args|")
+                                                -e "s|^|$w3_args |" \
+                                                -e "s|^|$SURFRAW_bookmark_search_elvis |")
                 ;;
         esac
     fi
-------------- next part --------------
*** elvi/google	2012-04-24 07:03:50.312029109 +0300
--- /usr/lib/surfraw/google	2012-04-24 10:02:04.560888241 +0300
***************
*** 25,30 ****
--- 25,31 ----
  	  images	|	Images
  	  videos	|	Videos
  	  maps		|	Maps
+ 	  groups	|	groups
  	  news		|	News
            bsd           |       BSD
            linux         |       Linux
***************
*** 38,44 ****
    -i, -images                   Image Search (same as -search=images)
    -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
--- 39,46 ----
    -i, -images                   Image Search (same as -search=images)
    -v, -videos                   Video Search (same as -search=videos)
    -m, -maps                     Map Search (same as -search=maps)
!   -n, -news                     News Search (same as -search=news)
!   -g, -groups                   Groups Search (same as -search=groups)
    -safe=                        Safe Search level
          default         |       Default: $SURFRAW_google_safe
  	off             |       Environment: SURFRAW_google_safe
***************
*** 61,66 ****
--- 63,69 ----
      -v*)        setopt   SURFRAW_google_search  videos    ;;
      -m*)        setopt   SURFRAW_google_search  maps      ;;
      -n|-news)   setopt   SURFRAW_google_search  news      ;;
+     -g|-groups) setopt   SURFRAW_google_search  groups    ;;
      *) return 1 ;;
      esac
      return 0
***************
*** 95,100 ****
--- 98,104 ----
      case "$SURFRAW_google_search" in
  	i*) url="${url}images" ;;
  	m*) url="${url}maps"   ;;
+ 	g*) url="${url}groups" ;;
  	n*) url="${url}news"   ;;
  	v*) url="${url}video"  ;;
  	*)  url="${url}www"    ;;
***************
*** 106,111 ****
--- 110,116 ----
  	v*) url="${url}www"; search="search"; extra="&tbo=p&tbm=vid";;
  	i*) url="${url}images" ; search="images";;
  	m*) url="${url}maps"   ; search=maps    ;;
+ 	g*) url="${url}groups" ; search=groups  ;;
  	n*) url="${url}news"   ; search=news    ;;
  	*)  url="${url}www"    ;;
      esac


More information about the Surfraw-devel mailing list