dokufreaks / plugin-include

A DokuWiki plugin for including other wiki pages into the current one.
http://www.dokuwiki.org/plugin:include
GNU General Public License v2.0
62 stars 54 forks source link

After Update: Local Links now point to namespace and not to root #278

Closed glreschke closed 1 year ago

glreschke commented 2 years ago

I have a huge problem since the update to the new include plugin: Formerly all links were relative to the root, now they are relative to the namespace. Example:

{{page>ns:start}} Formerly links [[...]] in page ns:start pointed to the main namespace ( = [[:...]] ), now they link to [[ns:...]]. This is a huge difference, which hits my whole wiki structure. Some hundred pages with perhaps about thousand links are now suddenly affected.

In the plugin config there is no possibility to specify a landing namespace (i.e. plugin wst which I also use, but in different cases, offers this option).

I suppose there is no real solution for this, so in the meantime I can only stay with the old plugin version. Or has anybody an idea?

My proposition (but I'm not a PHP programmer): A simple option "Links point to root/base (yes) or are relative to namespace (no)" would be enough. The default should be "yes" to keep the former standard.

michitux commented 2 years ago

There should have been no change. Have you possibly also updated DokuWiki at the same time? Can you specify which version is working and which version is broken? Also, it would be helpful to provide an example link, and what page it used to point to and what page it is now pointing to. In theory, if a link works on page A, it should still point to the same page regardless where that page A is included.

glreschke commented 2 years ago

No, i did not update Dokuwiki. Just after the plugin update (as offered on the "installed plugins" page) the change happened, without me doing something else.

The present (old) version (which I have restored now) is 2021-07-05 (from plugin.info.txt), the version offered as update is 2022-01-23. So the change of the behaviour happened exactly with the update.

On page https://www.uhren-wiki.com/doku.php?id=start&do=edit you find for example this call: {{page>template:start_info&inline}} The contents of the (included) page template:start_info (file = pages/template/start_info.txt) reads like this:

==== Neue Artikel ==== * **30.1.2022** --- [[JLC 410]] • [[JLC 470]] ........ Now, as you see in the present version, [[JLC 410]] points to https://www.uhren-wiki.com/doku.php?id=jlc_410 After the plugin update it points to https://www.uhren-wiki.com/doku.php?id=template:jlc_410 (Cannot be proved now, because I can only have one version running; but you can believe me.)

The same with all other instances of include usages. After the update all local links point to template:xxx instead of xxx.

(For the sake of completeness I have to add that in the config I have template* as regular expression under hidepages. But this has not been a problem.)

michitux commented 2 years ago

If you go to the page template:start_info, all links are broken. As I've said, the include plugin is not supposed to change which page a link is pointing to. Therefore, if the link is broken before the include, it should also be broken afterwards.

DokuWiki interprets the link [[foo]] as relative to the current page. You need to write [[:foo]] to link to the page in the root namespace. This is not related to the include plugin but standard DokuWiki behavior. I do not know why this worked in the old version of the include plugin.

What might help you is an option in the include plugin to interpret relative links as relative to the including page. While the include plugin could also change relative links to be relative to the root namespace, I do not see why it should do that as relative links should be relative and not absolute.

glreschke commented 2 years ago

I have found it (helper.php):

case 'internallink': // ### Re: lokale Links immer auf Basis-Namespace umleiten { $link = $ins[$i][1][0]; //echo $ns . '
' . $link .'
'; $p = strpos($link,':'); //$p2 = strpos($link,'template'); if ($p!==0 and $ns=='template') { $ins[$i][1][0] = ':' . $link; } //echo '((';
}

has disappeared in the new version.

glreschke commented 2 years ago

I had posted the above at the same time as your answer. It seems to be a peculiar coincidence that someone [[[Perhaps it was me and I did it myself in my file; I really don't remember....]]] had coded this condition with exactly this namespace name "template" which I use, so that the former plugin version behaved (ok.) like I described.

What might help you is an option in the include plugin to interpret relative links as relative to the including page.

This is exactly what I meant. It would be perfect if the above erased code would be changed, not questioning the namespace name but simply testing such a config option of the plugin.


There is no urgency. I have solved this case by programming a conversion software which changes "[[" to "[[:" in all these files (see https://www.uhren-wiki.com/doku.php?id=template:start_info). It changed all the files (520 x 2) in seconds. It was simpler than I thought.

The idea with the said option would be helpful, but I'm not under pressure any more.

Thank you for your assistance!

Michaelsy commented 2 years ago

I have found it (helper.php): [...] has disappeared in the new version.

The code you provide here is obviously a non-update-safe modification of yours that has been overwritten by the update to the new version.

- Michael Sy.

glreschke commented 2 years ago

Yes. Sorry, I could not remember.