DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:goto:old_discussion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
plugin:goto:old_discussion [2019-03-15 23:55]
turnermm [Updated Version]
plugin:goto:old_discussion [2019-03-16 00:48] (current)
turnermm
Line 1: Line 1:
-===== Installation ===== 
  
-Search and install the plugin using the [[plugin:​extension|Extension Manager]]. Refer to [[:​Plugins]] on how to install plugins manually.+===== Discussion =====
  
-===== Requirements =====+Right now this plugin can only redirect to internal wiki pages. I'd like it to be able to redirect to external pages, but I'm a little hazy on how DokuWiki processes URLs. Any help is appreciated. ​ --- //​[[aormond@gmail.com|Allen Ormond]] 2006-06-30 22:35//
  
-This plugin requires ​the user to have JavaScript enabled ​in order to work to its fullestHowever, a redirect ​link will still be displayed even without JavaScript+I don't see the point of a page with a ~~GOTO~~ and then some additional content. I'd suggest that if a page contains only an internal link, make an HTTP-header (HTTP 301 response code) redirection and then show a "​Redirected from ..." ​in the destination page. I'm not that convinced on the subject of automatic external redirection. --- //​[[atnbueno@mundoplus.tv|Antonio Bueno]] 2006-07-28 13:25// 
 +>I agree, that does sound nice. However, there are a couple reasons I didn't use an http header redirection. As far as I know, it's impossible ​to make a simple syntax plugin ​to do it (or at least it's beyond my abilities)Alsoif the page redirects without being seen, it would become difficult for user to remove the redirect. Of course, I'd love to see a more elegant solution, but this is working for me for now. ^_^ --- //​[[aormond@gmail.com|Allen Ormond]] 2006-07-29 01:16// 
 +>>How about a parameter that disables the redirect, e.g. redirect=no?​ 
 +>>>​I set min and default to 0, and use the ?do=edit to stop the redirect. Granted that's not going to work for all users..
  
-The ''​pause''​ before ​redirect is controlled by configuration options for the default pause length ( ''​seconds''​ ) and the minimum pause length allowed ( ''​minSeconds''​ ). See [[#​pause_length]] below.+Sorry, but this Plugin is Crap. Why did you not use the all Wiki Standardcode like : 
  
 +#redirect [[Articlename]] ​
  
-===== Syntax =====+??
  
-You can put the GOTO string anywhere in the document, but it probably makes the most sense to put it at the top.+The code you use is to complex and nobody can remember this.
  
-  ~~GOTO>​wiki:​syntax~~ 
  
-The above will force the document ​to redirect to the [[:​wiki:​syntax]] page after the default amount of seconds. You can change the default number of seconds by editing the plugin (by default, this is 10 seconds).+> You're welcome ​to do better
  
-It is possible ​to link to a subheading of the page: +> If there actually existed something like an "all Wiki Standardcode",​ we would all be happy to implement and use it. But there is no such thing! 
-  ​~~GOTO>wiki:syntax#​subheading~~+>> Ever head of [[http://​www.wikicreole.org/​ |Wiki Creole]]? --Fabian
  
-You can change ​the number of seconds on the fly like so: +>>You have to now "#​redirect"​ in the same way like you have to now "~~GOTO~~". 
-  ​~~GOTO>​wiki:​syntax?​15~~+>>Use "​\inc\lang\en\edit.txt"​ to advice the users if necessary. 
 +>>The only thing is, that such a basic function should by part of the basecode.
  
-This will redirect ​the page after a 15 second pause.+---- 
 +$seconds and $minSeconds could by inserted in to the admin-configuration.
  
-=== Pause length ===+----
  
-By default, users can't set the pause length ​to be faster than two secondsThe reason for the minimum pause length is that if it's too fast, it becomes difficult to hit the 'Edit Page' button before the redirect happensIf you can't edit the page, then it becomes tricky ​to remove the redirect.+Note that the download links (to yeahway.com) are **broken** as of 2013-07-11. I'm not touching them as I don't know what policy is. 
 +---- 
 +  
 +==== Why not allow to redirect ​to external sites? ====
  
-===== Revision History =====+Specifying an URL like ''​http://​www.example.com/​path/''​ doesn'​t do what expected. 
 +Is it a bug or a feature? 
 + --- [[user>​jno|jno]] //​2011/​07/​08 12:27//
  
-  * 2006-06-30 --- Released. +==== Why not using HTTP redirects? ====
-  * 2006-07-19 --- Made it easier to customize the displayed redirect message. +
-  * 2016-10-02 --- Moved to GitHub, added compability for PHP 7, added redirection to headlines, integration of language files, integration of configuration manager for settings, avoid redirection while editing+
  
 +If you add 
  
-===== Issues =====+  ob_start();​ 
 +  ob_implicit_flush(FALSE);​
  
-  * The viewer's web browser must have JavaScript enabled in order to automatically redirect. +to ''​doku.php''​ it would be possible ​to do HTTP redirects by using ''​header('​Location: ​...'​);''​ , which would have some advantages:
-  * Currently, the plugin only works correctly for internal links.+
  
-===== Updated Version ===== +  - No need to enable JavaScript 
-There is an updated version of ''​GOTO''​ which has not yet been integrated into the main distribution. It has a feature which had been asked for an several occasionsthe ability to redirect to external sites. ​ It also contains an entirely new feature, which is the ability to automatically redirect to user pages on login. ​   ​+  - No extra clicks ​for visitorsif they disabled JavaScript
  
-For documentation ​and downloadsee the ''​GOTO''​ [[plugin:goto:supplement]]+The issue "​editing a page may be tricky"​ is not right - you can always enter "​pagename?​do=edit"​ manually in the browser - so what's the point? 
 + 
 +=== User stupidity === 
 + 
 +Simple - You can't rely on the fact that all users will be able to know how to use the address bar correctly. If you can't access it through visual scanning ​and mouse clicksassume 80% of the population will be unable to utilize the feature. 
 +==== Languages ==== 
 + 
 +<​code>​ 
 +Change 
 + 
 +$message = "<​strong>​You will be redirected to %d in approximately %s seconds.</​strong>";​ 
 + 
 +to  
 + 
 +$message = "<​strong>"​.$this->​getLang('redirect')."</​strong>";​  
 +</​code>​ 
 + 
 + 
 +and 
 + 
 +Input this in the Path "​lang"​ 
 + 
 + 
 +== en == 
 +<code php> 
 +<?php 
 +/* 
 +English language file 
 + 
 +%d will be replaced with a link to the destination. 
 +%s will be replaced with the number of seconds before redirect. 
 + */ 
 +$lang['redirect']="You will be redirected to %d in approximately %s seconds.";​ 
 +//Setup VIM: ex: et ts=2 enc=utf-8 : 
 +?> 
 +</​code>​ 
 + 
 + 
 +== de == 
 +<code php> 
 +<?php 
 +/* 
 +German language file 
 + 
 +%d will be replaced with a link to the destination. 
 +%s will be replaced with the number of seconds before redirect. 
 + */ 
 +$lang['​redirect'​]="​Diese Seite wird in ungef&​auml;​hr %s Sekunden umgeleitet zu: %d"; 
 +//Setup VIM: ex: et ts=2 enc=utf-8 : 
 +?> 
 +</​code>​ 
 + 
 +== fr == 
 +<code php> 
 +<?php 
 +/* 
 +french language file 
 + 
 +%d will be replaced with a link to the destination. 
 +%s will be replaced with the number of seconds before redirect. 
 + */ 
 +$lang['​redirect'​]="​Vous allez être redirigé vers la page %d dans approximativement %s secondes";​ 
 +//Setup VIM: ex: et ts=2 enc=utf-8 : 
 +?> 
 +</​code>​ 
 + 
 +== es == 
 +<code php> 
 +<?php 
 +/* 
 +Spanish language file 
 + 
 +%d will be replaced with a link to the destination. 
 +%s will be replaced with the number of seconds before redirect. 
 + */ 
 +$lang['​redirect'​]="​Serás redireccionado a la pagina %d en %s segundos aprox.";​ 
 +//Setup VIM: ex: et ts=2 enc=utf-8 : 
 +?> 
 +</​code>​ 
 + 
 +==== Great ==== 
 +Great, this plugin ​made my day. Only issue is that I cannot remember the syntax, #REDIRECT would have been better. 
 + 
 +==== Support for Anchors ==== 
 +The # character is replaced by %23 in the URL, so I've made the following modification to the render function. ​ This allows the plugin to redirect to a particular section of a page. 
 + 
 + function render($format,​ &​$renderer,​ $data) { 
 + $message = str_replace("​%d",​$renderer->​internallink($data[0],​ $data[0],'',​ true),​$data[2]);​ 
 + $message = str_replace("​%s",​$data[1],​$message);​ 
 + $renderer->​doc .= $message; 
 + $urlArr = split('#',​ $data[0], 2); 
 + $url = wl($urlArr[0]);​ 
 + if (count($urlArr) > 1) { 
 + $url .= '#'​.$urlArr[1];​ 
 +
 + $renderer->​doc .= '<​script>​url="'​.$url.'";​setTimeout("​location.href=url",'​.($data[1]*1000).'​);</​script>';​ 
 +
 + 
 +==== Support for external pages ==== 
 + 
 +Minor modifications which allow: 
 +  - external pages to be referenced. 
 +  - doesn'​t output the javacode when looking at page preview. 
 + 
 +<​code>​ 
 +--- ./​syntax.php ​     2006-07-19 14:33:​18.000000000 -0400 
 ++++ ./​syntax.php ​       2010-09-27 14:​19:​29.000000000 -0400 
 +@@ -48,18 +48,29 @@ 
 +                                $matches = explode("?",​ substr($match,​7,​-2));​ 
 +                                if (is_numeric($matches[1])){ $seconds = $matches[1]; } 
 +                                if ($seconds < $minSeconds){ $seconds = $minSeconds;​ }//Check that seconds is greater than $minSeconds. 
 +-                               ​resolve_pageid(getNS($ID),​ $matches[0],​ $exists); 
 ++                               if (substr($matches[0],​0,​7) == "​http://"​) 
 ++                                       ​resolve_pageid(getNS($ID),​ $matches[0],​ $exists); 
 +                                $message = str_replace("​%D","​%d",​$message);//​Make %d case insensitive. 
 +                                $message = str_replace("​%S","​%s",​$message);//​Make %s case insensitive. 
 +                                return array($matches[0],​ $seconds, $message);​ 
 +                        } 
 + 
 +                        function render($format,​ &​$renderer,​ $data) { 
 +-                               ​$message = str_replace("​%d",​$renderer->​internallink($data[0],​ $data[0],'',​ true),​$data[2]);​ 
 +-                               ​$message = str_replace("​%s",​$data[1],​$message);​ 
 +-                               ​$renderer->​doc .= $message; 
 +-                               ​$renderer->​doc .= '<​script>​url="'​.wl($data[0]).'";​setTimeout("​location.href=url",'​.($data[1]*1000).'​);</​script>';​ 
 ++                                global $ACT; 
 ++                               if (substr($data[0],​0,​7) == "​http://"​) { 
 ++                                       ​$message = str_replace("​%d",​$renderer->​internallink($data[0],​ $data[0],'',​ true),​$data[2]);​ 
 ++                                       ​$message = str_replace("​%s",​$data[1],​$message);​ 
 ++                                       ​$renderer->​doc .= $message; 
 ++                                       if ($ACT != '​preview'​) 
 ++                                               ​$renderer->​doc .= '<​script>​url="'​.wl($data[0]).'";​setTimeout("​location.href=url",'​.($data[1]*1000).'​);</​script>';​ 
 ++                               } else { 
 ++                                       ​$message = str_replace("​%d",​ "<a href=\""​.$data[0]."​\">"​.$data[0]."</​a>",​$data[2]);​ 
 ++                                       ​$message = str_replace("​%s",​ $data[1],​$message);​ 
 ++                                       ​$renderer->​doc .= $message; 
 ++                                       if ($ACT != '​preview'​) 
 ++                                               ​$renderer->​doc .= '<​script>​url="'​.$data[0].'";​setTimeout("​location.href=url",'​.($data[1]*1000).'​);</​script>';​ 
 ++                               } 
 +                        } 
 + 
 +                } 
 +</​code>​
plugin/goto/old_discussion.txt · Last modified: 2019-03-16 00:48 by turnermm