Feature Proposal: Fallback To Topic When URL has Trailing Space And No Subweb exists but topic does


Help the user that typed a traling / but really just wanted the topic to find his topic

Description and Documentation

See Tasks.Item598 for the background

When you type a URL like http://mydomain/Webname/Topicname we all agree what is web and what is topic

URL http://mydomain/Webname/Subweb/topicname we also agree on

But http://mydomain/Webname/Subweb/ what is that?

The TWiki 4.X behavour is that you reach http://mydomain/Webname/Subweb/WebHome

But what if Subweb does not exist. But we have a topic called Subweb.

TWiki 4.X gives an oops that the Subweb does not exist.

This proposal suggests that if a subweb does not exist but the topic with same name does - Foswiki will go to the topic instead of giving an oops.

The scope for this would be 1.0.1





-- Contributors: KennethLavrsen for SvenDowideit - 02 Jan 2009


I raised this proposal for Sven so that I could close Tasks.Item598 but not allow Sven's suggestion to be forgotten.

I am not sure I prefer this way but if a majority think this is the right way then I will not give any resistance.

This proposal does not break any existing URLs. It is fully backwards compatible.

As release manager I do not dare putting this in 1.0.0. But OK to sneak into a patch release 1.0.1

-- KennethLavrsen - 02 Jan 2009 - 04:24

This has not been sneaked in yet. But noone raised concern so it was 14 day accepted a long time ago.

Sven now that we have release vs trunk - this enhancement should go into trunk only so we get enough time to test and find any negative sideeffects we may have forgotten.

-- KennethLavrsen - 21 Mar 2009

all i ask is that my common use case isn't broken: i often install a blog in a WikiName directory under Main (yes, at the same place that WikiName.txt exists)

-- WillNorris - 23 Mar 2009

eeee, deferring to 1.1.1 or more likely 2.0 - depends on what the change actually entails.

-- SvenDowideit - 31 Mar 2010

Depressing is that my Foswiki 1.0.9 site must use /ParentWeb/SubWeb/ and not /ParentWeb/SubWeb to access the SubWeb.WebHome

-- PaulHarvey - 31 Mar 2010

TimHeilig raised a task - clearly there's user desire for this too..

-- SvenDowideit - 29 Jun 2010

i need to write the tests, but this is the code atm

diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm
index 87ea6c3..97852f5 100644
--- a/core/lib/Foswiki.pm
+++ b/core/lib/Foswiki.pm
@@ -1911,7 +1911,21 @@ sub new {
     if ($webNameTemp) {
         $this->{webName} = $webNameTemp;
+    #http://trunk.foswiki.org/Development/FallBackToTopicWhenTrailingSpaceAndNoSuchSubweb
+    #if the requested web does not exist, try it as a topic (and use the defaultweb and Homeweb in case there's only one param)
+    if (!Foswiki::Func::webExists($this->{webName})) {
+      my $default = $Foswiki::cfg{UsersWebName};
+      if (defined($query->param('defaultweb'))) {
+          $default = Foswiki::Sandbox::untaint( $query->param('defaultweb'), \&Foswiki::Sandbox::validateWebName );
+        }
+        my ($w, $t) = Foswiki::Func::normalizeWebTopicName($default, $this->{webName});
+        if (Foswiki::Func::topicExists($w, $t)) {
+          $this->{webName} = $w;
+          $this->{topicName} = $t;
+        }
+    }
     $this->{scriptUrlPath} = $Foswiki::cfg{ScriptUrlPath};
     # Form definition cache
Topic revision: r12 - 05 Jul 2015, GeorgeClark - This page was cached on 17 Sep 2021 - 18:28.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy