DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:goto

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:goto [2015-04-04 06:24] – Remove bad download link PatrickBrownplugin:goto [2023-10-30 23:58] (current) Klap-in
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Easily have a page redirect to another page in the wiki +description: Easily have a page redirect to another page in the wiki 
-author     : Allen Ormond +author     : Allen Ormond, cziehr, turnermm, 
-email      : 2006-07-19+email      : turnermm02[at]shaw[dot]ca
 type       : syntax type       : syntax
-lastupdate : 2006-07-19 +lastupdate : 2021-03-01 
-compatible : 2006-11-06Angua+compatible : Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Elenor of Tsort, Frusterick Manners, GreeboHogfather
 depends    :  depends    : 
 conflicts  conflicts 
 similar    : 404manager, pageredirect similar    : 404manager, pageredirect
 tags       : redirect tags       : redirect
 +
 +downloadurl: https://github.com/cziehr/goto/zipball/master
 +bugtracker : https://github.com/cziehr/goto/issues
 +sourcerepo : https://github.com/cziehr/goto/
  
 ---- ----
 +This plugin redirects the current page to another page after a stipulated number of seconds. It requires the user to have JavaScript enabled in order to work to its fullest. However, a redirect link will still be displayed even without JavaScript.
 +===== Installation =====
  
-This [[plugins|plugin]] requires the user to have JavaScript enabled in order to work to its fullestHoweverredirect link will still be displayed even without JavaScript.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. 
 + 
 +The default pause time before the redirect, and the minimum allowable pause time can be set in the configuration manager.   See [[#pause_before_redirect|below]] for further details
  
 ===== Syntax ===== ===== Syntax =====
 +
 You can put the GOTO string anywhere in the document, but it probably makes the most sense to put it at the top. You can put the GOTO string anywhere in the document, but it probably makes the most sense to put it at the top.
 +
   ~~GOTO>wiki:syntax~~   ~~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 can change the number of seconds on the fly like so: +The above will force the document to redirect to the [[:wiki:syntax]] page after the default number of seconds. It comes set at three seconds. You can change the default number of seconds in the Configuration Manager.
-  ~~GOTO>wiki:syntax?15~~ +
-This will redirect the page after a 15 second pause.+
  
-By default, users can't set the pause length to be faster than three seconds, but this can be changed by editing the plugin. The 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 happens. If you can't edit the page, then it becomes tricky to remove the redirect. +It is possible to link to a subheading of the page: 
- +  ~~GOTO>wiki:syntax#subheading~~ 
-===== Issues ===== +=== Pause before redirect ===
-  *When editing page with the ''GOTO'' tag, be careful of hitting the 'Preview' button. The preview **will** redirect just the same as the saved page. +
-  *The viewer's web browser must have JavaScript enabled in order to automatically redirect. +
-  *Currently, the plugin only works correctly for internal links. +
- +
-===== Installation ===== +
- +
-Download a zip [[http://yeahway.com/stuff/plugingoto.zip|here]], unzip and put the ''goto'' folder in your ''lib/plugins'' directory. +
- +
-If you want to modify the default pause length and the minimum pause length, edit the following lines in ''syntax.php'': +
-  $seconds    10;     //Default number of seconds to wait before redirect. +
-  $minSeconds 3;      //Minimum number of seconds allowed before redirect+
- +
-You can change the redirect message that is displayed by editing the following line in syntax.php: +
-  $message "<strong>You will be redirected to %d in approximately %s seconds.</strong>"; +
-''%d'' will be replaced with a link to the destination.\\ +
-''%s'' will be replaced with the number of seconds before redirection. +
- +
-===== syntax.php ===== +
-<code php syntax.php> +
-<?php +
-/** +
-* GOTO Plugin: Easily redirect to other pages in your wiki. +
-*  +
-* @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
-* @author     Allen Ormond <aormond atgmaildotcom>   +
-*/+
    
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +You can change the number of seconds before the redirect like so
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +  ~~GOTO>wiki:syntax?15~~
-require_once(DOKU_PLUGIN.'syntax.php'); +
-  +
-class  syntax_plugin_goto extends DokuWiki_Syntax_Plugin { +
-  +
- function getInfo(){ +
- return array( +
- 'author' => 'Allen Ormond', +
- 'email'  => 'aormond atgmaildotcom', +
- 'date'   => '2006-07-19', +
- 'name'   => 'GOTO', +
- 'desc'   => 'Easily redirect to other pages in your wiki.', +
- 'url'    => 'http://www.dokuwiki.org/plugin:goto', +
- ); +
-+
-  +
- function getType(){ +
- return('substition'); +
-+
-  +
- function connectTo($mode) { +
- $this->Lexer->addSpecialPattern('(?i)~~GOTO>.+?~~',$mode,'plugin_goto'); +
-+
-  +
- function getSort() { +
- return 249; +
-+
-  +
- function handle($match, $state, $pos, &$handler){ +
-  +
- $seconds = 10;        //Default number of seconds to wait before redirect. +
- $minSeconds = 3;      //Minimum number of seconds allowed before redirect. +
-  +
- /* $message is the redirection message that is displayed. %d will be replaced with a link +
- *  to the destination. %s will be replaced with the number of seconds before redirect. */ +
- $message = "<strong>You will be redirected to %d in approximately %s seconds.</strong>"; +
-  +
- global $ID; +
- $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); +
- $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>'; +
-+
-  +
-+
- //Setup VIM: ex: et ts=4 enc=utf-8 : +
-</code>+
  
-===== Revision History ===== +This will redirect the page after a 15 second pause.
-  * 2006-06-30 --- Released.\\ +
-  * 2006-07-19 --- Made it easier to customize the displayed redirect message.+
  
 +By default, users can't set the pause length to be faster than two seconds, but this can be changed in the Configuration Manager by setting a new value for the ''minSeconds'' option. The 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 happens. If you can't edit the page, then it becomes tricky to remove the redirect. 
  
  
Line 124: Line 48:
  
  
 +===== Updated Version =====
 +The ''goto'' plugin includes updates as described below. \\
 + --- [[user>turnermm|Myron Turner]] //2019-04-05 22:48//
 +==== Auto Login ====
 +Auto login enables registered users, on logging into the wiki, to be automatically redirected to their own user page.The page will be created if it does not already exist. There are two ways to implement the auto login feature. 
 +==== 1. Embedded GOTO Syntax ====
 +The first applies only to the current user.  It uses the GOTO syntax with the ''user'' wildcard in place of the page id:
 +    ~~GOTO>user~~ 
 +This must be placed on the wiki's main page, so that when the user logs in, the page displayed in the browser is the page with this markup. No message is printed to the screen. and the user is  redirected to the user page in the root namespace. If the userid is "foo", the user page will be ":foo". This does not take a time setting: ''?tm'' The redirection occurs after a 3 second delay on login. 
  
 +==== 2. Configured Background Process ====
 +Unlike **1** this method requires no additional plugin markup and does not require that the browser lands on any particular page. On login, the auto login feature redirects the user to the user's page or start page.  This page and its namespace are based on the settings in either the ''auto_options'' setting or the ''group_options'' setting.  For this to work, the ''auto_login'' option must be set to true.  The redirection occurs immediately, without a delay.
  
-===== Discussion ===== +The redirects are governed by the ''auto_options'' and ''group_options'' settings. The ''auto_options'' redirect to pages and namespaces based on the userid.  The ''group_options'' redirect to pages located in namespaces based on group membership.  
-Right now this plugin can only redirect to internal wiki pagesI'd like it to be able to redirect to external pages, but I'little hazy on how DokuWiki processes URLsAny help is appreciated.  --- //[[aormond@gmail.com|Allen Ormond]] 2006-06-30 22:35//+==== Configuration ==== 
 +^Option^Description^Default^ 
 +|seconds|Time till redirection (seconds)| 3| 
 +|minSeconds|Minimum time allowed till redirection (seconds) | 2| 
 +|auto_login|On login, automatically go to predefined page, as set in ''auto_options'' or ''group_options''|false | 
 +|auto_options|Target for the auto_login page based on ''userid'' (See [[#auto_options]])|:user_page | 
 +|common_ns((i.e. ''common namespace'', so named because it is common to all users.))|Used with ''auto_options''. Arbitrarily defined namespace of any depth where the auto login pages will reside. This can include the wildcard ''user_ns'', in which case the user will have namespace in the common namespace directory. | | 
 +|group|Comma separated list of  group namespaces to which users can be redirected. Different users can be in different groups.  If a user belongs to two groups on this list,  the user will be redirected to the first.| | 
 +|group_options|The user can be redirected either to the group start page or to the user's own page in the group namespace.  The options are ''start_page'' and ''user_page''|start_page| 
 +|only_option|The options are ''group'' and ''user''. ''group'' restricts redirects only to group namespaces and their pages; ''user'' only to user namespaces and pages; and ''default'' to either, with group having precedence.|default|
  
-I don't see the point of a page with a ~~GOTO~~ and then some additional contentI'd suggest that if a page contains only an internal linkmake 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// +==== Auto_Options ==== 
->I agree, that does sound niceHowever, 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). Also, if the page redirects without being seen, it would become difficult for a user to remove the redirect. Of courseI'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// +There four options available for defining the user page and namespace to which the auto login will be directed In each case ''user'' stands for the userid and ''ns'for namespace. If the userid is "foo", then the first option would give you ":foo" in the root namespace, the second option ":foo:foo" The start page is one of DokuWiki's ''basic'' configurations and defaults to ''start''. The fourth option requires that the GOTO common namespace (''common_ns''option be set These are the four possibilities for defining the auto login pagewhere "foo" is the userid: 
->>How about a parameter that disables the redirect, e.g. redirect=no? +  :user_page \\ :foo   
->>>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..+  :user_ns:user_page \\ :foo:foo 
 +  :user_ns:start_page \\ foo:start 
 +  - :common_ns:user_page \\ <common_ns>:foo ((See [[#configuration]]))
  
-Sorry, but this Plugin is a Crap. Why did you not use the all Wiki Standardcode like +==== Group Options ==== 
 +Therre are two possibilities for defining the auto login page based on group membership.  In each case the group name is the name of the namespace so that both options locate the redirect page in namespace which is the same as the group name:  
 +  - start_page \\ group-name:start 
 +  - user_page  \\  group-name:userid
  
-#redirect [[Articlename]]  
  
-?? 
  
-The code you use is to complex and nobody can remember this. 
  
 +==== External Links ====
 +External links now supported. The following:
 +   ~~GOTO>https://mturner.org/devel/doku.php?id=wiki:welcome~~
 +will redirect to wiki:welcome at mturner.org.  The on-page notification will read: \\
 +**%%You will be redirected to https://mturner.org/devel/doku.php?id=wiki:welcome in approximately 3 seconds.%%** 
  
-> You're welcome to do better.  
  
-> 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! +===== Revision History ===== 
->> Ever head of [[http://www.wikicreole.org/ |Wiki Creole]]? --Fabian +{{rss>https://github.com/cziehr/goto/commits/master.atom date count=25}} 
- +===== Old Discussion ===== 
->>You have to now "#redirect" in the same way like you have to now "~~GOTO~~"+To review old issues and discussion: [[plugin:goto:old_discussion]]
->>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. +
- +
----- +
-$seconds and $minSeconds could by inserted in to the admin-configuration. +
- +
----- +
- +
-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? ==== +
- +
-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// +
- +
-==== Why not using HTTP redirects? ==== +
- +
-If you add  +
- +
-  ob_start(); +
-  ob_implicit_flush(FALSE); +
- +
-to ''doku.php'' it would be possible to do HTTP redirects by using ''header('Location: ...');'' , which would have some advantages: +
- +
-  - No need to enable JavaScript +
-  - No extra clicks for visitors, if they disabled JavaScript +
- +
-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 clicks, assume 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 VIMex: 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.1428121483.txt.gz · Last modified: 2015-04-04 06:24 by PatrickBrown

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki