Feature Proposal: Ship HomePagePlugin as a core extension

Motivation

For years I have wondered why the start page is not easily configurable. I'm not the only one:
(14:42:15) foswiki_irc1: I'm looking for a possility to define another starting page for a foswiki server other than /Main/WebHome
(14:42:55) gac410: That's usually done by setting up apache to redirect to a different page.

People often want to do this. Falling back to the web server config is like welding the doors shut on your car and getting in and out through the windows (though I'm all for that if Daisy Duke is anywhere to be seen)

Description and Documentation

So, why don't we add $Foswiki::cfg{DefaultWebName} (and maybe $Foswiki::cfg{DefaultTopicName}). I made the change in my local install in 5 minutes, and it seems to work (though I didn;t run the test suite)

Or am I missing something important?

Impact

  • Possible impact on REST handlers, which will initiate with DefaultWebName not UsersWebName
  • Possible impact on plugins? I can't think what, though.

Implementation

Specifically,
Index: Foswiki.spec
===================================================================
--- Foswiki.spec   (revision 13561)
+++ Foswiki.spec   (working copy)
@@ -1483,6 +1483,12 @@
 # you are doing!)
 $Foswiki::cfg{UsersWebName} = 'Main';
 
+# **STRING 20 EXPERT**
+# Name of the default web where any reference that does not include a web
+# specification will go. This usually only affects the starting web for the
+# wiki.
+$Foswiki::cfg{DefaultWebName} = '$Foswiki::cfg{UsersWebName}';
+
 # **STRING 70x10 EXPERT**
 # A comma-separated list of generic file name templates that defines the order
 # in which templates are assigned to skin path components.
Index: Foswiki.pm
===================================================================
--- Foswiki.pm   (revision 13561)
+++ Foswiki.pm   (working copy)
@@ -1175,7 +1175,7 @@
         # goto oops if URL is trying to take us somewhere dangerous
         $url = $this->getScriptUrl(
             1, 'oops',
-            $this->{webName}   || $Foswiki::cfg{UsersWebName},
+            $this->{webName}   || $Foswiki::cfg{DefaultWebName},
             $this->{topicName} || $Foswiki::cfg{HomeTopicName},
             template => 'oopsredirectdenied',
             def      => 'redirect_denied',
@@ -1565,7 +1565,7 @@
 here)
 
 *WARNING* if there is no web specification (in the web or topic parameters)
-the web defaults to $Foswiki::cfg{UsersWebName}. If there is no topic
+the web defaults to $Foswiki::cfg{DefaultWebName}. If there is no topic
 specification, or the topic is '0', the topic defaults to the web home topic
 name.
 
@@ -1590,7 +1590,7 @@
             $topic = TAINT($topic);
         }
     }
-    $web   ||= $cfg{UsersWebName};
+    $web   ||= $cfg{DefaultWebName};
     $topic ||= $cfg{HomeTopicName};
 
     # MAINWEB and TWIKIWEB expanded for compatibility reasons
@@ -1829,7 +1829,7 @@
       Foswiki::Sandbox::untaint( $web, \&Foswiki::Sandbox::validateWebName );
 
     if ( !defined $this->{webName} && !defined $this->{topicName} ) {
-        $this->{webName}   = $Foswiki::cfg{UsersWebName};
+        $this->{webName}   = $Foswiki::cfg{DefaultWebName};
         $this->{topicName} = $Foswiki::cfg{HomeTopicName};
     }
 
Index: Foswiki/UI/Rename.pm
===================================================================
--- Foswiki/UI/Rename.pm   (revision 13561)
+++ Foswiki/UI/Rename.pm   (working copy)
@@ -666,7 +666,7 @@
         else {
             $new_url = $session->getScriptUrl(
                 0, 'view',
-                $Foswiki::cfg{UsersWebName},
+                $Foswiki::cfg{DefaultWebName},
                 $Foswiki::cfg{HomeTopicName}
             );
         }
Index: Foswiki/UI/Rest.pm
===================================================================
--- Foswiki/UI/Rest.pm   (revision 13561)
+++ Foswiki/UI/Rest.pm   (working copy)
@@ -85,7 +85,7 @@
 
         # No topic specified, but we still have to set a topic to stop
         # plugins being passed the subject and verb in place of a topic.
-        $session->{webName}   = $Foswiki::cfg{UsersWebName};
+        $session->{webName}   = $Foswiki::cfg{DefaultWebName};
         $session->{topicName} = $Foswiki::cfg{HomeTopicName};
     }
 
Index: Foswiki/Func.pm
===================================================================
--- Foswiki/Func.pm   (revision 13561)
+++ Foswiki/Func.pm   (working copy)
@@ -225,7 +225,7 @@
     ASSERT($Foswiki::Plugins::SESSION) if DEBUG;
 
     $web ||= $Foswiki::Plugins::SESSION->{webName}
-      || $Foswiki::cfg{UsersWebName};
+      || $Foswiki::cfg{DefaultWebName};
     return getScriptUrl( $web, $topic, 'view' );
 }
 

Changes in the test set may be required; I didn;t run it.

-- Contributors: CrawfordCurrie - 13 Jan 2012

Discussion

This feature obviously can be extended to make it a bit more useful.

  1. defining a start topic, not only a web seems to be straight forward
  2. defining a different landing page per user to set up foswiki with every user starting at their own profile page
The latter only make sense when the user is already authenticated, thus defining the landing page right after logging in. This in turn requires an url param to override redirecting to the default landing page after logging in. That's required in situations where a clicked page is protected by an interim login screen and the user will expect to see the original page instead of a default landing page. In option 2, the landing page isn't a fixed one either: it takes the user as a parameter.

-- MichaelDaum - 13 Jan 2012

you are not missing anything - it is simple - but its too simple stick out tongue

I wrote HomePagePlugin to cater to a better reality that Micha points out - for an authenticated user, their userpage is the default - thus encouraging the userpage to be a useful dashboard, and then for different uses, different web.topics can be defaults.

you should be able to set web and topic - some users make the guest default == a custom rego topic, and the authed one to go to a different topic depending on group membership...

honestly though, if you commit this, you should also reduce the number of places that setting is used to one thus simplifying the code further.

-- SvenDowideit - 14 Jan 2012

In that case there is a substantial feature overlap in this proposal and an already existing plugin. So this needs further inspection of the plugin's features and merge bring them to the core.

-- MichaelDaum - 14 Jan 2012

I looked at the code of the HomePagePlugin (which I admit I didn't know existed) and it looks reasonable. It's very small, and I can't see why we shouldn't just bring the plugin into the release.

-- CrawfordCurrie - 14 Jan 2012

It needs some unit tests! Other than that I don't have any objections.

-- GeorgeClark - 08 Feb 2012

I've removed my objection and set this as Accepted for 1.2. ... We really ought to get some unit tests created though!

-- GeorgeClark - 23 Feb 2012
 
Topic revision: r10 - 05 Jul 2015, GeorgeClark - This page was cached on 07 Dec 2016 - 23:41.

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