Forum OpenACS Development: Improving Gatekeeper Package

Collapse
Posted by Nima Mazloumi on
Hi everybody,

I looked at the code of the gatekeeper package which uses a virtual url header file to display a watched url.

Is it possible to warp the result of the page that is shown inside the master template of openacs so that one has the impression to be inside of openacs? Can anybody help. I think this feature would be great for everyone.

I am thankful for any idea.

Best wishes,
Nima

Collapse
Posted by Jade Rubick on
Nima, can you post the relevant portions of the code, and explain it a little. If nobody else has done it, that's probably the best way to get help on it.

I'm not sure if the question is whether or not .vuh files can return templated results, or something easier.

Collapse
Posted by Tilmann Singer on
The main problem is that most web apps that would be included with gatekeeper like this deliver complete pages already, not only including html and body start and end tags but also their own design and navigation etc. You would need to cut this out somehow before you can wrap it in the openacs template.

Besides that, adding a template around the retrieved data could work like this: add a dummy.adp that contains a unique string that serves as placeholder for your content, retrieve the parsed template into a string like this:

set template [ad_parse_template dummy]

split the result into header and footer:

regexp {^(.*)myplaceholder(.*)$} $template match header footer

and then output header, your content and then the footer with ns_write.

Collapse
Posted by Nima Mazloumi on
Hi Tilmann,

I will try out what you have said. Regarding the html/head/body tags you are right but I also have a lot of requests here at the university to integrate php-based stuff created at the university and they want these to be integrated transparently to OpenACS. I could ask them to leave these tags away. So they can benefit from the gateway package. Also when they switch from mysql to postgresql they can also benefit from user information stored there.

Greetings,
Nima

Collapse
Posted by Nima Mazloumi on
I looked at the code and the following passage does all the rewriting of the pages:

ad_proc -private gatekeeper_subst_tag { page tag relative_url this_dir} {
    #Handle relative urls that start with ../ by translating them as if they were server rr
    regsub -nocase -all "(<\[^>]*\[ \n\t\]+$tag\[ \n\t\]*=\[ \n\t\]*\"?)\.\./(\[^> \n\t\]*)(\[> \n\t\])" $page "\\1$this_dir../\\2\\3" page

    regsub -nocase -all "(<\[^>]*\[ \n\t\]+$tag\[ \n\t\]*=\[ \n\t\]*\"?)/(\[^> \n\t\]*)(\[> \n\t\])" $page "\\1$relative_url\\2\\3" page
    return $page
}

I don't understand the part \[ \n\t\]. Any idea what this implies?

The $tag is "href", "src", "action" or "codebase".
The $page is the original content of the page.

So for instance the following url

http://<server>/<directory>/page.html

is rewritten to

http://<aolserver>/gatekeeper-path/sr//<directory>/page.html

I tested it with real pages but some links are broken.
Also the rewrite seems to have problems with pages that contain frames.
And last but not least I created two gatekeeper-instances, one for PHPMyAdmin and one for PHPPGAdmin (both PHP-applications ;)). While the last one displays at least the pages the first one asks me if I want to download the PHP-Pages. This seems to have something to do with the content-type, I guess.

Has someone had similiar experience with the package?

If we could fix this and extend the package by accept headers and footers and redirecting also cookies then we could create a single-sign-on mechanism for sites that work with cookies.

Greetings,
Nima

Collapse
Posted by Nima Mazloumi on
Alright! I found the reason why some links are broken. When mounting a site under the Gatekeeper-Package:

1. You get a strange behavior if you mount a sub-directory and links inside this directory link to content in parent directories.

2. Only relative URL should be used within the pages that are mounted. I did these changes to the website and it works very well.

Regarding phpMyAdmin or phpPgAdmin (for PostgreSQL) the problems where of another kind:

1. phpMyAdmin the config file had using gzip for outgoing pages set to TRUE so the pages where compressed which causes problems for the Gatekeeper since it assumes that the page is not of type text/html and the IExplorer opens a Download popup window. I turned this feature of and now it works very well.

2. Regarding phpPgAdmin the reason that the Navigation didn't work is the fact that in the browser.php file the path to the server is set via {$_SERVER['PHP_SELF']}. I deleted this part and now it works perfectly.

I will try to get this footer and header problem work.

Greetings,
Nima

Collapse
Posted by Andrew Piskorski on
Yes certainly, the "\[ \n\t\]" is a character class matching either a space, a newline, or a tab.

Now a days that big long regexp pattern all in double quotes is somewhat poor style. (When originally written with an older version of Tcl, it might have been necessary to include the special \n and \t esacpes within double quotes so they would be interpreted by Tcl parser before being seen by the regexp command.)

With all recent versions of Tcl, you can remove a lot of the spurious backslashes by doing it in a few steps like this (note I haven't actually tested this pattern):

set pattern {(<[^>]*[ \n\t]+}
append pattern $tag
append pattern {[ \n\t]*=[ \n\t]*"?)\.\./([^> \n\t]*)([> \n\t])}
regsub -nocase -all $pattern page
The [ \n\t] business could also be replaced by a more general white-space character class as well.