Using ScriptSharp to code YUI controls - javascript

I am in the process of choosing ScriptSharp for coding all my javascripts. I already use JQuery and it is great that there is built-in support for this.
But what about YUI? I need it in particular for the editor control..
How can I code the part for the editor control within Script# framework? Is there a place to enter custom javascript when a certain library is not supported or something similar?
Are there any future plans to add YUI to ScriptSharp?

It would be interesting to have YUI support, but there aren't specific plans to add support for it right now, at least not at the top of the priority list.
However, if folks in the community want to get it going and contribute, I can help with questions that come up.
The general idea is you create an import library (there is an Import Library project template when you install Script#), which defines a c# API corresponding to the OM that you program against. The C# API consists of classes and stub methods that define the signatures (think of this as a header file of sorts). There are a few metadata attributes to customize generation of script that references those APIs to get various transforms to happen ... so you can create a working, and often times more natural c# interface that then maps to runtime script constructs and APIs you are targeting.
When I see the sample at http://yuilibrary.com/ I see a bunch of parallels to jQuery, so I imagine building support for it is likely possible at a technical level.
The best way to understand how to do this would be to look at the sources of mscorlib.dll (represents the core script objects) Script.Web.dll (represents the DOM) and Script.jQuery.dll (represents core jQuery API). All of these are in the Script# repository on github ... https://github.com/nikhilk/scriptsharp ... if you haven't already seen them.

We are creating an import library for OpenLayers (http://openlayers.org) and I can say it is incredible easy to do. We started just doing what NikhilK says, inspecting the source code. The results are just great. YUI is a very well designed and documented api, so I think it would be stratightforward. You could just create the import clases you need for your project.

Related

Add js external libs to embedded Camunda with Graalvm js-engine

I'm trying to implement some complex business validation logic via JS in DMN using java embedded camunda with spring boot. To avoid usage of deprecated Nashorn and add ES6 support, I've added to project graal js engine. It seems it works pretty well, but I have no idea how to add custom functions into context of js-script engine. Let's say I have index.js in my resource folder with exported functions, how can I register such extension to be able to use it into camunda?
Graal.js already works to a certain extent, but official support for it is only added in 7.16. Please see: https://jira.camunda.com/browse/CAM-13516
Specifically the point of allowing to load external scripts by default is in discussion there. You may explain your use case in a comment on the ticket.

Converse.js core library

I have setup openfire server and I am able to connect converse.js client. It is working fine.
I however do not want to use the converse.js UI. Is there a way to only use converse api without the Backbone UI part.
I tried removing the Backbone part but it is not working.
I understand it uses strophe internally but converse have readymade functions
Firstly, it should possible to use Converse simply as an engine, or API and I've done some work to make this usecase feasible. Specifically by splitting Converse out into plugins. However, I haven't used it myself like that yet, so it's rather theoretical still at this point.
Backbone is however is critical, because it's used for more than just Views. Backbone Models and Collections are used to model data and relationships between objects. So you can't remove it.
As mentioned, Converse is made up of plugins. The plugins that are included in the final build (created by running make dist) are all listed in src/converse.js.
You can create customized builds by editing this file and removing plugins that you don't want.
So for example the converse-chatview.js plugin contains Backbone Views for rendering chat boxes. So it can be removed. Similarly the converse-controlbox.js is a View that renders the control box can also be removed.
Other plugins to remove would be converse-minimize.js and converse-dragresize.js, both which are UI-focused.
However, here comes the fly in the ointment. converse-muc.js, which provides support for groupchats contains boths views and models, and is not yet split up. So if you need to support groupchats, then you'll need to include that plugin and its views in turn depend on converse-chatview.js, so it will also be included (even if you remove it from converse-config.js).
What needs to happen is that converse-muc.js needs to be split into two files, converse-muc.js and converse-muc-views.js (this will probably happen in a future release). Then you could remove the latter from your build.
So, sorry if this is not a super satisfying answer.
What you can also do is write your own plugins, and in those plugins you can override or change any of the Models, Collections or Views from other plugins (if your plugin depends on them, and is therefore loaded after them). This however requires you to study the code somewhat, to develop a decent understanding of what needs to be done.
EDIT: For more info on the plugins and how they work, take a look at pluggable.js which is the underlying library and the relevant converse.js documentation.

Custom UI for Alfresco ECM

What are the options for implementing a custom UI for searching the alfresco repository?
I have found only customizations of the Web Scripts share which is more of a WCM thing. Could it be implemented and expanded for Custom Model searches from imported CMIS data?
Has anyone built a custom UI for communicating with the 5.0 or 5.1 alfresco repository?
Any help or search paths would be greatly appreciated.
It's up to you, really.
Latest versions of Alfresco have a nice and documented REST API, which you can consume. Additionally, web scripts you might create are also easily accessible with a simple HTTP request, so customizing is not a problem.
https://api-explorer.alfresco.com/api-explorer/
The latest thing is what Gagravarr already mentioned, Angural2 based components (which also speak with the above mentioned REST API).
Here is a blog post with almost the exact title as your question. The short answer is you can use whatever you want to build a custom app on top of Alfresco.
Yes, there are Angular2 components that will be available some day, but for now, they rely on REST API changes that have not been shipped in any stable release of Alfresco, including Community Edition. They require an early access release (201606-EA or higher) which you should not run in production.
So from whatever language you decide to use you'll be making REST calls. But to which API? There are many. Here is the order of preference you should use when selecting an API for Alfresco.
CMIS. Grab a library from Apache Chemistry.
Public REST API, see http://docs.alfresco.com/5.1/pra/1/topics/pra-welcome.html
Out-of-the-box web scripts marked "Public". See http://localhost:8080/alfresco/s/index for a list, then click down to an individual web script until you see its lifecycle.
Your own custom web scripts
Out-of-the-box web scripts with no lifecycle or something other than public.
That last one is truly a last resort. Don't do it without being fully aware that you are writing against an API that will change without warning.

Recommendation for SWT/JFace Javascript Editor?

I'm building an app using SWT + JFace and I would like to integrate a Javascript editor (with Syntax Highlighting and Auto-Indent).
I'm looking for something simple like RSyntaxTextArea: just use the widget like as a TextArea and set the syntax to "Javascript".
So far I've come across examples with "JFace Text" but it seems I have to implement the Javascript part myself. Also, I don't want to integrate the whole Eclipse workbench if possible.
Do you know of any component that would do the job?
It's possible to use StyledText widget (so no dependency on JFace) to show syntax highlight (see Into the Deep End of the SWT StyledText Widget), but it's quite lot of work to do..
For additional example see Implements syntax coloring using the StyledText API.
It's also possible to use SWT_AWT bridge and put the RSyntaxTextArea to your application directly..
I found some interesting project, which might help you with the situation..
It's called The DJ Project (The Sweet library brings some rich components to SWT-based applications) and when you check the Gallery, you can find as last example SWT gui with javascript syntax highlighted text area.
The licence is LGPL, which is one of the best for any purpose..

Dojo style coding

I'm new to dojo style coding. Got used to pure javascript and then jQuery style. Searched through and got some results such as
Dojo, when used with closure compiler works best.
advanced dojo is more OO than procedural type
I'm having problems with
dojo.require() - whenever I download a plugin for dojo, I get the error - 404 NOT FOUND. and half the time for developing goes in fixing this issue, getting the js file and placing it at location.
And is it possible to extend the dojo object as in jQuery we extend the root jquery object by using $.fn.somefunction that is internally defined as jQuery.fn = jQuery.prototype. Is there something similar in dojo.
And I feel documentation for dojo is not as good as jQuery's.
What are dijit and dojox ? When I import dojo.js from Google api library, and then using a plugin in dojo, these dijit and dojox were always a problem.
Need some help. I'm porting few plugins from jQuery to dojo. These plugins are not available in dojo.
I feel that you have to use the entire library when coding using dojo, and then compile it to get the optimized code, and export it to whereever needed. Am I right here? if not, what am I doing wrong?
1) dojo.require automatically downloads the needed files through XHR requests. You don't need to download anything manually. If you use the google CDN all classes should download from there, i would recommend to download the full package to your local application and use it from there. Later you probably want to create a Build. You should also read Starting with Dojo
2) Enhancing dojo like jQuery don't makes any sense. dojo is just the top namespace and under it you have a lot of classes like dojo.Animation, dojo.behavior, dojo.Deferred, dojo.NodeList and a lot of other classes. Some are functions like dojo.connect() and dojo.style().
If you want to create a new class look into dojo.declare. You can also create new classes under the dojo "namespace" or other namespaces.
If you want to add a new function to the dojo namespace, you can just type dojo.new_function = function(){} Like normal JavaScript. But i wouldn't recommend that. It can make problems if you upgrade to later Dojo versions.
jQuery and Dojo are completly different. If you type something like $('.data') in jQuery it fetches all dom-nodes with the class "data" and it returns a new object wraped in the jQuery class.
In Dojo you use dojo.query('.data') for the same effect. But it returns a new object of the type dojo.NodeList. If you want to add new functions to the chain ability you need to extend dojo.NodeList.
There already exists some extension like dojo.NodeList-fx that adds the Animation effect to the dojo.NodeList class. If you load the class with dojo.require() your dojo.Nodelist will extend automatically. Look into Extend dojo.NodeList for more information.
3) The documentation is quite good, everything you asked is already documented and i provided some ressources you completly find on the main page from Dojo. The difference is that Dojo is a completly Toolkit, including GUI, layout systems, Widgets, data abstraction and a lot of other really high-level stuff. If you never worked with something like that, it could be hard to start with it because it contains so much. jQuery doesn't provide anything like this. So sometimes it is sure easier to start with it.
For documentation look at:
Tutorials
Reference Guide
API Browser
4) Dojo is a toolkit that uses 3 namespaces in JavaScript dojo, dijit and dojox. The dojo namespace contains things that nearly everybody uses later, like a Framework for I18N, L10N, model abstraction like dojo.data or dojo.store and a lot of other stuff.
Just loading the "dojo.js" file by the way don't give you everything that dojo provides.
The dijit namespace contains a lot of widgets in Dojo. All Widgets in the dijit namespace have full I10N and L10N support. dijit contains Dialog, Layout Systems, Widgets like calendar, buttons, select fields, radio fields, a full WYSIWYG Editor under dijit.Editor.
Also see the Dijit Theme Editor to see what Dijit contains. The complete site including layout is complete based on dijit.
The dojox namespace contains a lot of extra functionality that dont fit in dijit or are experimental. But not everything is experimental. You find things like the dojox.grid.DataGrid or dojox.charting (Start Charting, Advanced Charting) or Systems like dojox.gfx to create cross-browser graphics that uses SVG, Canvas, VRML, Silverlight or Flash.
Just look into Beyond Dojo's Core to get a (small) overview what dijit and dojox contains.

Categories