added gateway code so sites can exist at /somepath and not just at /
This commit is contained in:
parent
39b949e9f3
commit
c3acc50381
11 changed files with 64 additions and 45 deletions
|
|
@ -759,9 +759,11 @@ sub updateConfigFile {
|
|||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::Matrix") unless isIn("WebGUI::Asset::Wobject::Matrix",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::InOutBoard") unless isIn("WebGUI::Asset::Wobject::InOutBoard",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::File::ZipArchive") unless isIn("WebGUI::Asset::File::ZipArchive",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::Dashboard") unless isIn("WebGUI::Asset::Wobject::Dashboard",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::StockData") unless isIn("WebGUI::Asset::Wobject::StockData",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::WeatherData") unless isIn("WebGUI::Asset::Wobject::WeatherData",@{$newConfig{assets}});
|
||||
push(@{$newConfig{assets}}, "WebGUI::Asset::Wobject::MultiSearch") unless isIn("WebGUI::Asset::Wobject::MultiSearch",@{$newConfig{assets}});
|
||||
$newConfig{location} = "/";
|
||||
$conf->purge;
|
||||
$conf->set(%newConfig);
|
||||
$conf->write;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
# Add a comma separated list of the names this site can use.
|
||||
# The first site in the list will be used as the default
|
||||
# sitename for generating offline URLs and other functions.
|
||||
|
||||
sitename = www.example.com, example.com
|
||||
|
||||
# The location where the WebGUI server will be handling
|
||||
# requests. This is normally just '/' or the root of the
|
||||
# server, but on some installations it might be /webgui or
|
||||
# /site1, /site2, etc. If this is set to anything other than
|
||||
# '/' then a matching <Location /somepath> block should
|
||||
# contain the WebGUI handler instead in the Apache
|
||||
# VirtualHost configuration.
|
||||
|
||||
gateway = /
|
||||
|
||||
# The relative or fully qualified URL to the extras folder
|
||||
# that comes with WebGUI.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Apache2::RequestIO ();
|
|||
use Apache2::Const -compile => qw(OK DECLINED NOT_FOUND);
|
||||
use Apache2::ServerUtil ();
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub handler {
|
||||
my $r = shift;
|
||||
|
|
@ -54,6 +55,9 @@ sub handler {
|
|||
$r->handler('perl-script');
|
||||
$r->set_handlers(PerlAccessHandler => \&uploadsHandler);
|
||||
} else {
|
||||
$session{requestedUrl} = $session{wguri};
|
||||
my $gateway = $session{config}{gateway};
|
||||
$session{requestedUrl} =~ s/^$gateway(.*)$/$1/;
|
||||
$r->handler('perl-script');
|
||||
$r->set_handlers(PerlResponseHandler => \&contentHandler);
|
||||
$r->set_handlers(PerlTransHandler => sub { return Apache2::Const::OK });
|
||||
|
|
@ -137,7 +141,7 @@ sub page {
|
|||
if ($output eq "") {
|
||||
my $asset = eval{WebGUI::Asset->newByUrl($assetUrl,$session{form}{revision})};
|
||||
if ($@) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't instantiate asset for url: ".$session{wguri}." Root cause: ".$@);
|
||||
WebGUI::ErrorHandler::warn("Couldn't instantiate asset for url: ".$session{requestedUrl}." Root cause: ".$@);
|
||||
}
|
||||
if (defined $asset) {
|
||||
my $method = "view";
|
||||
|
|
@ -205,7 +209,7 @@ sub tryAssetMethod {
|
|||
my $methodToTry = "www_".$method;
|
||||
my $output = eval{$asset->$methodToTry()};
|
||||
if ($@) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for url: ".$session{wguri}." Root cause: ".$@);
|
||||
WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for url: ".$session{requestedUrl}." Root cause: ".$@);
|
||||
$output = tryAssetMethod($asset,'view') if ($method ne "view");
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ Returns the not found object. The not found object is set in the settings.
|
|||
=cut
|
||||
|
||||
sub getNotFound {
|
||||
if ($session{wguri} eq "/*give-credit-where-credit-is-due*") {
|
||||
if ($session{requestedUrl} eq "*give-credit-where-credit-is-due*") {
|
||||
my $content = "";
|
||||
open(FILE,"<".$session{config}{webguiRoot}."/docs/credits.txt");
|
||||
while (<FILE>) {
|
||||
|
|
@ -795,7 +795,7 @@ sub getNotFound {
|
|||
className=>"WebGUI::Asset::Snippet",
|
||||
snippet=> '<pre>'.$content.'</pre>'
|
||||
});
|
||||
} elsif ($session{wguri} eq "/abcdefghijklmnopqrstuvwxyz") {
|
||||
} elsif ($session{requestedUrl} eq "abcdefghijklmnopqrstuvwxyz") {
|
||||
return WebGUI::Asset->newByPropertyHashRef({
|
||||
className=>"WebGUI::Asset::Snippet",
|
||||
snippet=>q|<div style="width: 600px; padding: 200px;">Why would you type in this URL? Really. What were you expecting to see here? You really need to get a life. Are you still here? Seriously, you need to go do something else. I think your boss is calling.</div>|
|
||||
|
|
@ -1101,7 +1101,7 @@ A specific revision to instanciate. By default we instanciate the newest publish
|
|||
|
||||
sub newByUrl {
|
||||
my $class = shift;
|
||||
my $url = shift || $session{wguri};
|
||||
my $url = shift || $session{requestedUrl};
|
||||
my $revisionDate = shift;
|
||||
$url = lc($url);
|
||||
$url =~ s/\/$//;
|
||||
|
|
|
|||
|
|
@ -666,8 +666,7 @@ sub view {
|
|||
} else {
|
||||
$sql .= "asset.lineage";
|
||||
}
|
||||
my $currentPageUrl = $session{wguri};
|
||||
$currentPageUrl =~ s/^\///;
|
||||
my $currentPageUrl = $session{requestedUrl};
|
||||
$p->setDataByQuery($sql, undef, undef, undef, "url", $currentPageUrl);
|
||||
foreach my $dataSet (@{$p->getPageData()}) {
|
||||
next unless ($dataSet->{className} eq "WebGUI::Asset::Post" || $dataSet->{className} eq "WebGUI::Asset::Post::Thread"); #handle non posts!
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ sub displayLogin {
|
|||
my $method = $_[0] || "login";
|
||||
my $vars = $_[1];
|
||||
unless ($session{form}{op} eq "auth") {
|
||||
WebGUI::Session::setScratch("redirectAfterLogin",WebGUI::URL::gateway($session{wguri},$session{env}{QUERY_STRING}));
|
||||
WebGUI::Session::setScratch("redirectAfterLogin",WebGUI::URL::page($session{env}{QUERY_STRING}));
|
||||
}
|
||||
$vars->{title} = WebGUI::International::get(66);
|
||||
my $action;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub copyIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'copy.gif" align="middle" border="0" alt="'.WebGUI::International::get('Copy','Icon').'" title="'.WebGUI::International::get('Copy','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -125,7 +125,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub cutIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'cut.gif" align="middle" border="0" alt="'.WebGUI::International::get('Cut','Icon').'" title="'.WebGUI::International::get('Cut','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -158,7 +158,7 @@ sub deleteIcon {
|
|||
$confirmText = qq| onclick="return confirm('$confirmText')" |;
|
||||
}
|
||||
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'" '.$confirmText.'>';
|
||||
$output .= '<img src="'._getBaseURL().'delete.gif" align="middle" border="0" alt="'.WebGUI::International::get('Delete','Icon').'" title="'.WebGUI::International::get('Delete','Icon').'" /></a>';
|
||||
|
|
@ -195,7 +195,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub editIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'edit.gif" align="middle" border="0" alt="'.WebGUI::International::get('Edit','Icon').'" title="'.WebGUI::International::get('Edit','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -219,7 +219,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub exportIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
# TODO Change icon to Jeffs export icon
|
||||
$output .= '<img src="'._getBaseURL().'export.gif" align="middle" border="0" alt="'.WebGUI::International::get('Export','Icon').'" title="'.WebGUI::International::get('Export','Icon').'" /></a>';
|
||||
|
|
@ -292,7 +292,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub lockedIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'locked.gif" align="middle" border="0" alt="'.WebGUI::International::get('locked','Icon').'" title="'.WebGUI::International::get('locked','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -316,7 +316,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub manageIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'manage.gif" align="middle" border="0" alt="'.WebGUI::International::get('Manage','Icon').'" title="'.WebGUI::International::get('Manage','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -340,7 +340,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveBottomIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveBottom.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move To Bottom','Icon').'" title="'.WebGUI::International::get('Move To Bottom','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -364,7 +364,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveDownIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveDown.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Down','Icon').'" title="'.WebGUI::International::get('Move Down','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -388,7 +388,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveLeftIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveLeft.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Left','Icon').'" title="'.WebGUI::International::get('Move Left','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -412,7 +412,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveRightIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveRight.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Right','Icon').'" title="'.WebGUI::International::get('Move Right','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -436,7 +436,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveTopIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveTop.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move To Top','Icon').'" title="'.WebGUI::International::get('Move To Top','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -460,7 +460,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveUpIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveUp.gif" align="middle" border="0" alt="'.WebGUI::International::get('Move Up','Icon').'" title="'.WebGUI::International::get('Move Up','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -496,7 +496,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub pasteIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'paste.gif" align="middle" border="0" alt="'.WebGUI::International::get('Paste','Icon').'" title="'.WebGUI::International::get('Paste','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -520,7 +520,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub shortcutIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'shortcut.gif" align="middle" border="0" alt="'.WebGUI::International::get('Create Shortcut','Icon').'" title="'.WebGUI::International::get('Create Shortcut','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
@ -544,7 +544,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub viewIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{wguri};
|
||||
$pageURL = $_[1] || $session{requestedUrl};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'view.gif" align="middle" border="0" alt="'.WebGUI::International::get('View','Icon').'" title="'.WebGUI::International::get('View','Icon').'" /></a>';
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use WebGUI::URL;
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{wguri};
|
||||
return WebGUI::URL::page();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ package WebGUI::Macro::Slash_gatewayUrl;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return "/";
|
||||
return WebGUI::URL::gateway();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ sub process {
|
|||
if ($session{env}{REQUEST_URI} =~ /op\=/) {
|
||||
$append = 'op2='.WebGUI::URL::escape($append);
|
||||
}
|
||||
$temp = WebGUI::URL::gateway($session{wguri},$append);
|
||||
$temp = WebGUI::URL::page($append);
|
||||
$temp =~ s/\/\//\//;
|
||||
$temp = WebGUI::URL::append($temp,$session{env}{QUERY_STRING});
|
||||
if ($param[1] ne "") {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ The string to escape.
|
|||
=cut
|
||||
|
||||
sub escape {
|
||||
return uri_escape($_[0]);
|
||||
return uri_escape(shift);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -105,11 +105,11 @@ sub escape {
|
|||
|
||||
=head2 gateway ( pageURL [ , pairs ] )
|
||||
|
||||
Generate a URL based on WebGUI's gateway script.
|
||||
Generate a URL based on WebGUI's location directive.
|
||||
|
||||
=head3 pageURL
|
||||
|
||||
The urlized title of a page that you wish to create a URL for.
|
||||
The url of an asset that you wish to create a fully qualified URL for.
|
||||
|
||||
=head3 pairs
|
||||
|
||||
|
|
@ -120,13 +120,17 @@ Name value pairs to add to the URL in the form of:
|
|||
=cut
|
||||
|
||||
sub gateway {
|
||||
$_[0] =~ s/^\///;
|
||||
my $url = '/'.$_[0];
|
||||
my $pageUrl = shift;
|
||||
my $pairs = shift;
|
||||
$pageUrl =~ s/^\///;
|
||||
my $url = $session{config}{gateway};
|
||||
$url .= '/' unless ($url =~ m/\/$/);
|
||||
$url .= $pageUrl;
|
||||
if ($session{setting}{preventProxyCache} == 1) {
|
||||
$url = append($url,"noCache=".randint(0,1000).';'.time());
|
||||
}
|
||||
if ($_[1]) {
|
||||
$url = append($url,$_[1]);
|
||||
if ($pairs) {
|
||||
$url = append($url,$pairs);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
|
@ -169,8 +173,7 @@ sub setSiteURL {
|
|||
|
||||
=head2 getSiteURL ( )
|
||||
|
||||
Returns a constructed site url. The returned
|
||||
value can be overridden using the setSiteURL function.
|
||||
Returns a constructed site url. The returned value can be overridden using the setSiteURL function.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -222,7 +225,7 @@ Returns the URL of the current page.
|
|||
=head3 pairs
|
||||
|
||||
Name value pairs to add to the URL in the form of:
|
||||
|
||||
gateway()
|
||||
name1=value1;name2=value2;name3=value3
|
||||
|
||||
=head3 useSiteUrl
|
||||
|
|
@ -243,15 +246,12 @@ sub page {
|
|||
if ($useFullUrl) {
|
||||
$url = getSiteURL();
|
||||
}
|
||||
$url .= '/';
|
||||
my $pathinfo;
|
||||
$url .= gateway();
|
||||
if ($session{asset}) {
|
||||
$pathinfo = $session{asset}->get("url");
|
||||
$url .= $session{asset}->get("url");
|
||||
} else {
|
||||
$pathinfo = $session{wguri};
|
||||
$pathinfo =~ s/^\/(.*)/$1/;
|
||||
$url .= $session{requestedUrl};
|
||||
}
|
||||
$url .= $pathinfo;
|
||||
if ($session{setting}{preventProxyCache} == 1 && !$skipPreventProxyCache) {
|
||||
$url = append($url,"noCache=".randint(0,1000).';'.time());
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ The string to unescape.
|
|||
=cut
|
||||
|
||||
sub unescape {
|
||||
return uri_unescape($_[0]);
|
||||
return uri_unescape(shift);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -293,7 +293,7 @@ Returns a url that is safe for WebGUI pages.
|
|||
|
||||
sub urlize {
|
||||
my ($value);
|
||||
$value = lc($_[0]); #lower cases whole string
|
||||
$value = lc(shift); #lower cases whole string
|
||||
$value = makeCompliant($value);
|
||||
$value =~ s/\/$//;
|
||||
return $value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue