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

When loading a template url from a custom plugin directory, prefix the relative directory #14717

Merged
merged 7 commits into from Sep 22, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Jul 31, 2019

In #14051 we started supporting multiple plugin paths.

There we already rewrite the path to the JS and CSS assets and load them from a different path. But it looks for some reason that a directive templateUrl is not loaded correctly when the plugin is located in a different path. It's still trying to load the template file eg from $matomoUrl/matomo/plugins/PluginName/angularjs/widgetname/widgetname.html when instead it should be maybe loaded from $matomoUrl/matomo/../extensions/PluginName/angularjs/widgetname/widgetname.html

@tsteur tsteur added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Jul 31, 2019
@tsteur tsteur added this to the 3.12.0 milestone Jul 31, 2019
@tsteur tsteur added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Aug 16, 2019
@nabiltntn
Copy link
Contributor

nabiltntn commented Aug 23, 2019

I am not sure if it's related but I am trying to use custom plugins folder for some of premium plugins like ABTesting, or SessionsRecording,

When Selecting them from the left menu, nothing is displayed in the main content ( no errors in browser's console / network )

Capture d’écran 2019-08-23 à 16 43 48

For ABTesting plugin, the following files are 404, i guess because it's not not taking in account custom folders relative path:

  • $matomohost/plugins/AbTesting/libs/abtestingicons/fonts/abtestingicons.ttf?5qxh2m
  • $matomohost/plugins/AbTesting/libs/abtestingicons/fonts/abtestingicons.woff?5qxh2m

Thanks.

@tsteur
Copy link
Member Author

tsteur commented Aug 23, 2019

Yes it's related to that. Feel free to give the patch a try and let me know if it works 👍

@nabiltntn
Copy link
Contributor

nabiltntn commented Aug 26, 2019

Unfortunately, i am on a Docker environnement right now, so i will wait for the official 3.12.0 image to test if this PR will be included in.

Thanks

var urlParts = config.url.split('/');
if (urlParts && urlParts.length > 2 && urlParts[1]) {
var pluginName = urlParts[1];
if (pluginName && pluginName in piwik.relativePluginWebDirs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pluginName check in the if is redundant here since urlParts[1] is checked above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be safer to check if (piwik.relativePluginWebDirs[pluginName]) instead of pluginName in piwik.relativePluginWebDirs in case the value is falsey?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another check. I think we could remove plugin in ... but had sometimes problems with it in past not sure why.

@diosmosis diosmosis merged commit 6db4698 into 3.x-dev Sep 22, 2019
@diosmosis diosmosis deleted the prefixtemplateDirCustomPluginPath branch September 22, 2019 20:28
@mattab mattab added the c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants