Forum OpenACS Q&A: In widget URL changing to a relative link, deleting Sub Domain required.

I would like to know how I can force the Widget form to code hyperlinks as Absolute hyperlinks, rather than relative references.

Here are more details:

When a URL in our domain is
typed into the Widget using the "Insert Link" button at the top of the widget:


That URL is changed to a Relative File path in the HTML code.

This action prevents the Sub domain from being recorded in the HTML code.

So, when the URL is clicked on, the system cannot find
the Sub domain, and the URL goes to another subdomain, and of course, the hyperlink doesn't work for any user (either the owner of the domain or any other user).

This is the HTML code that the system generates.

<a href = "../../blog" > http://subdomain.domain-name.com/blog</a>

In the bottom left hand corner of the browser, the hyperlink shows as this:

http://team.domain-name.com/blog

So, the subdomain "Team" is substituted for the one that should be there.

This is the result using self, blank, parent, and top targets:

"self" is the default.

<a href= "../movies/message-view/3496240" > Movies </a>

All the Target options are causing the Relative reference to be used, although occasionally some target options use an absolute reference.

Thanks in advance for any suggestions.

Julieanne

Julieanne,

As I understand it, you want the widget to convert a local url to an absolute url.

Look at the source of ec_insecurelink[1] for ideas. It checks if a url is relative (at least for cases of [match /* $new_page] and then builds an absolute url from there.

see also source of these for more ideas:

util_absolute_path_p
subsite::get_url
ad_make_relative_path

1. https://openacs.org/api-doc/proc-view?proc=ec_insecurelink&source_p=1

hope that helps,
Torben

Thanks for your reply Torben. However, the code to do this is in Javascript.

Below is the  Javascript function AddLink, and there's more code for the function dlgInsertLink

I believe it's the  dlgInsertLink that I need to change because that's where the first part of the link is stripped off.  Can anyone confirm this for me please?

<script language="JavaScript" type="text/javascript">
<!--
function AddLink() {
    var oForm = document.linkForm;

    //validate form
    if (oForm.url.value == '') {
        alert('Please enter a url.');
        return false;
    }
    if (oForm.linkText.value == '') {
        alert('Please enter link text.');
        return false;
    }

    var html = '<a href="' + document.linkForm.url.value + '" target="' + document.linkForm.linkTarget.options[document.linkForm.linkTarget.selectedIndex].value + '">' + document.linkForm.linkText.value + '</a>';

window.opener.insertHTML(html);
    window.close();
    return true;
}
//-->

=================

/acs-templating/www/resources/rte/richtext.js has some code for insert_link.  Insert Link calls dlgInsertLink

Is this where I need to change the code to make the Link always  Absolute.

document.writeln('
<td>
<img class="rteImage" src="' + imagesPath + 'hyperlink.gif" width="25" height="24"
alt="Insert Link" title="Insert Link" onClick="dlgInsertLink(\'' + rte + '\', \'link\')">

</td>');

This is function  dlgInsertLink(rte, command)

document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'hyperlink.gif" width="25" height="24"
alt="Insert Link" title="Insert Link" onClick="dlgInsertLink(\'' + rte + '\', \'link\')"></td>');

Thanks in advance,

Julienane