DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:autolink

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
Last revisionBoth sides next revision
tips:autolink [2010-03-26 11:57] 192.54.144.229tips:autolink [2015-01-29 16:46] – [Sample of link page] 84.204.72.82
Line 7: Line 7:
 ===== Usage ===== ===== Usage =====
  
-this script can used to:+this script can be used to:
  
   * automatically add links to a word   * automatically add links to a word
Line 15: Line 15:
  
 <code perl autolink.pl> <code perl autolink.pl>
- #!/usr/bin/perl+#!/usr/bin/perl
  
 sub substi sub substi
Line 81: Line 81:
             if($f =~ /($str)/i)             if($f =~ /($str)/i)
             {             {
-             $f =~  s/([\(\)., :\*{2}\_{2}])($str)([\)\(., :\*{2}\_{2}])/$1\[\[$ns\|$2\]\]$3/gi; +             $f =~  s/([\(\"\)., :\*{2}\_{2}])($str)([\)\(., :\"\*{2}\_{2}])/$1\[\[$ns\|$2\]\]$3/gi; 
-             $f =~  s/^($str)([\)\(., :\*{2}\_{2}])/\[\[$ns\|$1\]\]/gi; +             $f =~  s/^($str)([\)\(., :\"\*{2}\_{2}])/\[\[$ns\|$1\]\]/gi; 
-             $f =~  s/([\(\)., :\*{2}\_{2}])($str)$/\[\[$ns\|$1\]\]/gi;+             $f =~  s/([\(\)., :\"\*{2}\_{2}])($str)$/\[\[$ns\|$1\]\]/gi;
  
 #print $f."<br/>"; #print $f."<br/>";
Line 185: Line 185:
   autolink($ARGV[0],$ARGV[1]);   autolink($ARGV[0],$ARGV[1]);
 } }
 +
 +
  
 +
 +</code>
 +
 +
 +===== Deployment =====
 +
 +  - copy script into your web directory
 +  - create a link page into your wiki (in sample this page is named **autolink** and is on the root page directory)
 +  - cron script each night 
 +  
 +  autolink.pl <link_file> <data_directory>
 +
 + __cron sample :__
 +  
 +   40 0 * * * cd /var/www/html/scripts/ ; perl autolink.pl /var/www/html/wiki/data/pages/autolink.txt /var/www/html/wiki/data/pages
 +
 +===== The link page =====
 +
 +  * **Only line started with '|' char are analysed**. Then you can create Title, table, or adding text into autolink page.
 +  * **no space into table line**, except if you want to match spaces 
 +  * it's **case insensitive matching**, "Toto" or "toto" in the wiki ,no differences
 +  * **autolink.txt pages are ignored**
 +  * for matchin whole wiki directory ':' in table (see sample)\\ \\
 + 
 +__The analysed line format is :__
 +  |<appliance namespace>|<word_to_link>|<link>|
 +
 +
 +==== Sample of link page ====
 +
 +<code>
 +====== Autolink ======
 +
 +== Fruits ==
 +
 +^ appliance namespace  ^ word  ^ link  ^
 +|fruits|apple|fruits:apple|
 +
 +== Instruments ==
 +
 +^ appliance namespace  ^ word  ^ link  ^
 +|instruments:wind|flute|instruments:cord:flute|
 +|instruments:cord|violin|instruments:cord:violin|
 +
 +== All == 
 +
 +^ appliance namespace  ^ word  ^ link  ^
 +|:|instrument|instruments|
 +|:|fruit|fruits|
  
 </code> </code>
Line 193: Line 244:
   * **apple** to **fruits:apple** into namesapce **fruits**   * **apple** to **fruits:apple** into namesapce **fruits**
   * **flute** to **instruments:cord:flute** into **instruments:wind**   * **flute** to **instruments:cord:flute** into **instruments:wind**
-  * ... +  * ... 1
- +
-===== Discussion =====+
  
  
  
tips/autolink.txt · Last modified: 2015-01-29 16:46 by 84.204.72.82

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