Where to declare application scope variables on marionettejs I - marionette

I am using marionettejs yeoman generator
https://github.com/mrichard/generator-marionette
what's the best way to declare global variables like application root path and API endpoint ?

Declare them right on the app itself, or create a Util module or something. There are numerous ways to do it.

Related

How do I access 3rd party lib global objects in Angular 2 apps?

When a library creates an object in the global scope, like CodeMirror for that matter, how do I peek into that object in Angular 2?
Say, I am using ng-codemirror which uses CodeMirror library, which in turn produces CodeMirror object in the global scope. How do I lurk into CodeMirror.modes from DevTools when in an Angular 2 app?
You need to import CodeMirror in your project
import 'codemirror';//or what ever the name is of that library.
Once you have imported code mirror in your project you should be able to have the global scope you are looking for.

Classes in package freemarker.template.utility available in template?

I see there are a number of classes available in the package freemarker.template.utility. Is there a way for these to be exposed in the data model so that they can be used inside a template?
It seems like that might be what they are for but I can't figure out how to access them from my templates.
Thanks!
You can create an instance of the desired object, and drop it into the data-model like anything else. Or, you can set said objects as Configuration-level "shared variables", via Configuration.setSharedVariable.

Global var accesible only by redeclare with "global"

I have Joomla and some external php scripts and libraries. There is a main library where I declare some global vars.
lib.php
global $var_glb; $var_glb="some_value";
script.php:
require_once(lib.php);
print_r($var_glb) //Notice: Undefined variable
print_r$GLOBALS['var_glb']); //DEFINED!
global $var_glb; print_r($var_glb) //DEFINED!
So I had to put "global" in front of $var_glb in order to be accessible... normally it should be defined without "global"...
I don't know why $var_glb (without "global") is lost and only $GLOBALS['var_glb'] is accessible or when using "global $var_glb"
Why is that happening? I don't want to redeclare all global vars in the script.
I used Jumi component in order to insert php scripts into Joomla.
And the problem with global vars was related to Jumi.
I tried another similar component called Sourcerer and now everything is working ok.

Building a plugin system for a nodejs based MVC platform

I would like to be able to build functionality for my application in a plugin style system for a couple reasons:
New projects can choose which plugins are necessary and not have code for functionality that's not needed
Other developers can build plugins for the system without needing too much knowledge of the core workings.
I'm not really sure how to go about implementing this. I would like to have a plugins folder to host these separately but I guess my questions are:
How do plugins interact with the core system?
How does the folder structure work? Would each hold the standard MVC structure: controllers, services, models, views, etc?
I guess if anyone has a tutorial or some documentation relating to this technique that would be helpful. I've done a bit of searching but it's all a little too closely related to the actual code they're working with instead of the concept and I hadn't found anything specifically related to nodejs.
I suggest an approach similar to what I've done on the uptime project (https://github.com/fzaninotto/uptime/blob/master/app.js#L46):
trigger application events in critical parts of your application
add a 'plugins' section in the applicaition configuration
each plugin name must be a package name. The plugin packages should return either a callback, or an object with an init() function.
either way, inject to the plugins the objects they will need to run (configuration, connections, etc) when calling init(), or executing the callback.
plugin modules register listeners to the application events and modify it
Benefits:
lightweight
rely on npm for dependencies
don't reivent the wheel
Create a plugin prototype for the base
functionality, and let the user define its plugin in a module. In the
module the user would inherit an object from the prototype, extend its
functionality, and then export a constructor which returns the plugin
object.
The main system loads all plugins by require("pluginname") and for
each calls the constructor.

VS2010, MSDeploy and declaration of parameters

I'm trying to deploy an ASP.NET MVC 2 app using MsDeploy. I use VS2010 to generate the package as a ZIP. Inside that ZIP is a parameters.xml file that declares the parameters that I can set.
I want to be able to set more parameters, using the auto-generated deploy.cmd file like this:
MySite.deploy.cmd
"-setParam:name='IIS Web Application Name',value=MySite"
"-setParam:name=IisVirtualDirectoryPhysicalPath,value=C:\inetpub\MySite"
"-setParam:name=httpBinding,value=*:80:www.mysite.dk"
That works fine, except for the httpBinding param. That is because that parameter is not declared inside the parameters.xml file that is added to the ZIP container.
I could go and add that parameter declaration manually, but isn't there a way to do it from the command line and have it declare parameters I have in another XML file?
Are you saying that the value param was not declared when the package was created? If so then I think you would have to add it. Either manually or you can use the -setParam switch and sync the package from and to itself. If you use -setParam with a name which was never declared as a param to begin with I'm pretty sure that value is just ignored.
I'm only just looking at this, but is the section on MSDN about the matching of declareParam with setParam the way to go ?
I'm using MsDeploy to update my deployment zip following the idea in this stackoverflow post
Apologies if I'm completely off on this

Resources