How to use Web Script in Alfresco as a developer? - javascript

I am new to Alfresco and using Alfresco 5.2. I started learning it as an ECM and now I can understand the Share interface to some extent. But I need to master Alfresco as a developer, for which I have to nail Web Script. But I am not sure how to progress in this direction. I am not being able to understand where can I use Web Script and how can it help me. Also, I don't know how to write Web Script/JavaScript programs in Alfresco to perform complex operations. I am stuck within all the documentations and tutorials available on the Internet. Any suggestion or advice can help a lot.

There are two types of webscripts,
Java-Backed and Non-java backed,
The Javascript API exposes a smaller subset of capabilities than the Java Foundation API that's available to Java-backed webscripts, although there are ways to increase what's exposed to Javascript or to expose new custom APIs to Javascript if you like.
The other difference which is useful at certain times, is that with a Java backed webscript you have more control over what parts of the webscript framework are used. E.g. with a JS webscript, you are always obliged to use a template for the "view" (usually Freemarker) so that can be problematic if you want to send back a raw binary content stream, e.g. a document or other non-text based content. With a Java-backed webscript you can define a class that implements the WebScript interface directly or uses AbstractWebscript instead of DeclarativeWebscript. You could also do other things like look at or set request/response headers, cookies or other things that won't have access to using a Javascript controller
Please refer this documentation
Please refer this blog for web-scripts

Alfresco identifies webscripts by its URLs mentioned in desc.xml file of webscript. Webscripts are used to exchange data between share to repo.
There are two types of webscripts share(presentation) and repository (data) webscripts. Some data resides on server(repository) for e.g. (files or users info) and you might want them to be displayed on client side page or you may want to submit data to the server, then there would be specific repository side webscript or API available which provides/accept such data. For that you have to make call(setup communication) from share to repository webscript. For more info please visit http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#what-is-the-web-script-framework
and
http://ecmarchitect.com/images/articles/alfresco-webscripts/web-script-article.pdf

Related

Automatically create a CSV file with Javascript data on Github

I'm working on a Quizz with Html/JS on Github and which will be dedicated to my comrades.
I would like to be able to read everyone’s answers so I thought about creating a text or csv file with their answers that would be saved in a specific directory of the github project.
But I’m a beginner and I don’t know if that’s possible, i’ve seen tracks that use PHP or NodeJs with FileSaver.js, but I haven’t managed any of them because i would like it to be automatic, not to ask the user to download his answers.
If some people knwo how to do it or explain me why it’s impossible and how to do it otherwise it’ll be cool.
Thanks ! ;)
Unless you want to make every person using the quiz a contributor to your Github project (which will require that they sign up for Github accounts and tell you their account name so you can manually grant them permission) and then use the API to read the CSV file, modify it, then commit the change (and resolve any merge conflicts caused by race conditions): This is not possible (and if you are willing to do that, then it is among the most complex approach that you could take).
If you want to store and aggregate data submitted by visitors to a website then write some server-side code (using whatever language and frameworks you like, PHP and Node.js are both options) and use a web hosting service designed to support them. Github Pages is designed only for static pages and doesn't support any form of server-side programming.
Once you store the data in a file, just use git commands to commit and push it.

Read Google App Script Files from another script

I am looking to create a little Google App Script to parse another GAS file to pull out the functions and any jsdoc type comments, and then display it.
Like if you navigate to a script you can get the revision history etc, but I wanted to be able to pass in a Drive folder containing multiple script files and develop a front end to display each's content.
I know about the Google Drive REST API with exportLinks do download as JSON.
I wondered if there was a simpler way to do it from another GAS file, or would I need to URLFetch of some description to do it over the RestAPI?
I have tried searching for similar things but they always lead back to the DriveAPI.
Any help with a starting place, or what GAS Objects I should start looking at?
Thank you
You have to use the REST based Drive API, there is really no other alternative. However, you don't need to use URLFetch to access it. Google Apps Script has what's known as Advance Google Services a collection of interfaces that grant native access to many REST based APIS including the Drive API.
You can check out the Drive specific documentation here. Its somewhat sparse, so you'll often have to fall back on the REST based documentation as well as rely on autocomplete inside the script editor to make sense of things.

