bwanders / dokuwiki-strata

Strata - a Semi-Structured Data plugin for Dokuwiki
https://www.dokuwiki.org/plugin:strata
17 stars 8 forks source link

References with namespace don't work #43

Closed boqapt closed 7 years ago

boqapt commented 7 years ago

In dokuwiki 2017-02-19e "Frusterick Manners" I've installed sqlite and strata in Extension Manager. Then created 2 pages:

http://localhost/dokuwiki/doku.php?id=xxx:page_in_namespace

<data xxx>
Display Name: Page in namespace
</data>

http://localhost/dokuwiki/doku.php?id=referencing_page&do=edit

[[xxx:Page in namespace]]
<table ?name>
?xxx is a: xxx
?xxx Display name [ref::xxx]: ?name
</table>

In the last page there are 2 links leading to 'Page in namespace'. Here are they as seen in a browser.

  1. http://localhost/dokuwiki/doku.php?id=xxx:page_in_namespace
  2. http://localhost/dokuwiki/doku.php?id=page_in_namespace (link in a strata table)

    First links works, but second actually points to not existing page because it haven't namespace component. I expected it to work because I've specified namespace in hint of ref following strata reference. What am I doing wrong? Can you advise an alternative way for that (namespace TOC) with strata? I know how to use other plugins for that, but need strata because need to add more columns in TOC table.

bwanders commented 7 years ago

Hi there!

To get the second link working, you can use the page reference ?xxx directly as the displayed field. I have adapted your example to do this:

[[xxx:Page in namespace]]
<table ?xxx>
?xxx is a: xxx
?xxx Display name [ref::xxx]: ?name
</table>

Note that the line where the Display name is matched is not actually necessary for this.

The reason this happens is as follows: the type hint on the ref type is only used when converting raw user data to Strata format, because all links stored in strata are stored in qualified format (i.e. ,ns1:ns2:page). The principal reason for this being that qualified links can be used anywhere without needing to know where they originate from.

Does this help you out?

boqapt commented 7 years ago

Hi @bwanders

  1. No, it doesn't help. Page names are not quite readable with no whitespace, punctuation and letter casing. Thank you for help anyway.

  2. I disagree with your explanation but doesn't want to open a debate. I will just notice that it seemingly contradicts to strata reference.

  3. I've solved my problem and achieved what I've wanted by putting the code block below into render function of types\ref.php . If you want, I can create a pull request but I didn't test thoroughly and can't guarantee nothing is broken. Also that patch looks like a blotch on the slender body of your plugin.

    $lnk = ':'.$value;
    if (is_string($hint) && $hint != '' && strncmp($lnk, ':'.$hint, strlen($hint) + 1) !== 0) {
      $lnk = ':'.$hint.$lnk;
    }
    $R->internallink($lnk, $heading);    
bwanders commented 7 years ago

Thanks for the quick feedback!

On 1.: I now understand the specific problem: the links do not display a nice, and clean name. I think that your experience in this isn't a strata-specific problem: it's a DokuWiki one. By default, DokuWiki is configured to display the link text instead of the page title, you can change this with DokuWiki's useheading configuration setting. (Strata respects this setting and will use the display style you select there!)

On 2.: Can you point me to the reference part that is contradictory or unclear (or even better, quote the sentences that are unclear)? That way I can clarify the reference manual.

On 3.: I am glad that that patch fixes the problem for you; though I much prefer to refer people to the DokuWiki documentation on getting beatiful links. (Note: I can understand a specificly different type that does exactly what you propose here, but that would be a type specifically for your use case—which you seem very capable of building!)

Let me know how it goes.

boqapt commented 7 years ago

Hi @bwanders

  1. Thanks for pointing that out.

  2. Here is reference point unclear for me. In "plugin:strata" in the sentence "ref (type hint: namespace) References another piece of data or wiki page, and creates a link. The optional hint is used as namespace for the link." user is not warned that hint will work only under some conditions (as you said "when converting raw user data to Strata format" (?) ).

bwanders commented 7 years ago

I tried to improve the documentation a little, and rewrote it to read:

ref (type hint: namespace) References another piece of data or wiki page, and creates a link. An optional hint can be given to change how links are interepreted when saving them: if present, the hint is used as namespace for the link. If the hint ends with a #, all values will be treated as fragments.

I hope that clears up some of the confusion.

(I'm closing this issue as I feel that the clarification is clear enough; if you disagree, please do not refrain from posting another proposal!)