From 9781783a04d2fed9de59af9ff46ba209a0c3dc1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 25 Feb 2008 17:10:01 +0000 Subject: [PATCH] - handle redirect links Changed files: dokuwiki-plugin-pagemove-redirectlinks.patch -> 1.1 dokuwiki-plugin-pagemove.spec -> 1.4 --- dokuwiki-plugin-pagemove-redirectlinks.patch | 55 ++++++++++++++++++++ dokuwiki-plugin-pagemove.spec | 5 +- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 dokuwiki-plugin-pagemove-redirectlinks.patch diff --git a/dokuwiki-plugin-pagemove-redirectlinks.patch b/dokuwiki-plugin-pagemove-redirectlinks.patch new file mode 100644 index 0000000..cfbca92 --- /dev/null +++ b/dokuwiki-plugin-pagemove-redirectlinks.patch @@ -0,0 +1,55 @@ +--- pagemove/admin.php 2008-02-25 19:02:48.062065053 +0200 ++++ pagemove/admin.php 2008-02-25 19:01:41.271159305 +0200 +@@ -411,7 +411,8 @@ + function _pm_updatelinks(&$text, $links) + { + foreach( $links as $old => $new ) { +- $text = preg_replace( '#\[\[' . $old . '((\]\])|[\|\#])#i', '[[' . $new . '\1', $text); ++ $text = preg_replace( '#\[\[' . $old . '(\]\]|[\|\#])#i', '[[' . $new . '\1', $text); ++ $text = preg_replace( '#~~REDIRECT>' . $old . '(~~|[\|\#])#i', '~~REDIRECT>' . $new . '\1', $text); + } + } + +@@ -440,7 +441,14 @@ + //match all links + //FIXME may be incorrect because of code blocks + // CamelCase isn't supported, too +- preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER); ++ $matches = array(); ++ if (preg_match_all('#\[\[(.+?)\]\]#s',$text,$m,PREG_SET_ORDER)) { ++ $matches = array_merge($matches, $m); ++ } ++ if (preg_match_all('#~~REDIRECT>(.+?)~~#s',$text,$m,PREG_SET_ORDER)) { ++ $matches = array_merge($matches, $m); ++ } ++ + foreach($matches as $match){ + //get ID from link and discard most non wikilinks + list($mid) = split('[\|#]',$match[1],2); +@@ -572,9 +580,9 @@ + */ + function _pm_search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories +- if($type == 'd') return true;; ++ if($type == 'd') return true; + //only search txt files +- if(!preg_match('#\.txt$#',$file)) return true;; ++ if(!preg_match('#\.txt$#',$file)) return true; + + //get text + $text = io_readfile($base.'/'.$file); +@@ -589,7 +597,13 @@ + //match all links + //FIXME may be incorrect because of code blocks + // CamelCase isn't supported, too +- preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER); ++ $matches = array(); ++ if (preg_match_all('#\[\[(.+?)\]\]#s',$text,$m,PREG_SET_ORDER)) { ++ $matches = array_merge($matches, $m); ++ } ++ if (preg_match_all('#~~REDIRECT>(.+?)~~#s',$text,$m,PREG_SET_ORDER)) { ++ $matches = array_merge($matches, $m); ++ } + foreach($matches as $match){ + //get ID from link and discard most non wikilinks + list($mid) = split('[\|#]',$match[1],2); diff --git a/dokuwiki-plugin-pagemove.spec b/dokuwiki-plugin-pagemove.spec index 7c0ac87..3fcd5ac 100644 --- a/dokuwiki-plugin-pagemove.spec +++ b/dokuwiki-plugin-pagemove.spec @@ -3,11 +3,12 @@ Summary: DokuWiki PageMove plugin Summary(pl.UTF-8): Wtyczka PageMove dla DokuWiki Name: dokuwiki-plugin-%{_plugin} Version: 0.9.15a -Release: 0.1 +Release: 0.2 License: GPL v2 Group: Applications/WWW Source0: http://www.isection.co.uk/lib/exe/fetch.php?media=pagemove_20070722.zip # Source0-md5: f2cc2a57d40b877a335b52009e4cc072 +Patch0: %{name}-redirectlinks.patch URL: http://www.isection.co.uk/doku.php BuildRequires: sed >= 4.0 Requires: dokuwiki >= 20060309 @@ -39,10 +40,10 @@ W zupełności można: %prep %setup -q -n %{_plugin} - # undos the source %{__sed} -i -e 's,\r$,,' admin.php +%patch0 -p1 mv lang/cs/pagemove.txt{.txt,} mv lang/es/pagemove.txt{.txt,} mv lang/pl/pagemove.txt{.txt,} -- 2.43.0