[dokuwiki] Global start page patch
- From: Guy Brand <gb@xxxxxxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 28 Dec 2005 15:40:42 +0100
Hi all,
Attached is a small patch against darcs synced copy[1] which extends
the role of $conf['start'] to all the namespaces of a dokuwiki and
checks for an existing namespace when requesting a page.
Example:
pages/
start.txt
otherpage.txt
project/
start.txt
references.txt
wiki/
syntax.txt
dokuwiki.txt
Currently with dokuwiki ($conf['start'] = 'start'):
------------------------------------------------------------
Requested page Action Target
------------------------------------------------------------
id= Show start.txt
id=project/start Show project/start.txt
id=project/ Create project.txt
id=project: Create project.txt
id=project Create project.txt
id=wiki Create wiki.txt
id=wiki/syntax Show wiki/syntax.txt
id=ghost Create ghost.txt
------------------------------------------------------------
With the patch applied and $conf['globalstart'] = 1 :
------------------------------------------------------------
Requested page Action Target
------------------------------------------------------------
id= Show start.txt
id=project/start Show project/start.txt
id=project/ Show project/start.txt
id=project: Show project/start.txt
id=project Show project/start.txt
id=wiki Create wiki/start.txt
id=wiki/syntax Show wiki/syntax.txt
id=ghost Create ghost.txt
------------------------------------------------------------
Any start.txt page existing inside a subdirectory of data/pages is
used as default page when the subdirectory is requested. This
default page is also returned when a requested subdirectory exists
but does not contain this $conf['start'] page.
By default $conf['globalstart'] is set to false.
Would defaultpage be a better variable name that globalstart?
Comments and tests are welcome.
gb
[1] hash=20051213175633-9b6ab-1103b79a9d956d72e20b3df6ba4e5e6b55443c78
diff -aur dokuwiki/conf/dokuwiki.php work/conf/dokuwiki.php
--- dokuwiki/conf/dokuwiki.php Tue Nov 29 14:46:30 2005
+++ work/conf/dokuwiki.php Wed Dec 28 15:04:25 2005
@@ -19,6 +19,7 @@
/* Display Options */
$conf['start'] = 'start'; //name of start page
+$conf['globalstart'] = 0; //is the start page global to all
namespaces
$conf['title'] = 'DokuWiki'; //what to show in the title
$conf['template'] = 'default'; //see tpl directory
$conf['fullpath'] = 0; //show full path of the document or
relative to datadir only? 0|1
diff -aur dokuwiki/inc/pageutils.php work/inc/pageutils.php
--- dokuwiki/inc/pageutils.php Tue Nov 29 14:46:31 2005
+++ work/inc/pageutils.php Wed Dec 28 15:03:16 2005
@@ -53,6 +53,12 @@
$id = preg_replace('!^/+!','',$id);
}
if(empty($id) && $param=='id') $id = $conf['start'];
+
+ //if a subdir with name = id exists, turn id to it using default start page
name
+ if($conf['globalstart'] &&
@file_exists($conf['datadir'].'/'.utf8_encodeFN($id).'/'.$conf['start'].'.txt'))
{
+ $id .= '/';
+ }
+
if($clean) $id = cleanID($id);
return $id;
@@ -94,8 +100,18 @@
//clean up
$id = preg_replace($sepcharpat,$sepchar,$id);
$id = preg_replace('#:+#',':',$id);
- $id = trim($id,':._-');
+ if($conf['globalstart']) {
+ $id = trim($id,'._-');
+ } else {
+ $id = trim($id,':._-');
+ }
$id = preg_replace('#:[:\._\-]+#',':',$id);
+
+ if($conf['globalstart']) {
+ if(noNS($id)=='') {
+ $id .= $conf['start'];
+ }
+ }
return($id);
}
- Follow-Ups:
- [dokuwiki] Re: Global start page patch
- From: Anika Henke
Other related posts:
- » [dokuwiki] Global start page patch
- » [dokuwiki] Re: Global start page patch
- » [dokuwiki] Re: Global start page patch
- » [dokuwiki] Re: Global start page patch
- [dokuwiki] Re: Global start page patch
- From: Anika Henke