Alfresco 5.0C advanced search Get slingshot search parameters - json

When you make an advanced search in Alfresco it returns a json response with results executing the script
http://localhost:8080/share/proxy/alfresco/slingshot/search/?facetFields=..
I have add a button in the aikau advanced search results page and I want to execute the same script. How can I call it and get its parameters ?
The aikau button
var button = {
name: "alfresco/buttons/AlfButton",
config: {
label: "Exec Script",
additionalCssClasses: "call-to-action",
onClick:....... **call facets script**...
}
};

Firstly, if possible I would recommend that you move up to using Alfresco 5.0.d as this will enable you to take advantage of the weekly releases of Aikau as described in this blog post.
As for your specific question... you should not be attempting to define an Aikau button like that (with the "onClick" attribute). Aikau works over a publication/subscription mechanism so buttons would be configured with a publishTopic and a publishPayload. The topic published would need to be subscribed to by another widget or a service.
If you're not familiar with working with Aikau then I suggest that you work through the tutorial on GitHub. You can also find an additional list of educational references here.

Related

like button for posts in jekyll

I want to add a like button, for every post on the homepage of my jekyll blog
I didn't find any plugin. I don't want any facebook's like button that connects to company's/product page likes.
I want a like button which is independent from any social platforms and only relates to post.
Something like this
Short answer: you can't.
Long answer: your button will have store the "likes" somewhere (usually a database), which is by definition a dynamic process. Jekyll can only generates static data.
You can bind your button to an external service, e.g. LikeBtn which provides such functionality (the free offer miss advanced features like statistics).
Whatever the service you choose, it will usually work by adding a javascript snippet, as with google analytics. You can see how to use google analytics with jekyll to help you (e.g. here).
Yes it is possible to add a like button and track number of likes by writing your custom JavaScript code and a database to your Jekyll generated static sites.
So coming to the database as it is a static page and doesn't involve any server, it is not possible to interact with database directly but there is a way.
In my case I am making use of firebase. Firebase by Google provides us many capabilities like storage, database , hosting and also access to serverless architecture using functions.
So coming to the point, all you need to do is register with http://firebase.google.com
Then create an app and then in your JavaScript add following code in head tag
<script src="https://www.gstatic.com/firebasejs/5.9.0/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
var timestamp = new Date().valueOf();
var obj = {};
obj[timestamp] = "1";
firebase.database().ref('/').update(obj)
</script>
For more details,
You can visit my blog on this topic
https://xyzcoder.github.io/firebase/2019/03/17/firebase-real-time-database.html
Note: we can also implement security restrictions on who can read and write data to our json store
Thanks,
Pavan

Get JSON from Google Apps Script URL via Erlang

