2

Hi,

I'm in the process of adding a new functionality to my plugin which requires displaying custom HTML/Javascript inside Wiki pages.

It is a GWT project and I have all the files generated by GWT inside a subfolder inside static directory. The entry point is a javascript file which processes some parameters and then calls another .html file to display my content. For this to work, the initial JS file should be able to access the other files in its folder (using relative path), like in a normal web server environment. (I have done the exact same thing on a plugin for another Wiki platform. Also, when I host and serve the GWT files on my own web server and change the URLs inside the Fogbugz plugin to refer location of my hosted files, it displays fine inside Fogbugz Wiki pages).

I have read the documentation on IPluginStaticJS interface and am in the process of implementing it but without success so far. I'm actually confused by its usage and would be grateful if additional info could be provided for following questions:

  1. Is it possible to include non .js files inside public string[] StaticJSFiles() method? If I specify all files inside my static folder/subfolders here, would the js files be able to access other files using relative path?

  2. How exactly do I access the files once they are defined inside the implementation class. If I add js/custom_message.js file to the array of files, how do I access this file, say for example using a URL?

  3. Is there any way to access a file inside the static folder of a plugin using a direct URL? Right now I use http://server/fogbugz/default.asp?pg=pgPluginStatic&ixPlugin=37&sFilename=fileName to refer these. But when using this notation it seems files cannot access other files in the same directory tree using relative path.

I would be very grateful if you could help me with the above. Thanks in advance.

flag

1 Answer

1

You should use the IPluginJS interface instead of the IPluginStaticJS interface, which we have deprecated. You can find the documentation for it and an example here: https://developers.fogbugz.com/default.asp?W206

  1. The purpose of the IPluginJS interface is to specify javascript that your plugin wants to be included on every page. What it guarantees is that the javascript in the specified files is executed on every page when your plugin is loaded.
  2. Once the files are indicated using IPluginJS, their contents will be executed (via a script tag) on every page.
  3. To get a link to a file inside a plugin's static folder, you can use the PluginStaticFileUrl method (see the documentation at http://www.fogcreek.com/fogbugz/library/80/html/5ED47D60.htm). (You should use this function, although it turns out that it does generate a URL of the form you mentioned.) This will indeed let you reference files inside the static folder. For example if I have a file in my plugin zip located at "\static\foo\hello.jpg", I could get a link to it in my plugin using

    base.api.Url.PluginStaticFileUrl("foo\\hello.jpg")

Cheers, Jack

link|flag
Thank you very much for your response Jack. I will try your suggestions and update the progress here. – ramishka Jun 6 2012 at 20:32

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.