[Prev][Next][Index][Thread]

Re: Custom Parsers for Search URLs



At 7:39 PM -0500 3/11/97, John C. Mallery wrote:
>At 7:22 PM -0400 1997-03-11, Mark Feblowitz wrote:
>>>In this case, + has no special meaning (we're using form url encoding).
>>>However, you could provide your own parser to convert these into a list if
>>>you like.
>>>
>>>See the discussion in: 
>>>
>>>http://wilson.ai.mit.edu/cl-http/show-documentation?HTTP%3AEXPORT-URL
>>
>>Interesting. So this is is the "right" way to put a standard search url out on a page, in such a way that the search url conventions are not replicated throughout the lisp code in thousands of "(format nil "~A~?~A=?A+?A..." ...) statements, and so that a change in search string conventions can be easily implemented.
>>
>>Now, for a simple (?) question on the use of the URL:STANDARD-WRITE-SEARCH-INFO function: if I were to want to generate an anchor that contains search info in it,  what would be a good way to do this? It seems that the note-anchor fn is looking for a URL, but the STANDARD-WRITE-SEARCH-INFO function wants to write to a stream. 
>
>Sorry, the right url for documentation is:
>
>http://wilson.ai.mit.edu/cl-http/show-documentation?HTTP%3AEXPORT-URL
>
>If you pass an interned URL to note-anchor, it will write the correct thing in your html.
>
>There is no more convenient way to just make a URL beyond intern-url. So, you could
>creaye the search url as an uninterned url and use it as a prototype. You set the search
>keys to the desired parameters, recompute the name string, and then pass this to note-anchor.
>If a cleaner way to accomplish this springs to mind and this is a frequent activity, we could
>add it to the system.

OK - here's one possibility. It's a function that builds and returns a search-url, given the necessary parts. So as not to replicate the code in the reference function url:standard-write-search-info, I've merely captured the stream output from it.

(defun intern-search-url (base-search-url search-keys)
	"Takes a base-search-url (ending with a '?') and search-keys (as either
a list of keys or a query-alist (as accepted by url:standard-write-search-info) 
and returns an interned search url."
  (let ((output-string-stream (make-string-output-stream)))
    (url:standard-write-search-info search-keys output-string-stream)
    (url:intern-url (concatenate 'string (url:coerce-url-string base-search-url)
                                 (get-output-stream-string 
					output-string-stream)))))

Here's how I use it:
                           
 (note-anchor "Click here to examine the enterprise's services"
  (intern-search-url (url:make-http-url-spec-from-pathname 
				"brs/show-enterprise-services?")
                       `((enterprise . (,(string enterprise)))
                         (service . (,(string service))))))
  :stream stream)

which puts out an anchor with a reference of:

	#<HTTP-SEARCH http://host.gte.com/brs/show-enterprise-services?ENTERPRISE=GTE&SERVICE=WIRELINE-POTS #x318BBD6>




Mark Feblowitz
GTE Laboratories Incorporated
40 Sylvan Road
Waltham, MA 02154-1120
mfeblowitz@gte.com
phone:(617) 466-2947 fax: (617) 466-2618




Follow-Ups: References: