[Prev][Next][Index][Thread]
Re: Custom Parsers for Search URLs
At 3:38 PM -0400 1997-03-12, Mark Feblowitz wrote:
>>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.
Looks like it works. Now it can use some efficiency tuning and a nice calling
interface.
>
>(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)))))
1. Too much consing. I would use an uninterned url see the args for intern-url.
Also, declare all the temporaray structures dynamic-extent. Try to avoid string
streams at practically any cost because they are typically slow.
>
>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)
I would make a macro that sets up all the data structures and stack conses
them. You might do lots of the note-anchors.
>
>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>
References: