Gossamer Forum
Home : Products : Others : Fileman :

Relative path problems in HTML view/edit

Quote Reply
Relative path problems in HTML view/edit
Does anyone know how to have Fileman recognize that relative paths shouldn't be based off of the cgi-bin? I have a folder set up within my cgi bin titled 'extranet' within that I plan on having a couple of different sections which will hold HTML files etc. The HTML uses relative paths ("../index.html", "images/image.gif" etc.) which are changed when the pages are processed by the script and displayed via the standard view or edit modes within Fileman. The paths start at the cgi-bin as opposed to the proper directory (cgi-bin/extranet/directory).

Is there a way to get Fileman to display these pages properly? I cannot change the relative paths for these files as this is just a review area, so any changes made here would propagate to the production environment and would no longer function.

Am I missing something simple? Has anyone else gotten around this issue? Help would be greatly appreciated!

Alex
Quote Reply
Re: [alexjones] Relative path problems in HTML view/edit In reply to
I don't think it's simple because Fileman is web based HTML editor and it uses the browser to display information (contents,images ...). If Fileman read a file which have relative paths located outside the web root, the browser won't be able to find that image and won't display the image properly.

Cheers,
jean(at)Gossamer-Threads.com
http://www.gossamer-threads.com
Quote Reply
Re: [alexjones] Relative path problems in HTML view/edit In reply to
Hi,

One possible solution would be to add a <BASE HREF=""> into the src. We'll look into this and see if it works.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [alexjones] Relative path problems in HTML view/edit In reply to
We found a solution for this issue. Please follow the instructions below :

1. Add these new lines ,in red , at the end of FileMan.pm:
Code:

sub js_quote_include {
my $file = shift;
my $tags = GT::Template->tags;
my ($host) = $tags->{html_url} =~ m,(\w+://[^/]*?/)?,;

my $in = new GT::CGI;
my $css_file = $in->cookie('scheme') || 'fileman';
my $color;
CASE: {
($css_file eq 'fileman') and $color = '#D6D6D6', last CASE;
($css_file eq 'gt') and $color = '#d9e4f2', last CASE;
($css_file eq 'maple') and $color = '#F0E8CE', last CASE;
($css_file eq 'rainy') and $color = '#CFD8C2', last CASE;
($css_file eq 'rose') and $color = '#DEC9CE', last CASE;
}
my $parsed = GT::Template->parse("$tags->{template_root}/common/$file",
{
host => $host,
html_url => $tags->{html_url},
scrollbar_arrow_color => 'black',
scrollbar_base_color => $color,
editor_base_color => $color,
advanced_editor_background => 'white',
advanced_editor_font => 'arial'});
$parsed =~ s{([\\/'"<>])}{\\$1}g;
$parsed =~ s/(?:\r\n|\r|\n)/\\n/g;
return \$parsed;
}


2. Add a new line <base href="<%host%>"> to templates/common/editor_editor.html, below the HEAD tag.


Cheers,
jean(at)Gossamer-Threads.Com

Last edited by:

jean: Feb 26, 2002, 12:53 PM
Quote Reply
Re: [jean] Relative path problems in HTML view/edit In reply to
A bit of a belated reply... Thanks for the tip. I'll try this out soon!
Quote Reply
Re: [alexjones] Relative path problems in HTML view/edit In reply to
Is this patch still valid for the latest Fileman? We're having problems with relative links as well.

Rob
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
Well, the patch seems to work for IE7, but not for IE6, as it just outputs "unknown tag". Without the patch, all relative links get converted to the root domain in the URL, which means any subdirectory relative links gets switched to the root domain without the sub-directory. Is there a workaround/patch for this to satisfy all browsers? Is FileMan supported any longer? Thanks.

Rob
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
Add the code below into editor_editor.html:

<head>
<script type="text/javascript">
var host = window.location.protocol + '//' + window.location.hostname
document.write('<base href="' + host + '">');
</script>
</head>
.....

Let me know if it doesn't help.

B.
Quote Reply
Re: [604] Relative path problems in HTML view/edit In reply to
That is the code that was there originally. When I switch it back to that, then relative URL's in a sub-directory get re-written as absolute URL's for the domain in the URL, *and* remove the sub-directory from this absolute path, which breaks functionality. That is what we are trying to fix. Thanks.

Rob
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
In this case, you can change var host = window.location instead.

B.
Quote Reply
Re: [604] Relative path problems in HTML view/edit In reply to
That just puts the URL of where fileman is being used from, which is not good. Basically, What we're looking for is, if you have html code such as:

Code:

<a href="books.html">Books</a>


That fileman when editing this code will *not* modify it to the host name, window.location, etc... Because, if the file exists in a sub-directory off of the main directory, then the rewritten absolute URL is wrong.

Seems fileman editing does not handle relative links at all currently. That is what we're trying to overcome. Thanks.

Rob
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
Unfortunately, the current version does not support for this, but the issue will be on our todo list for the next version of FileMan.

B.
Quote Reply
Re: [604] Relative path problems in HTML view/edit In reply to
Is there a way to get the "work_path" directory in the base href setting? The work_path is the subdirectory, so if we could get into the base href setting (and possibly manipulate it) then the base would be set correctly for sub-directories also...

Rob
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
Yes, there is:

<script type="text/javascript">
var host = window.location.protocol + '//' + window.location.hostname
<%if work_path%>host .= '/<%work_path%>';<%endif%>
document.write('<base href="' + host + '">');
</script>






B.
Quote Reply
Re: [604] Relative path problems in HTML view/edit In reply to
Thanks. Seems that the href replace though balks anytime you put a "/" in the URL, and it falls back to the default or the physical path. Even this does not work:

Code:

<script type="text/javascript">
var host = window.location.protocol + '//' + window.location.hostname + '/test';
document.write('<base href="' + host + '">');
</script>



But this does work (well, it outputs the text right after the domain at least:

Code:

<script type="text/javascript">
var host = window.location.protocol + '//' + window.location.hostname + 'test'
document.write('<base href="' + host + '">');
</script>



Any ideas? Thanks.

Rob

Last edited by:

rmang: Dec 4, 2006, 1:27 PM
Quote Reply
Re: [rmang] Relative path problems in HTML view/edit In reply to
Oops...it should be:

<script type="text/javascript">
var host = window.location.protocol + '//' + window.location.hostname;
<%if work_path%>host += '/<%work_path%>';<%endif%>
document.write('<base href="' + host + '">');
</script>




B.
Quote Reply
Re: [604] Relative path problems in HTML view/edit In reply to
Thanks for all the help. Unfortunately, it does not seem to work when a "/" is added to the host name no matter how you try it. It probably has to do with regexp the code does for URL formatting.

Hopefully a future version could have a settng to not alter relative links. I know this may break preview when editing, but currently editing a file in a sub-directory on the web with relative links and saving will break all links.

Rob