[dokuwiki] Re: Namespace linking from URL (fix for #991)

On 26 March at 20:18, Andreas Gohr wrote:

> Hmm, I just thought about this again. Shouldn't we do a redirect to the
> correct page here, instead of displaying the same content under two
> different URLs?
> 
> Calling doku.php?id=ns: should redirect me to doku.php?id=ns:start (or
> to whatever it resolves). This makes sure the user bookmarks the
> correct page and search engines are happier with canonical URLs as well.

  OK, I've added that point to the attached patch.

-- 
  bug
New patches:

[Namespace autolinking from URL (FS#991 fix)
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070330212802
 
 You can now request doku.php?id=ns: or doku.php?id=ns/ if you have the
 useslash option activated and have DokuWiki return the $conf['start']
 page from that namespace. See issue #991.
 
] {
hunk ./inc/pageutils.php 55
+
+  // Namespace autolinking from URL
+  if(substr($id,-1) == ':' || ($conf['useslash'] && substr($id,-1) == '/')){
+    if(@file_exists(wikiFN($id.$conf['start']))){
+      // start page inside namespace
+      $id = $id.$conf['start'];
+    }elseif(@file_exists(wikiFN($id.noNS(cleanID($id))))){
+      // page named like the NS inside the NS
+      $id = $id.noNS(cleanID($id));
+    }elseif(@file_exists(wikiFN($id))){
+      // page like namespace exists
+      $id = $id;
+    }else{
+      // fall back to default
+      $id = $id.$conf['start'];
+    }
+    header("Location: ".wl($id,'',true));
+  }
+
}

Context:

[some test cleanups
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070326185533] 
[set scope for session cookies FS#1109
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070326180948] 
[Escape Ctrl-Z so darcs stops treating utf8.php as binary.
Tom N Harris <tnharris@xxxxxxxxxxxxx>**20070323030243] 
[Typo in plugin.php (FS#1094)
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070323075309] 
[fix for the new SimplePie
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070312203419
 SimplePie changed the method to fetch the feed, this patch restores the usage
 of DokuWiki's own HTTP client.
] 
[SimplePie update
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070311215020] 
[always have a trailing newline in JavaScript output
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070308224331
 This may fix https://bugzilla.mozilla.org/show_bug.cgi?id=316033
] 
[js_compress updates
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070308223644
 This ports the fixes from the original python code to DokuWiki's js_compress
 functions. The unit tests now pass.
] 
[Latvian language updates
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070307211110] 
[FS#1011-fix
bernd@xxxxxxx**20070306005940] 
[dbg_backtrace() function added
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070305223458
 This adds a useful debugging function for printing function call backtraces.
] 
[added JsStrip unit test files
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070305223025
 
 This patch adds unit test files from the new release of JsStrip [1]. Some of 
the tests
 currently fail pointing to bugs which are fixed in the new JsStrip release. 
The fixes
 need to be ported to DokuWiki's js_compress function.
 
 This patch also adds a way to output additional info when a test fails. It 
misuses
 SimpleTest's signalling which is probably a bad idea but works for now.
 
 
 http://code.google.com/p/jsstrip/
 
] 
[Several small french language corrections
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070305165211] 
[French lang for revert plugin
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070305163850] 
[French language update
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070305140920] 
[unit test for auth_aclcheck
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303225338] 
[fixed warning whith no search results FS#1088
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303220143] 
[added getFormat() function to renderer
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303214102
 Each renderer has to supply a getFormat() function returning the format it
 produces. Usually this is the same as the classname of the renderer (or Plugin)
 says but it does not need to be necessarily.
 
 Fixes a problem with the wrong format being reported to plugins when a
 render plugin was used.
] 
[never build instructions twice in the same run FS#1090
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303202232
 When a page was called with purge=1 the instructions were built multiple
 times for the multiple renderers. This is not only an unnessary ressource hog
 it could also make certain plugins fail which. This patch makes sure that
 instructions for a source file are not built more than once per run.
] 
[only debug when in xhtml mode in parserutils.php
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303195008] 
[improved writability check for sitemap FS#1093
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070303192836] 
[bulgarian translation
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070302180103] 
[skip images in links for metadata renderer
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070302102035] 
[Fix broken if in previous patch
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070302100506] 
[Allow @USER@ variable in ACLs
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20070301230309
 
 This saves a lot of ACL lines for users namespaces for example:
 
 users:*               @ALL        1
 users:@USER@          @USER@      8
 
] 
[fix pass by reference problem in indexer.php
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070301211751] 
[TAG develsnap 2007-03-01
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20070301000001] 
Patch bundle hash:
ffc92049d1f9520e57560ef611ddd5f94a3c27b3

Other related posts: