Re: goofy HTML addressing

Discussion in 'Java' started by Thomas Fritsch, Feb 14, 2006.

  1. Roedy Green wrote:

    > In particular I refer to html URL relative addressing. It is fine to
    > address members in the same directory, but falls on its nose to
    > address a page elsewhere in the tree. If a page is moved, all links
    > in a page must be recalculated in a way that is highly error-prone.
    >
    > The same included HTML needs to be adjusted depending on where it is
    > inserted to adjust all relative links.
    >
    > If a page moved, there is no simple way with search/replace to find
    > and adjust all links in other pages to it.
    >
    >
    > I make my adjustments with static macros, but the obvious solution is
    > a third mode -- webroot relative addressing.
    >
    > I propose syntax like this
    >
    > href=":images/dog.png"
    >
    > means relative to the webroot which works for local or website
    > browsing You can use that sane syntax to get at your linkages at any
    > depth in the html document tree.

    If you use
    href="/images/dog.png"
    you do have a link relative to the webroot. So what is the difference to
    what you want to achieve? Or did I completely misunderstand you?


    --
    "Thomas:".replace(':', '.').replace('@', '$')
     
    Thomas Fritsch, Feb 14, 2006
    #1
    1. Advertising

  2. Thomas Fritsch

    Roedy Green Guest

    On Tue, 14 Feb 2006 19:34:11 GMT, Thomas Fritsch
    <> wrote, quoted or indirectly quoted
    someone who said :

    >If you use
    > href="/images/dog.png"
    >you do have a link relative to the webroot. So what is the difference to
    >what you want to achieve? Or did I completely misunderstand you?


    but there is no such thing as a webroot locally when you are preparing
    and viewing the files, or distributing them for offline use, right? It
    would be lovely to be wrong on this one. I would kick myself for so
    long spent wrestling with pure relative addresses.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 15, 2006
    #2
    1. Advertising

  3. "Roedy Green" <> wrote:
    > On Tue, 14 Feb 2006 19:34:11 GMT, Thomas Fritsch
    > <> wrote, quoted or indirectly quoted
    > someone who said :
    >
    >>If you use
    >> href="/images/dog.png"
    >>you do have a link relative to the webroot. So what is the difference to
    >>what you want to achieve? Or did I completely misunderstand you?

    >
    > but there is no such thing as a webroot locally when you are preparing
    > and viewing the files, or distributing them for offline use, right?


    Suppose your HTML file is at URL "file://localhost/somedirectory/page.html"
    and you have
    href="/images/dog.png"
    in it. Then this ref would expand to
    href="file://localhost/images/dog.png"
    That means: in this case your webroot is at "file://localhost/"

    > It would be lovely to be wrong on this one. I would kick myself for so
    > long spent wrestling with pure relative addresses.


    --
    "TFritsch$t-online:de".replace(':','.').replace('$','@')
     
    Thomas Fritsch, Feb 15, 2006
    #3
  4. Thomas Fritsch

    Roedy Green Guest

    On Wed, 15 Feb 2006 03:30:28 +0100, "Thomas Fritsch"
    <> wrote, quoted or indirectly quoted
    someone who said :

    >Suppose your HTML file is at URL "file://localhost/somedirectory/page.html"
    >and you have
    > href="/images/dog.png"
    >in it. Then this ref would expand to
    > href="file://localhost/images/dog.png"
    >That means: in this case your webroot is at "file://localhost/"


    but that won`t be where the local file is. Each website you are
    preparing lives in its own directory, not the root.

    In my case for example I need href=":images/dog.png" inside file
    E:\mindprod\jgloss\dalmatian.html to expand to
    file://localhost/E:/mindprod/images/dog.png
    when used locally
    and
    http://mindprod.com/images/dog.png
    when used on the web.

    You want true file urls rather than faked local websites with an HTTP
    servec so that when you do view source you can edit the orginal.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 15, 2006
    #4
  5. Roedy Green wrote:
    > On Wed, 15 Feb 2006 03:30:28 +0100, "Thomas Fritsch" wrote:
    >
    >>Suppose your HTML file is at URL
    >>"file://localhost/somedirectory/page.html" and you have
    >> href="/images/dog.png"
    >>in it. Then this ref would expand to
    >> href="file://localhost/images/dog.png"
    >>That means: in this case your webroot is at "file://localhost/"

    >
    > but that won`t be where the local file is. Each website you are
    > preparing lives in its own directory, not the root.
    >
    > In my case for example I need href=":images/dog.png" inside file
    > E:\mindprod\jgloss\dalmatian.html to expand to
    > file://localhost/E:/mindprod/images/dog.png
    > when used locally
    > and
    > http://mindprod.com/images/dog.png
    > when used on the web.
    >
    > You want true file urls rather than faked local websites with an HTTP
    > servec so that when you do view source you can edit the orginal.


    Well, I must admit, the "file:"-URL technic is not very well-suited for
    offline-testing web-sites.

    One (probably very bad) way to get around this would be:
    Instead of keeping your whole web-content in "E:\mindprod", keep it in "E:\"
    or maybe in "C:\". Then the root "file:///" is, where it should be.

    Another idea is:
    Completely avoid offline-testing with "file:..." URLs. Instead set up a
    HTTP-server on your local machine, and configure it to have "E:\mindprod\"
    as its web-root, and to listen at "localhost".
    Test your offline-site with "http://localhost/...." URLs. When your browser
    sees href="/images/dog.png" in your HTML, it will request
    "http://localhost/images/dog.png", and your local server will respond with
    the contents of "E:\mindprod\images\dog.png".
    You know that you won't need a full-featured server like Apache. Any small
    toy web-server will do. (Google for example for "Tiny HTTPd in Java")

    --
    "Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')
     
    Thomas Fritsch, Feb 15, 2006
    #5
  6. Thomas Fritsch

    Timo Stamm Guest

    Thomas Fritsch schrieb:
    > Well, I must admit, the "file:"-URL technic is not very well-suited for
    > offline-testing web-sites.



    It definitely isn't. Just think about content types.


    > Instead set up a HTTP-server on your local machine


    ACK.


    Timo
     
    Timo Stamm, Feb 15, 2006
    #6
  7. Thomas Fritsch

    Roedy Green Guest

    On Wed, 15 Feb 2006 16:42:44 GMT, Thomas Fritsch
    <> wrote, quoted or indirectly quoted
    someone who said :

    >Completely avoid offline-testing with "file:..." URLs. Instead set up a
    >HTTP-server on your local machine, and configure it to have "E:\mindprod\"
    >as its web-root, and to listen at "localhost".


    The problem with that approach is view source does not work. You are
    using the links to find the stuff you need to update. With a local
    server you don't get the original do you?

    I thought perhaps a clever editor that would render, edit and navigate
    links could be taught to reinterpret absolute links locally. However,
    than leaves out in the cold my users who want to peruse the website
    offsite from a local mirror.

    The problem does not have an elegant solution. Perhaps that is why
    W3C backed away from it.

    Consider the this scenario. You are using google desktop to index
    your local files. You parachute into to a file

    E:\mindprod\jgloss\jar.html and it has a reference to :image\jar.png

    How is the browser to know that really means
    E:\mindprod\images\jgloss\jar.png rather than
    E:\images\jgloss\jar.png
    ?

    Ok, let's say W3C were to invent a header tag called local base
    set to E:/mindprod all is fine, right?
    until somebody downloads the site and puts it in
    F:/mymirrors/mp

    So I think the solution is:

    1. You use a tag of the form ":images/jar.png" which is interpreted
    as webroot relative both on the website and locally.

    2. To help with the translation from webroot to absolute locally, you
    must register a set of webroots in your browser, and the browser
    selects the best/only fit.

    I suppose I could try to introduce this idea into the world purely as
    a browser convenience feature. Then I don't need W3C approval.
    I have to sell it to browser makers a few at a time, and hope the
    natuar0l use of it forces the others to support it too.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 16, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Giorgio

    goofy global.asa

    Giorgio, Jul 24, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    493
    JessicaL
    Jan 29, 2007
  2. Thomas Hawtin

    Re: goofy HTML addressing

    Thomas Hawtin, Feb 14, 2006, in forum: Java
    Replies:
    5
    Views:
    436
    Roedy Green
    Feb 16, 2006
  3. Blair Fraser

    Goofy re.sub behavior

    Blair Fraser, Oct 31, 2003, in forum: Python
    Replies:
    1
    Views:
    327
    Gary Herron
    Nov 1, 2003
  4. Replies:
    74
    Views:
    1,485
    Scott David Daniels
    Sep 23, 2006
  5. Mike Owens
    Replies:
    18
    Views:
    494
    Magnus Lycka
    Sep 13, 2006
Loading...

Share This Page