Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"local/" in "/site/local/?r=" is missing in sparql query results in resource outside the namespace #52

Open
cfrancois7 opened this issue Feb 10, 2016 · 10 comments
Labels

Comments

@cfrancois7
Copy link

Dear all,

When I use the back to site with an instance outside the namespace my sparql query works fine but the link of the sparql result items are http://localhost/site/r/prefix%my_URI instead of http://localhost/site/local/r/prefix%my_URI.

Do you know where I can fix the code?

EDIT: I use the AKWS templates

@white-gecko
Copy link
Member

“It seems to be very closed problem with the issue # 36 of site.ontowiki” (from AKSW/aksw.org#62)

In general this could be related to the changes made to fix #36 . At least this should point you to the correct places in the code to fix this issue.

local in you example is the siteId, which is some how not added when creating the back to site button. I remember some issues with the correct propagation of the siteId (75f4108, but might be unrelated)

@white-gecko
Copy link
Member

Is the defaultSite correctly configured in your <owroot>/extensions/site.ini resp. <owroot>/extensions/site/doap.n3 (<owroot>/extensions/site/default.ini is not used anymore, it just remains for reference).
The button is created here: https://github.com/AKSW/site.ontowiki/blob/develop/SiteHelper.php#L157 the siteId is read here from the config: https://github.com/AKSW/site.ontowiki/blob/develop/SiteHelper.php#L252 and written to $site['id'] in this line https://github.com/AKSW/site.ontowiki/blob/develop/SiteHelper.php#L264. Maybe this helps you for debugging.

@cfrancois7
Copy link
Author

Thanks for your reply.

Yes, in my doap.n3 the defaultSite is correctly defined:

:defaultSite "local" ;
  :subfolderTypes "types" ;
  doap:release :v1-0 .

Just to be more clear on my problem.

In my case the back to site button works fine. The problem is the dysfunctions with the wrong url web address of my sparql query results obtained with {{query ...}} only when the URI is not in the namespace.

The query displays correctly the items (content and label) but the url web link of these items to reach the web page of these items aren't correct: the local is missing in the address: http://localhost/site/r/prefix%my_URI instead of http://localhost/site/local/r/prefix%my_URI .

Now if I'm on one of this item (of my query result) in ontowiki and use the back to site button the address is correct, no local is missing. The problem is linked to the {{query ...}} command which associates incorrect url web link to the query results.

But I don't find exactly where the url is defined for {{query ...}} results in the code. If I find, I could correct the bug.

@white-gecko
Copy link
Member

{{query …}} is provided by https://github.com/AKSW/site.ontowiki/blob/develop/helpers/Query.php You should check, if $siteId is correctly set in https://github.com/AKSW/site.ontowiki/blob/develop/helpers/Query.php#L50 Maybe there is some problem with getting the correct templateData.

@cfrancois7
Copy link
Author

Thanks for your reply.

I found few clues about the problem.

The problem isn't the $siteId at L50 because in my example the script correctly takes the local/items/li.phtml.
I tried once to modify how the the url is defined in the template file li.phtml and the addess is modified but in wrong way (see below the code):

If we focus my li.phtml modified just for the example (addition of local in the url address):

// prepare vars from the querylist helper
$resourceUri = $this->resourceUri;
[...]
$link = $this->link(array(
        'uri' => "local".$resourceUri, 'text' => $title
    ))
?>
    <li class="<?php echo $oddclass ?>" about="<?php echo $this->curie($resourceUri) ?>">
        <?php echo $link , $hookline ?>
    </li>
[...]

The address is modified but in a wrong way for my problem (in this case base_uri is normally defined by the prefix):
http://localhost/site/?r=localhttp%3A%2F%2Fbase_uri%2Furi
Instead of http://localhost/site/local/r/prefix%uri

And I noticed that http://localhost/site/?r=http%3A%2F%2Fbase_uri%2Furi works. So the $resourceUri in li.phtml should be correct if there is no interpretation from a higher script.

The problem comes from at higher level where the $link from li.phtml is interpreted. The higher level seems to be is Querylist.php if we see the code of Query.php#L69 or Renderx.

@cfrancois7
Copy link
Author

the {{link uri=...}} has the same symptoms. If I use a resource outside from the namespace as uri, the uri is interpreted but the siteId is missing in the address.

e.g.:

  • in ontowiki: {{link uri="http://www.semanticweb.org/my_URI"}}
  • in site.ontowiki, the address of the item defined by {{link ...}} becomes: http://localhost/site/r/prefix%3Amy_URI
  • instead of http://localhost/site/local/r/prefix%3Amy_URI

@white-gecko
Copy link
Member

Just a short question, are you on the current master or develop branch?

@cfrancois7
Copy link
Author

Sorry to spam but I seems I find clues after clues and reach the solution.

Because {{query ...}} and {{link ...}} didn't workl for uri outside from the namespace I search to modify how the url is defined in these two helpers and fine a very interesting line in Link.php at 105 where I add 'siteId' => 'local'):

// generate the link URL from the resource URI
        if ($direct == true) {
            $url = $uri;
        } else {
            $url = $this->view->Url(array('uri' => $uri, 'siteId' => 'local'));
        }

And now the uri in AND/OR outside the namespace works with {{query ...}} and {{link ...}}
This solution is ad hoc and not general one. Do you think is better to modify Link.php by calling siteId in a variable and provide the option in this way as 'siteId' => $siteId or to change Url.php by defining a condition where the uri is or not in the namespace?

@cfrancois7
Copy link
Author

I'm on the develop branch (it's the default one).

@cfrancois7
Copy link
Author

My proposition to change the code:

// get the site Id though template data
$siteId = $this->view->getHelper('Renderx')->templateData['siteId'];
// add the `siteId` to the `url` as option when the `uri` isn't direct and not defined in the namespace
$url = $this->view->Url(array('uri' => $uri, 'siteId' => $siteId));

That works for me.

new code part:

// generate the link URL from the resource URI
        if ($direct == true) {
            $url = $uri;
        } else {
            $siteId = $this->view->getHelper('Renderx')->templateData['siteId'];
            $url = $this->view->Url(array('uri' => $uri, 'siteId' => $siteId));
        }
        $url .= $ext;
        if ($plain === true) {
            return $url;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants