[NTG-context] Downloading long urls

Hans Hagen pragma at wxs.nl
Sun Jan 23 21:54:31 CET 2011


On 23-1-2011 9:34, Aditya Mahajan wrote:
> On Sun, 23 Jan 2011, Hans Hagen wrote:
>
>> On 22-1-2011 1:20, Aditya Mahajan wrote:
>>
>>> A simple algorithm with assume that everything following the dot is the
>>> extension, while that is certainly not the case here. We can definitely
>>> restrict the search of extension to the last 10 or so characters of the
>>> url, but there will be cases when such heuristics will fail.
>>
>> it's not that complicated ... say that you patch this way:
>>
>> function schemes.cleanname(specification)
>> return (gsub(specification.original,"[^%a%d%.]+","-"))
>> end
>>
>> local function fetch(specification)
>> local original = specification.original
>> local scheme = specification.scheme
>> local cleanname = schemes.cleanname(specification)
>>
>> that will be the current method. Now you can experiment with:
>
> Can cleanname be passed as a parameter of the specification? Then we can
> have
>
> local cleanname = specification.cleanname or
> schemes.cleanname(specification)
>
> This way, I can only change the cleanname of the files that are
> downloaded by my module without affecting the cleanname for any other
> command that might want to download a file.

I made this ... as this is rather specialized tuning (that might confuse 
users) it's a directive:

\starttext

\enabletrackers [resolvers.schemes]
\enabledirectives[schemes.cleanmethod=md5]

\externalfigure[http://contextgarden.files.wordpress.com/2008/08/logo-alt41.png][width=3cm]
\externalfigure[http://contextgarden.files.wordpress.com/2008/08/logo-alt41.png][width=3cm]
\externalfigure[http://contextgarden.files.wordpress.com/2008/08/logo-alt41.png][width=3cm]

\stoptext

currently 'strip' is default but we can decide on md5

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list