0

I'm writing a simple extension for Apache Guacamole following the guidance in the manual. I can get most theme elements working correctly except adding custom javascript. According to the manual I should be able to include my javascript file by specifying a relative path to the file in my extension guac-manifest.json file like this:

{

    "guacamoleVersion" : "0.9.12-incubating",

    "name"      : "stuff",
    "namespace" : "stuff-menu-extension",
    "translations" : [
        "translations/en.json"
    ],

    "js": ["myscript.js"],
    "html" : [ "resources/templates/new_template.html" ]

}

Here's a screenshot of the reference in the manual enter image description here

Except when I include any js file it appears that app.js doesn't bundle correctly and give this error and the site does not display at all:

enter image description here

At first I thought it was my js code in the myscript.js file, but to test I removed everything from the file except a comment line

//test

But I get the same error. Is this just a bug or am I messing this up? I then tried it with an empty file, but got the same error. After digging through the code it looks like Guacamole takes all the javascript files specified in an extensions manifest and tries to bundle them into the main app.js file, and I guess this is where I'm messing things up.

Has anyone experienced this? Any idea on the proper way to include custom javascript in a guacamole extension? Ideally, I'd like to eventually include angularjs code to add functionality.

RG5
  • 517
  • 1
  • 5
  • 16

1 Answers1

1

I had the same issue and the error was actually in my pom.xml file. I have copied some existing pom.xml which contained angular-maven-plugin. This plugin requires generated and template directories within the project, which I didn't have (and didn't need in my case). The building of the project was fine, but the plugin produced the same error as yours when loaded into page. Removing angular-maven-plugin solved the issue.

I believe your observation is right, this issue can be caused by packaging. You may also check if the final generated .js file has the same name in pom.xml and in guac-manifest.json.

mnikolic
  • 572
  • 1
  • 5
  • 9
  • I think the main issue for me was that I really needed to edit the existing angular controllers, but I wanted to avoid having to edit the source directly. My angular skills are not the greatest so I'm not sure if it's possible to "extend" an existing controller. Since extension js is really just appended to the end of the app.js I don't know if it's possible. Ultimately I just ended up replacing the existing controllers to get what I wanted. It's not a clean solution IMO. Ideally I'd like to be able to replace or extend the existing angular code with an extension rather than a patch – RG5 Sep 29 '17 at 14:30