How to load different configs for MoxieManager - moxiemanager

I use Moxiemanager as a standalone plugin (just including moxman.loader.min.js).
This file calls api.php, where MOXMAN class initialises with default config.php file.
// Load default config
if (!isset($moxieManagerConfig)) {
$moxieManagerConfig = array();
require_once(MOXMAN_ROOT . '/config.php');
}
What would be the best way to pick different configs for different pages?
For example on 1 page i would like to change autoformat rules and on another change folder path.
Can i pass a parameter somehow? Or define a constant?

Ok, i found that the easiest way would be just to have a separate folder for images with mc_access file where we can redefine the settings.
Create a folder
Set rootpath to this folder in js
Put ms_access file with redefined settings.

Related

Webpack: Why there are multiple files with same file name when search the source code?

I am using vue.js (2.6.5) and webpack (5.77.1), and I enabled the source map feature in development env, with simple config as below:
mode: 'development',
devtool: 'eval-cheap-module-source-map',
.....
Well, the source map feature indeed works, but what confuse me is when you search a file name, there will be multiple files with same file name listed, see as below:
Only one of them is the exact original file definition, other files are definitions of render function of vue.js and some others. Every time I need to click on each one of them to check which is the exact original file, this annoys me, does any one know how to only show the exact original file ?

Intellij idea Live templates variable run groovy script relation file path

Live templates -> edit variable.
I can specify groovy file in variable settings: groovyScript("C:/test.groovy")
Where is "home" directory to store my script? i Want something like that:
groovyScript("test.groovy")
For easy export config to another PC.
groovyScript's argument can be either the script text itself or a filename. In the latter case the filename is relative to idea or idea/bin directory. It's probably better to use absolute paths.
In recent IDEA builds you can share live templates by copying them to clipboard (Ctrl+C, see https://youtrack.jetbrains.com/issue/IDEA-141077)

Meteor upload empty files to public folder

I'm trying to upload files in Meteor using this great script. I modified the event to handle multiple files, like this:
'click #saver': function(ev) {
$.each( $(".fileuploader"), function (index, item) {
if(item.files.length > 0) {
Meteor.saveFile(item.files[0], item.files[0].name);
}
})
}
Everything else is exactly the same as in the Gist (see link to script, above).
The upload shows no errors and the page reloads after the public folder is changed, but most of the files uploaded to the public folder show up as empty, (i.e. they are 0kb in size). There seems to be no pattern. Sometimes all files are empty, sometimes only a couple, and in no predictable order. The console sometimes logs correctly, and other times doesn't. Any thoughts?
Thanks, as always, for your considered advice.
db
It's not that easy at this moment. Files in public dir are managed by Meteor. Therefore, whenever contents of that directory change, the server reloads itself - terminating the file save you've been inside.
The solution is to put files in a place Meteor does not care about: hidden folder (.name), ignored folder (name~), or folder outside of Meteor directory.
Then you'll need to serve those files by hand. See this answer for a snippet:
Dynamically insert files into meteor public folder without hiding it

Save the modified Property file inside WAR deployed on server

We are trying to use Apache PropertiesConfiguration in our project using JSF and JBoss.
My property file is located inside a package say demo.prop by the name of Prop1.prop
Inside my WAR file the same is present under /WEB-INF/classes/demo/prop/Prop1.prop
Using
FacesContext.getCurrentInstance().getExternalContext().getResource("/WEB-INF/classes/demo/prop/Prop1.prop");
I am able to fetch the property file. So when I try to extract a string from the property file using
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
String s1=(String)pc1.getProperty("User_Name");
I am able to get the proper string. Using set property method I am able to set the property also.
pc1.setProperty("User_Name", "hardcodedString");
But I am not able to save the FILE back to this location. No matter what I do it is not able to save the file using pc1.save.
Can anyone please try to tell me how can I save this file back to its original location so that the changes done in the property file remain as it is.
Modifying the WAR file is a bad idea (for example, some web servers may notice the file
modification an redeploy your app, there may be problems when the server explodes the war on deployment etc.)
I would suggest applying an alternative approach - some possibilities are:
Place the properties in a database table, so they can be easily modified
Use an external properties file for overriding your "Prop1.prop" file settings. You can pull this off for example as follows. Assume that the default property values are bundled in your WAR and the modified values are saved to some other path, which is defined using a system property - let say it's called CONFIG_LOCATION. Now after loading your properties from the bundle you read them also from this external "overrides.prop" file - this overrides your defaults from "Prop1.prop":
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
try(FileReader propReader = new FileReader(System.getenv().get("CONFIG_FILES") +"/overrides.prop"){
pc1.load(propReader);
}
When you need to save changes, you do that to "overrides.prop" - this will save all
the properties, not only the changed ones, but that should have no negative effects.

Where should I put my custom widget files in Yii framework?

From this page,
http://www.yiiframework.com/wiki/23/how-to-create-a-breadcrumb-widget/
It seems it suggests that we should put the files in the component folder. But if my widget contains javascript and css files, where should these files be placed?
By the way, is this a good idea that I create it as an extension? If I go this way, all widget files are more self-contained in a folder inside the extension folder. But since the widget I am going to work on is very customized, it's unlikely that it will be useful to other people or my other projects. Making it an extension seems a little bit strange.
I understand that it does not really matter where I put these files as long as the paths I am using in the codes are correct but I would like to know the common practice.
I think the common practice is to put the widget in extensions folder with js & css files in an folder named asset. In the php class file, you do initialization first by publishing the asset with yii asset manager.
The file structure may be like
extensions/
widget_name/
widget.class.php
assets/
plugin.js
style.css
I would join the recommendation to put the widget under /protected/extensions.
I put the assets in a slightly more detailed manner: /protected/extensions/WidgetClassName/assets/ and the widget view files in /protected/extensions/WidgetClassName/views/...
Don't forget to edit your /protected/config/main.php and add a row in the 'import' section (for autoloading of the widget): 'ext.WidgetClassName.WidgetClassName.*'