Good Evening!
I've been looking into the possibility of using GAS(Google Apps Script) to host a small bit of javascript that lets me use the new Google finance apps api. The intention being that I'll be using the stock information for a project which involves the use of stock data. I know that there are a few ways to get stock information from Google, but the data that the finanace app returns is more in-line with other sources we are using. (One constraint on this project is that we have multiple sources).
I've written the javascript and I can call a httpc:request to the URL for the script given to me from Google. In the browser the JS returns the json object as I want it, however when the call is made from Erlang I'm getting it in a list of ascii. From checking the values it appears to be a document starting like:
Below is the javascript and the url to see the json:
https://script.google.com/macros/s/AKfycbzEvuuQl4jkrbPCz7hf9Zv4nvIOzqAkBxL1ixslLBxmSEhksQM/exec
function doGet() {
var stock = FinanceApp.getStockInfo('LON:TSCO');
return ContentService.createTextOutput(JSON.stringify(stock))
.setMimeType(ContentService.MimeType.JSON);
}
For the erlang, it's a simple request but I've not been doing erlang long, so perhaps I've messed something up here (The URL being the one mentioned above). I've got crypto / ssl / inets when I'm testing this on the command line.
{ok, {Version, Headers, Body}} = httpc:request(get, URL, []}, [], []).
I think it's also worth mentioning that when i curl it from Cygwin, I get a massive load of HTML also, I've included it below, but if you see it you'll thank me for not posting it in here! http://pastebin.com/UtJHXjRm
I've been updating the script as I go with the new versions but I'm at a bit of a loss as to why it's not returning correctly.
If anyone can give me any pointers I'd be very grateful! I get the feeling that it's not intended to be used this way, perhaps only within other Google products and such.
Cheers!
It would be necessary to review how are you deploying the Web App, specifically the Who has access to the app, to access without authentication should be configured as shown in the image:
See Deploying Your Script as a Web App from the documentation.
In my test, by running:
curl -L https://script.google.com/macros/s/************/exec
Get the following result:
{
"priceopen":358,
"change":2.199981689453125,
"high52":388.04998779296875,
"tradetime":"2013-10-11T15:35:18.000Z",
"currency":"GBX",
"timezone":"Europe/London",
"low52":307,
"quote":357.8999938964844,
"name":"Tesco PLC",
"exchange":"LON",
"marketcap":28929273763,
"symbol":"TSCO",
"volumedelay":0,
"shares":8083060703,
"pe":23.4719295501709,
"eps":0.15248000621795654,
"price":357.8999938964844,
"has_stock_data":true,
"volumeavg":14196534,
"volume":8885809,
"changepct":0.6184935569763184,
"high":359.5,
"datadelay":0,
"low":355.8999938964844,
"closeyest":355.70001220703125
}
Possibly your GET is not following the REDIRECT that happens when you use contentService. Look at the html returned there is a redirect in there.

Is there a way to target specific file in Box app on IOS through box:// url scheme?

