Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > d8544620e4ac7bee48ddb48c85d55709 > files > 308

ikiwiki-3.20190228-1.mga7.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>siterel2pagerel (third party plugin)</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../../style.css" type="text/css" />

<link rel="stylesheet" href="../../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../../index.html">ikiwiki</a>/ 

<a href="../../plugins.html">plugins</a>/ 

<a href="../contrib.html">contrib</a>/ 

</span>
<span class="title">
siterel2pagerel (third party plugin)

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p><span class="infobox">
Plugin: siterel2pagerel<br />
Author: <span class="createlink">PaulWise</span><br />
Included in ikiwiki: no<br />
Enabled by default: no<br />
Included in <a href="../goodstuff.html">goodstuff</a>: no<br />
Currently enabled: no<br />
</span></p>

<p>This is a simple plugin to convert all site-relative links to page-relative
links (converts /foo into ../../../foo or similar). It works as a
postprocessing filter, allowing it to work on mdwn, wiki, html, rst and any
other format that produces html. The code is available here:</p>

<pre><code>#!/usr/bin/perl
# quick HTML siterel2pagerel link hack by Paul Wise
package IkiWiki::Plugin::siterel2pagerel;

use warnings;
use strict;
use IkiWiki 2.00;

sub import {
        hook(type =&gt; "sanitize", id =&gt; "siterel2pagerel", call =&gt; \&amp;siterel2pagerel);
}

sub siterel2pagerel (@) {
        my %params=@_;
        my &#036;baseurl=IkiWiki::baseurl(&#036;params{page});
        my &#036;content=&#036;params{content};
        &#036;content=~s/(&lt;a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"\/([^"]*)"/&#036;1 href="&#036;baseurl&#036;2"/mig;
        &#036;content=~s/(&lt;img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"\/([^"]*)"/&#036;1 src="&#036;baseurl&#036;2"/mig;
        # FIXME: do &lt;script and everything else that can have URLs in it
        return &#036;content;
}

1
</code></pre>

</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">











<div class="pagedate">
Last edited <span class="date">Tue Feb 26 23:01:54 2019</span>
<!-- Created <span class="date">Tue Feb 26 23:01:54 2019</span> -->
</div>

</div>


<!-- from ikiwiki -->
</div>

</div>

</body>
</html>