Ticket #275 (closed Enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

Plugin classes should not squat the JavaScript global scope

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.1
Component: DeepaMehta Standard Distribution Version: 4.0.11
Keywords: Cc: dgf
Complexity: 5 Area: Application Framework / API
Module: deepamehta-webclient

Description

The same applies for Page Renderers, Field Renderers and so on. These will be addressed in separate tickets.

Change History

comment:1 Changed 8 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 8 years ago by Jörg Richter

Webclient: plugin classes not in global space #275

IMPORTANT: plugin developers must adapt their plugin classes.
The change pattern is straight forward. Just replace...

function my_plugin() {

...

}

by

dm4c.add_plugin("my_plugin", function() {

...

})

See ticket 275.

comment:3 Changed 8 years ago by Jörg Richter

comment:4 Changed 8 years ago by dgf

thanks for this additional seperation of scope

i have good experiences with http://requirejs.org/ that also can wrap the vendor libraries and provides a dependency mechanisnm inclusive parallel loading of each hirarchy layer. please have a look at it.

Version 0, edited 8 years ago by dgf (next)

comment:5 Changed 8 years ago by jri

Thanks, dgf, for the requirejs hint!
I'll check it out.

comment:6 Changed 8 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed

comment:7 Changed 8 years ago by Jörg Richter

Webclient: plugin namespace convention (#275).

IMPORTANT for plugin developers:
For proper namespacing there is the convention to use the plugin's URI when registering via dm4c.add_plugin():

dm4c.add_plugin("de.deepamehta.topicmaps", function() {

...

})

Technically this string is arbitrary. It's just the identifier by which you can access the plugin later on, usually to call its public API methods:

dm4c.get_plugin("de.deepamehta.topicmaps").get_topicmap()

However, the string must be globally unique, so it is most natural to use the plugin's URI. Actually the plugin URI is the plugin bundle's symbolic name, which is calculated from the plugin project's group ID and artifact ID.

See ticket 275.

Furthermore in Webclient: exceptions that occur while loading and executing a script via dm4c.load_script() are rethrown to let them appear in the browser's error console.

comment:8 Changed 8 years ago by Jörg Richter

Webclient: plugin classes not in global space #275

IMPORTANT: plugin developers must adapt their plugin classes.
The change pattern is straight forward. Just replace...

function my_plugin() {

...

}

by

dm4c.add_plugin("my_plugin", function() {

...

})

See ticket 275.

comment:9 Changed 8 years ago by Jörg Richter

comment:10 Changed 8 years ago by Jörg Richter

Webclient: plugin namespace convention (#275).

IMPORTANT for plugin developers:
For proper namespacing there is the convention to use the plugin's URI when registering via dm4c.add_plugin():

dm4c.add_plugin("de.deepamehta.topicmaps", function() {

...

})

Technically this string is arbitrary. It's just the identifier by which you can access the plugin later on, usually to call its public API methods:

dm4c.get_plugin("de.deepamehta.topicmaps").get_topicmap()

However, the string must be globally unique, so it is most natural to use the plugin's URI. Actually the plugin URI is the plugin bundle's symbolic name, which is calculated from the plugin project's group ID and artifact ID.

See ticket 275.

Furthermore in Webclient: exceptions that occur while loading and executing a script via dm4c.load_script() are rethrown to let them appear in the browser's error console.

comment:11 Changed 8 years ago by Jörg Richter

Webclient: plugin classes not in global space #275

IMPORTANT: plugin developers must adapt their plugin classes.
The change pattern is straight forward. Just replace...

function my_plugin() {

...

}

by

dm4c.add_plugin("my_plugin", function() {

...

})

See ticket 275.

comment:12 Changed 8 years ago by Jörg Richter

comment:13 Changed 8 years ago by Jörg Richter

Webclient: plugin namespace convention (#275).

IMPORTANT for plugin developers:
For proper namespacing there is the convention to use the plugin's URI when registering via dm4c.add_plugin():

dm4c.add_plugin("de.deepamehta.topicmaps", function() {

...

})

Technically this string is arbitrary. It's just the identifier by which you can access the plugin later on, usually to call its public API methods:

dm4c.get_plugin("de.deepamehta.topicmaps").get_topicmap()

However, the string must be globally unique, so it is most natural to use the plugin's URI. Actually the plugin URI is the plugin bundle's symbolic name, which is calculated from the plugin project's group ID and artifact ID.

See ticket 275.

Furthermore in Webclient: exceptions that occur while loading and executing a script via dm4c.load_script() are rethrown to let them appear in the browser's error console.

Note: See TracTickets for help on using tickets.