Box:// seems to open the app, however I am not able to discern how to target a specific file.
Currently we don't have support for this, but it is a great idea that we'll consider for our roadmap.
We actually do support this. The best way to add this integration into your app is to use our OneCloud AppToApp framework (additional information available here http://developers.box.com/the-box-sdk-for-onecloud-on-ios/)
This is easy using the app-to-app framework. You just need to call BoxAppToAppAPI's sendFileDownloadRequestToApplication:withMetaData: if you want an app to go to a particular file and in Box's case download/preview it.
To make it go to the Box app you can simply pass in [BoxAppToAppApplication BoxApplication] in the first parameter.
As for the metadata parameter, you can create it with BoxAppToAppFileMetadata's appToAppFileMetadataWithFileName:fileExtension:folderPath:mimeType:fileID:folderPathByID:exportToken:username:
Assuming your app already integrates with the Box API via the SDK or otherwise, it should be able to get all of that information easily.
If the mimeType is not known, nil can be passed in. Also, nil can be passed in for the exportToken if the file was not exported out of the Box app (with the AppToApp framework, a roundtrip scenario is also supported where the user starts in the Box app, picks a file to view/edit/etc in your app, and then sends it back to Box to upload). So if it's not a round-trip, it's just a one-way from your app to Box, use nil for the exportToken.
Before doing this, you can also check if the Box app is installed by checking for [[BoxAppToAppApplication BoxApplication] isInstalled].
Below is a fictional example (the values are made up):
BoxAppToAppFileMetadata *metadata = [BoxAppToAppFileMetadata appToAppFileMetadataWithFileName:#"fileName"
fileExtension:#"png"
folderPath:#"All Files/Folder1"
mimeType:nil
fileID:[NSNumber numberWithLongLong:123456]
folderPathByID:#"0/12345"
exportToken:nil
username:#"username#email.com"]
BoxAppToAppStatus status = [BoxAppToAppAPI sendFileDownloadRequestToApplication:[BoxAppToAppApplication BoxApplication]
withMetaData:metadata];

Implementing UI services with HTML services within a sites page

I am trying to wrap my head around some concepts and trying to extend the help desk exercise in the process. What I am trying to accomplish is the following:
Within the site, create a "re-usable" page and create multiple links in the navigation like:
https://sites.google.com/a/mydomain.org/helpdesk/tickets?status=new
https://sites.google.com/a/mydomain.org/helpdesk/tickets?status=open
This Page, contains an HTML Service which reads the query string parameters and proceeds to query a spreadsheet for all tickets with the specified status and that are assigned to the current user, then displays them in a table format.
Then on the table, on each line, there will be a button that says "add solution or comment", this will open a UI service that allows the user to enter some text and change status if necessary.
So my questions are:
Does this sound feasible? Can I call a UI service from an HTML template service?
Can the HTML Service read the query string parameters?
Any examples of this?
Thanks for your feedback.
You can not mix UI service with HTML service. Once you're using one you have to stick with it.
But what you described can be easily done using either one. i.e. showing a table with some info and a button per row, that will show a textbox. So, yes, this is perfectly feasible.
Reading the url parameters can be easily done on "server-side", that is, it's independent if you're using Html or Ui Services.
Example of reading parameters? Here it is:
function doGet(e) {
var status = e.parameter.status;
if( status == 'new' ) {
//do your thing
} else if( status == 'open' ) {
//just examples
} else
;//bad status
return appOrHtml;
}

Determine if given job is currently running using Hudson/Jenkins API

Is there an API to determine whether a given job is currently running or not?
Ideally, I'd also like to be able to determine its estimated % complete and get the details of the SVN revision number and commit comment too!
EDIT:
I found the answer. http://host/job/project/lastBuild/api/ has almost all of what I need in it somewhere! If you kick off a manual build, it won't tell you the SCM changesets, but that makes sense. It does still tell you the latest SCM revision though, so that's good. All in all, good enough for my purposes right now.
As gareth_bowles and Sagar said, using the Jenkins API is the way to know.
If you put the depth to 1, you will see what you're looking for:
http://host/job/project/lastBuild/api/xml?depth=1
You will see there's a <building> tag to tell if that build is running
...
<build>
<action>
<cause>
<shortDescription>Started by user Zageyiff</shortDescription>
<userId>Zageyiff</userId>
<userName>Zageyiff</userName>
</cause>
</action>
<building>true</building>
<duration>0</duration>
<estimatedDuration>-1</estimatedDuration>
<fullDisplayName>Project #12</fullDisplayName>
<id>2012-08-24_08-58-45</id>
<keepLog>false</keepLog>
<number>12</number>
<timestamp>123456789</timestamp>
<url>
http://host/job/project/12
</url>
<builtOn>master</builtOn>
<changeSet/>
<mavenVersionUsed>3.0.3</mavenVersionUsed>
</build>
...
I'm using the Groovy plug-in, and run the following snippet as system:
import hudson.model.*
def version = build.buildVariableResolver.resolve("VERSION")
println "VERSION=$version"
def nextJobName = 'MY_NEXT_JOB'
def nextJob = Hudson.instance.getItem(nextJobName)
def running = nextJob.lastBuild.building
if (running) {
println "${nextJobName} is already running. Not launching"
} else {
println "${nextJobName} is not running. Launching..."
def params = [
new StringParameterValue('VERSION', version)
]
nextJob.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
}
It works like a charm.
If you go to your job's page, and add "api" to the end of the URL, you'll get information on using the API.
http://yourjenkins/job/job_name/api
More information on using the Jenkins API:
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
If you're comfortable with digging through the Jenkins Java API, you could write a system Groovy script to get this data. The Job class is the place to start.
As stated on the /api page of your build (chapter "Accessing Progressive Console Output"), you can poll the console output with a GET request by calling <url-to-job>/lastBuild/logText/progressiveText. To quote the API doc:
If the response also contains the X-More-Data: true header, the server is indicating that the build is in progress
And there you go. You can test this behaviour by simply calling the respective URL in your browser and then inspecting the response headers with your browser's developer tools (usually accessed by pressing F12). In Firefox, the respective tab is called "network analysis" (assuming my translation is correct, my browser is not set to English). In Chrome, navigate to the "Network" tab.
This answer is based on Jenkins version 2.176.3.
It is also possible to look at the color attribute. I know it is not the wanted way. But maybe someone can make use of it.
get the overview xml via "/job/api/xml" and then check the color attribute for "anim".