Perl-Sensitive Sunglasses | |
PerlMonks |
URL path shorteningby nop (Hermit) |
on May 23, 2002 at 21:17 UTC ( [id://168899]=perlquestion: print w/replies, xml ) | Need Help?? |
nop has asked for the wisdom of the Perl Monks concerning the following question:
Hi -- I have an app that uses TT2 to write a slew of static HTML files, many which link to one another. I've organized the resulting subsite into a series of directories. To keep my filenames straight, I've put all my name code in one function (see ugly code below). The routine can return a real filename (as TT2 needs a name to write a real physical file), or can return a URL (as the HTML needs URLs, not filenames). My code works fine, but only deals with absolute URLs. I'd like to modify my routine to return relative URLs. This would have 2 advantages: it'd save space (many files have many links); and it'd make the whole project easily relocatable. (The only URL "shortening" recoding I've done so far is chop off everything but the filename if the requesting and requested document live in the same directory. Can anyone point me towards a module or code that will help with URL shortening? For example, if a file living at http://blah.com/html/report/today.htm wants to reference http://blah.com/html/report/yesterday.htm it can do so with the relative <a href="yesterday.htm"> yesterday </a> link. That case is easy, but how about if http://blah.com/html/report/today.htm wants to reference http://blah.com/html/details/fun.htm? I'd like to be able to return a relative link like this <a href="../details/fun.htm"> fun </a>. Anyone have any suggestions? Didn't see anything on perlmonks or CPAN. Thanks -- nop please excuse this ugly code...
|
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: URL path shortening
by merlyn (Sage) on May 24, 2002 at 00:25 UTC | |
Re: URL path shortening
by grinder (Bishop) on May 23, 2002 at 21:44 UTC | |
Re: URL path shortening
by nop (Hermit) on May 24, 2002 at 02:27 UTC |
Log In? |
---|
Domain Nodelet? |
Node Status? |
node history Node Type: perlquestion [id://168899] Approved by crazyinsomniac help |
Chatterbox? |
How do I use this? • Last hour • Other CB clients |
Other Users? |
Others browsing the Monastery: (7) As of 2024-04-23 17:47 GMT |
Sections? |
Information? |
Find Nodes? |
Leftovers? |
|
Voting Booth? |
No recent polls found |