Creating a dynamic web page using AngularJS, WCF Service and SQL Server

I want to create a web application and I am exploring how I could do this. So I came across AngularJS. I want to use WCF Service and SQL Server in my application also. I am trying to find what AngularJS, WCF Service, SQL Server can do for me because I do not want change technologies in the middle of my project after discovering that AngularJS cannot do things which I want my application to do.
So, my question is can AngularJS help me create Static web pages and Dynamic web pages?
I can start my project in ASP.NET MVC but I want to explore AngularJS and want to find out what it is.
My project is about
Sending E-mails
Displaying content from database (in any manner using Ajax)
Voice chat, Video chat, Text chat
Can contain Javascript, jQuery, CSS, HTML5
Tell me something about it. Any suggestions?
Thanks
Your question is vague, but I'd suggest using Microsoft WebAPI instead of WCF or even ASP MVC, due to the from the ground up RESTful design of WebAPI and much easier configuration.
Using this approach, you'll still be able to query SQL Server in C# using WebAPI, so you won't need to switch your database.
There's very little documentation by comparison for querying non-RESTful web services, so you'll gain a huge advantage in terms of tutorials, blogs, etc. by going this route.
Please see below for your questions:
Can AngularJS help me create Static web pages and Dynamic web pages?
Yes certainly it can. Check it out at the official website
2.Sending E-mails
This should be the server side responsibility using an e-mail client, for instance SMTP client
3.Displaying content from database (in any manner using Ajax)
Yes, it certainly can.
4.Voice chat, Video chat, Text chat
Try WebRTC first to see if it's sufficient for your tasks
5.Can contain Javascript, jQuery, CSS, HTML5
Yes, you can use whatever you want as long as you are sure about what you are doing.
I hope following guidelines will help you.
When you create the project select WebApi template.
Then include angularjs files in the scripts folder.
Use cshtml files,but do as you in html file.
Use angular client side mvc features to build your app fast and performance.
Use the angular http service to call webapi methods.
All the c# specfic features build in the webapi.

Converting remote RRD to JSON format

I have a project wherein I need to access remotely hosted RRD files and create a highly interactive dashboard to visualize the data (most likely using Rails/Flot etc..)
I've looked into projects such as RRDTool and Jarmon (which seems to be collectd specific) and was wondering if there was a proven way to get the data from the rrd files into a format I can use on the javascript side of things. I intend to have this running on a fairly simple heroku instance, if that's any indicator of my server restrictions.
Thanks so much,
Nader
Have a look at rrdtool xport called on the command line it can produce json for you or when called via a scripting api you get the raw data which you cann then easily convert to json using your scripting language.
HTH
tobi
You need JavascriptRRD:
http://javascriptrrd.sourceforge.net/index.html
As the name implies (Javascript RRD), javascriptRRD is a javascript library for reading and interpreting RRD (Round Robind Database) files from both remote Web servers and local file directories. It uses AJAX-like techniques, but without any code being run on a remote Web server; i.e. it provides a purely client-side access to RRD files.
The javascriptRRD package provides the basic RRD reading libraries, as well as helper libraries to make displaying of RRD files easy with the Flot library.

blogengine without php or asp.net etc

