Create an Aloha Repository - repository

I've been looking at using Aloha for a project but I'm completely stumped by the documentation. I'm trying to create a repository following the documentation and I have this so far:
requirejs.config({
paths: {
'jquery': "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min",
'aloha': "http://cdn.aloha-editor.org/latest/lib/aloha",
},
});
define(
['jquery'],
function($) {
"use strict";
require(['aloha'], function(localAloha) {
console.debug(localAloha);
console.debug(Aloha.AbstractRepository);
});
return {};
}
);
Now. This tries to pull Aloha and jQuery from an appropriate CDN, and it works fine. However, despite what the Aloha documentation tells me, localAloha is not defined (it appears Aloha doesn't return itself) but that's not a problem since my that point it's in the global namespace anyway.
More frustrating when trying to define a repository is the fact that Aloha.AbstractRepository is undefined, despite all the examples, and code from live projects like the Drupal Aloha plugin, telling that all I need to do is extend Aloha.AbstractRepository.
Does anyone have any idea what's going on here? Aloha looks great, and is perfect for what I have in mind, but it's proven to be very difficult to actually get it working.

here is some code which should help you.
a php script is reading files from direcotries (eg. upload dir) and generates a json file with that information. that json is in the format which can be used by a js file (repository api) to tell aloha editor what's in your repository: http://ge.tt/1VJqium/v/0?c

Related

Extracting strings from source files during webpack bundling

I have a Vue application which uses Webpack 3 as bundler. The application contains custom translation tags ({% trans %}...{% endtrans %} as the templates used to be Jinja2 style) which get converted to $(...) as part of the bundling (using replace-string-loader), which vuex-i18n requires.
Is there a way to extract all $t() strings as part of the bundling into a file, so that this file can be translated? Since the replace-string-loader needs to process the files first, I expect this translation extractor to be integrated in the webpack.conf file (as part of the module.rules array)? Is there anything already out there which does the job or can someone please provide some help on how to write such a "loader"?
if $t() is an invocation of a function, u can write a webpack plugin that will hook the parser and trace all of the invocations, then write them to file using emit hook to write the collected data to file.
compiler.hooks.normalModuleFactory.tap('MyPlugin', factory => {
factory.hooks.parser.for('javascript/auto').tap('MyPlugin', (parser, options) => {
parser.hooks.expression.for('$t').tap("MyPlugin", expr => {
console.log(expr);
});
});
});
Good blog post about starting with webpack plugins: https://medium.com/webpack/the-contributors-guide-to-webpack-part-2-9fd5e658e08c
You can check the source code of providePlugin as a reference, read here what it does.

Angular translate useSanitizeValueStrategy does not work at all

I have a problem with angular translates useSanitizeValueStrategy.
It does nothing regardless what configuration i use.
I am using the async loader to load my translations.
It is an ASP.net MVC web api project.
Things I did to make it work :
implemented ngSanitize
tried multiple configurations
$translateProvider.useUrlLoader('api', {
queryParameter: 'langId'
})
.registerAvailableLanguageKeys(['en', 'de'])
.preferredLanguage('en')
.fallbackLanguage('de')
.useSanitizeValueStrategy('escape'); // tried every configuration I found
I also tried to seperate the useSanitizeValueStrategy like $translateProvider.useSanitizeValueStrategy('escape');
or tried to change the position of the command but this did not work either.
any suggestions why this does not work?
$translateProvider.useSanitizeValueStrategy('escape');
Try above-given line into your application configuration where you configuring your angular-translate library. In above given an answer with Strategy escape. This will escape HTML in the translation. You can also find many options here.

How to use TextEncoder and TextDecoder from bootstrap addon

Following OS.file example it uses TextEncoder however from bootstrap scope this is not available.
https://developer.mozilla.org/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread#Example.3A_Read_the_contents_of_a_file_as_text
Only way I could access it is by going decoder = new Services.appShell.hiddenDOMWindow.TextDecoder(); but is thi the only way?
You can use TextEncoder and friends inside a javascript module. But doing so might be an overkill, if all you want is a couple of missing globals (putting aside the fact that jsm are cached and this might not work well with a restartless addon).
Conveniently Addon SDK's loader delivers what you need.
const { TextDecoder, TextEncoder } = Cu.import('resource://gre/modules/commonjs/toolkit/loader.js', {});

"Access denied" error on 'rename' call when uploading files in Symfony

I'm working on a Symfony project in a Win7/Apache 2.2/ZendStudio environment and I have some trouble getting my file uploads to work properly.
My goal is to let the user create a new entity which can contain arbitrary many "Documents" (based on the article found at http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html). I have a form type containing one field of type 'collection' (based on the article found at http://symfony.com/doc/current/cookbook/form/form_collections.html). So far so good. Via jQuery I can add arbitrarily many forms as subforms which works fine. But when I submit my form, very often (but not always!) I get the following exception:
Warning: rename(C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityRecruiter.php.507bf02e30df69.85090364,C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityLecture.php): Zugriff verweigert (code: 5) in C:\Programming\Servers\Apache2.2\htdocs\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Proxy\ProxyFactory.php line 194
Zugriff verweigert is German for Access denied. Weirdly, the files seem to get renamed and saved at the right location nevertheless.
Why do I get this exception, does it have something to do with my environment and how can I fix it? I guess this issue is related to Symfony Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5), but not quite sure whether it's the same as it happens in another context. I do also encounter the problem described in this link, though.
Thanks in advance.
I've been running into the same exact issue recently. I don't really have a good sense of why the problem is happening, but the problem is coming from a step in the process where Doctrine is trying to generate proxy classes.
In my config.yml file, under the ORM section of the Doctrine configuration, I changed the value of auto_generate_proxy_classes from %kernel.debug% to false. I've played with it for a while since making the change and haven't been able to reproduce the issue since.
Found this while looking for same answer, it seems to be a windows + Doctrine issue.
Doctrine Ticket with more detailed info
TLDR: Basically the proxy is trying to rename a file that's still being used, works in Linux but not always on windows.
Go to the file that renames the file, then replace it with a windows compatible rename function
private function renameWindowsCompatible($oldfile,$newfile) {
try {
rename($oldfile,$newfile);
} catch(\Exception $e) {
if (copy($oldfile,$newfile)) {
unlink($oldfile);
return TRUE;
}
return FALSE;
}
return TRUE;
}
I learned about proxies and saw that it is used with lazy loading.
I had an entity A with a one to one relationship to B.
B was the problem is the proxies directory
I just had fetch="EAGER" annotation in A entity
/**
#ORM\OneToOne(targetEntity=B::class, fetch="EAGER")
*/
private $b;
Then the B proxy was not generated and no more problem with rename.
Hope this help.

cometd hello world example with dojo

I'm trying to follow the basic cometd example here: http://dojotoolkit.org/reference-guide/1.7/dojox/cometd.html
It's using the old module loader so I tried the equivalent as follows:
require(["dojo/ready","dojo/io/script","dojox/cometd","dojox/cometd/callbackPollTransport"], function(ready, dontcare, cometd) {
ready(function(){
cometd.init('http://localhost:8080/MyCometD/cometd');
comted.subscribe("/test", function(msg){
console.debug(msg);
});
});
});
This doesn't work and I think it has to do with loading modules - there is some sort of silent error as the code within the ready function does not execute at all. What I found is that when the "dojox/cometd" require statement is present, the code within the ready function does not execute.
Running example: http://jsfiddle.net/Q9W8f/2/
Example with dojox/comted removed: http://jsfiddle.net/mMs2h/4/
I haven't worked with the new module loader that much so I bet I just have some simple misconception.
Help!
It seems like youre correct and that there is a 'wait-loop' for a module requirement that never gets loaded. This may be any of the requirements inside dojox.cometd and you'd need to rewrite the codebase for a fix.
I have had similar issue with the RollingListPane, also in dojox repository - and the developers are saying 'we are 100% AMD compliant with 1.7' however the X in dojox is short for experimental. The developement of dojox modules is not done by the core djtk team and there are still glitches..
Try for starters to avoid using CDN which has performed a >>built macro on every single module. This tends to fail at times whilst using AMD. Instead download the tarball and use a local copy - Not compressed (dojo-release-1.7.2-src)
You can find the hello world example in cometD and ExtJs at following link:
http://jksnu.blogspot.in/2013/08/network-reliability-by-cometd-hellow_16.html