New filtering in MouseHole

Kevin Ballard kevin at sb.org
Fri Sep 9 22:14:57 EDT 2005


Ok, I have a new patch that implements this. include/exclude now take  
the same arguments as the new register_url (and the rewrite=>filter  
change has been dropped). The arguments can be a String, which is  
matched against both the entire URL and just the path, a Regexp,  
which is matched against the entire URL (I recommend ending a regex  
with (?:$|\?|#) if you want to anchor it to the end - this way query  
and fragment are irrelevant). It can be a URI, which is matched  
against the entire URL, with caveats: if the matching URI has no  
query, the query is stripped from the target URL (same for fragment),  
so that way query and fragment won't affect URLs unless you want them  
to. And lastly, if the argument is a hash, the values of the hash are  
compared to the named components of the target URL, either as a  
String or a Regexp.

register_url still passes a uri parameter to the associated block -  
you can "fix" that if you want, but I personally see no problem with  
doing that.

The patch can be found at <http://kevin.sb.org/files/mousehole-2.patch>.

On Sep 4, 2005, at 6:10 PM, Kevin Ballard wrote:

> That's actually a really good idea. It could take a single argument  
> -a regex matches against the whole URL, a string gets compared to  
> the URL (as opposed to translating it to a regex), and a hash gets  
> compared to the URL components.
>
> I'll work on that now, and post a revised patch that makes those  
> changes (as well as reverts filter back to rewrite and turns my new  
> rewrite to register_url).
>
> On Sep 4, 2005, at 5:26 PM, why the lucky stiff wrote:
>
>
>> Well, it's consistent with include_match and exclude_match.  I  
>> want all URL matching schemes to be identical.
>>
>> So, let's say down the road I entertain an idea for per-part  
>> matching:
>>
>>  include_match :scheme => "file"
>>  include_match :scheme => /https?/
>>  include_match :domain => /google\.com$/, :path => "user.js"
>>  exclude_match :scheme => "http", :domain => /boingboing/
>>
>> If I add that, I want it to be consistent for exclude_match and  
>> register_url as well.  Consistency and ease of remembering  
>> MouseHole's API is paramount.

-- 
Kevin Ballard
kevin at sb.org
http://www.tildesoft.com
http://kevin.sb.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2378 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/mousehole-scripters/attachments/20050909/b899f73a/smime.bin


More information about the Mousehole-scripters mailing list