Is there a way to have a blog directly integrated into my HTML/javascript-only website, without having to have something like a SQL-database and a dynamic engine like PHP or MySQL?
Maybe there is some service in the web that offers this (hopefully without ads :) ). Or maybe I can have a blog engine entirely written in javasript?
Entirely written in JavaScript? Surely that defeats the entire point of having a "blog-engine" in the first place? The point being that the data is stored somewhere and dynamically retrieved. To avoid using anything server-side (which seems to be your intent), and only use HTML/JavaScript, you'd have to store all the data for the blog in files that are served up to each visitor, and then retrieve the data from the particular, local, locations using JavaScript.
Sorry if I'm misunderstanding the point here... but this seems to be an utterly useless way of trying to go about things. Blogs are, in general, either written statically (in HTML [even though this is rare]), or are dynamically generated from a database by a server-side scripting language (most common).
Edit: As an additional point, I suppose you could include some third-party blog feed, or service, in your page, via use of JavaScript... but I'm unsure as to which (if any) blogging services would directly support this method of working. Additionally, this is quite an unreliable way of including third-party data in a page...
Here's a thought. It's not really a blog engine - but a wiki.
Entirely javascript/html/css. All lives in a single html file:
http://www.tiddlywiki.com/
not sure how it would work on a real live site, but their site is using it:
* A personal notebook
* A GTD ("Getting Things Done") productivity tool
* A collaboration tool
* For building websites (this site is a TiddlyWiki file!)
* For rapid prototyping
* ...and much more!
You could use github pages. You will get a generated blog with version control.
Other option is to use a Desktop blog tool and then update your site.
You can user iWeb if you have a Mac or CityDesk on Windows or you may try this open source tool
Edit Today I came across this tool: Zeta producer that may help.
http://code.google.com/p/showdown-blog/
Blog engine written in just JS and XML [v0.6] {JavaScript, XML}
So, what you want is to have a blog where you're website provider doesn't provide a way to serve dynamic content?
The only way I see that you can do it in that case is writing html-files (or text-files if you prefer) and adding them to the site. After that you can have some JavaScript to add them to your "blog-page".
You of course need to upload them to the website in the same way as you do for the other files, and then have a way for the JavaScript to know which pages it should fetch.
I am not aware of any JavaScript blog-engines, but you can have a look at the templating functions in for instance Prototype
Of course, that means that you will have to fetch both the template and the content through Ajax and let the client do all the processing (could be slow and possibly insecure), and you still need to have a place to upload the content and update it.
Your best bet is going to be using a generator to create the HTML/CSS/JS to upload to your server, take a look at Webby: http://webby.rubyforge.org/
IF you really need to you can use a public api for a service that lets you post small bits of info and retrieve it using javascript.
for example if you only need small posts you can make a blog in html.javascript that utilizes twitter as the engine. of course you will be limited to 140 chars. I am sure there are other services that will allow a similar idea but with less restrictions.
And of course the best option - Get a blog software or host your blog with a service provider and link to it from you site.
Good luck
One solution would be to use some application that generates the static web pages of your blog, and uploads them to your web server. This way you'd have a blog with static content that could all be managed in javascript alongside your existing site, without needing to install database, daemon software, or additional dynamic web programming languages on your server. The static content generation could happen directly on your server if possible, or you could run the html generation tool locally and upload the output.
MoveableType has a tool like this. You still need somewhere to store the content of your blog, and for this MoveableType uses MySQL by default, so you'd still need to install a database somewhere, but the database could simply be one your local desktop.
MoveableType also has support via plugins or older versions that can retrieve data from a sqlite or other database. The advantage of sqlite is that it doesn't require installing daemons like MySQL does, you can just put a sqlite file on disk somewhere, give MoveableType the path to the file, and run the script to generate your static content.
There are likely other tools like MoveableType, and I have in the past generated blog-like web pages simply by writing small scripts to generate HTML. The main issue is just that you need somewhere for these scripts to fetch data from.
Another option might be to develop your blog using XSLT, ... with XSLT, you'd put the content of your pages in XML files, and then write a template in XSL that converts your XML to HTML.
If you google for 'static blog site generation' you might find other ideas/options, including Jekyll/github mentioned in one of the other responses.

Categories