Could anyone provide aikau form example with data loading? - javascript

Aikau example contains a var button which configured to show popup with form control. As I know every aikau form has a value, which can be used to prepopulate controls, but how to load value from URL?
E.g. someone push on the button, it load "somehow" data from URL, stores them into Form value and then populate one field on the form.
The key problem is what parameters to use as URL (is it publishPayload.url?) and what and where a topic should be set for this?
I have tried already example modification and try to add publishPayload.url and setValueTopic: ALF_CREATE_FORM_DIALOG_REQUEST, but do not see any HTTP requests with URL. If URL was wrong I can see requests with 500 or 404 codes, but even these requests are not send.
Could somebody provide an example how to do this?
Note
It can be just a piece of code for button and cell with value. What is the data or url it does not matter, URL can be a simple link to some NodeRef with title/name property.

As with your last question I would suggest that you work through the Aikau tutorial on GitHub (see https://github.com/Alfresco/Aikau/blob/develop/tutorial/chapters/About.md) I think that you'll find that it has a lot more useful information on Aikau than the official documentation - those examples are taken from old blog posts that were written before Aikau became a standalone project in GitHub. The examples you're looking at a very much out of date and I will try to get them removed from the official documentation.
Aikau works on a publication/subscription model. A button will be configured with a publishTopic and a publishPayload. When clicked the payload will be published on that topic. Services can be provided to subscribe to published topics and provide data.
There are lots of examples of this in both the tutorial previously referenced and in my blog posts on the Alfresco Community platform

Related

Instagram ?_a=1 API JSON not working anymore

Recently, I have noticed that adding ?_a=1 at the end of an Instagram user's name no longer returns a JSON object that describes the information on the page.
For example: https://www.instagram.com/{username}/feed/?__a=1
The link used to return a large JSON object about each post.
Was this removed by Instagram or is it just me? Also is there a stronger alternative to be able to read post data from a user without having the be signed in to their account?
Thanks
Based on other answers to the same question, it looks like the feed works intermittently for years.
I tried /channel/ instead of /feed/ as others suggested, but the same error persisted.
Some suggest it's an invalid user agent header that causes issues.
This API URL I found from an XHR request when logged in also returns a user agent error if accessed directly.
https://i.instagram.com/api/v1/fbsearch/accounts_recs/{username}
{"message":"useragent mismatch","status":"fail"}

How to automatically save the headline for every new article provided my 3rd party js script is embed on a website

I am working on a something similar to Disqus, and I created a third-party javascript snippet which the user will embed in the website and have a rating widget for each article. Users can rate the article using the widget. Everything is working, the server is making the request, but I am making the article object instance explicitly.
I need to automate this, like for a new article on the website, checking the request is coming from the authenticated website and create a new rating widget in the Database in Django and Django-rest-framework.
I am using Python 2.7.
Question:
How do I automatically save the headline of the new article, if its new and authenticated in the database?
I know that I need to use a model to implement this, but I am unsure how to do the actual implementation.
EDIT:
Let's say this is the query
https://example.com/embed/comments/?base=default&version=edb619270a92c3035c453faa7c9444d1&f=example&t_i=article_2431522&t_u=http%3A%2F%2Fwww.firstpost.com%2Fbollywood%2Flatest-trailer-of-spectre-is-out-james-bond-is-back-all-guns-and-cars-blazing-2431522.html%09&t_e=Latest%20trailer%20of%20%27Spectre%27%20is%20out%3A%20James%20Bond%20is%20back%20all%20guns%20and%20cars%20blazing&t_d=Latest%20trailer%20of%20%27Spectre%27%20is%20out%3A%20James%20Bond%20is%20back%20all%20guns%20and%20cars%20blazing&t_t=Latest%20trailer%20of%20%27Spectre%27%20is%20out%3A%20James%20Bond%20is%20back%20all%20guns%20and%20cars%20blazing&s_o=default
In my model I need save the following, like f to forum (where forum=models.CharField("short name", max_length=30, unique=True)
I know I need to parse the url for every &, but don't know how. I checked the documentation of rest-framework, but I didn't get the gist of it.
`f ---->forum,
t_i----> identifier,
t_u----> url
t_s----> slug,
t_e----> title,
t_d----> documentTitle,
t_t----> title || documentTitle,
t_c ---->category,
s_o----> sortOrder,
l----> language`
What's the best practice to save?
Hope this helps
I'm going to just answer the question you stated at the end: "How do I automatically save the headline of the new article"
You're right, you'll need to create an Article model that mirrors the 3rd party site's articles.
It'll need to have a field for the title/headline (probably CharField), make sure you make it big enough and/or deal with cases where the title is bigger.
You'll also need a unique ID for each article. Ideally, rather than using Django's default, you'll use whatever the 3rd party site is using as the unique ID as a One to One mapping.
Then whenever a request comes in you can use the get_or_create method to ensure the article exists in your DB.

Using Google Spreadsheet as JSON file using tabletop to datatables returns error

I'm a relative newbie when it comes to coding, especially javascript. I currently am trying to populate a table from a google spreadsheet, which will update when the spreadsheet is.
I followed this tutorial word for word (basically all you need to do is replace the key with your own to specify your spreadsheet, and make sure its both published and public, which I've done)
http://dataforradicals.com/the-absurdly-illustrated-guide-to-sortable-searchable-online-data-tables/
I just get a bad request 400 error referring to my spreadsheet. If I visit the spreadsheet generated directly I just get the words...
"Invalid query parameter value for sq."
https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&sq=&callback=Tabletop.callbacks.tt140241226993949106
I can visit my spreadsheet with the link I was given when I published it here..
[maximum links reached but the structure is different]
As you can see the domain structure is different. I fear that "Tabletop to Datatables" is adding an outdated url to the start of that link but can't find where it actually applies it.
The only reason I would think thats not happening is because the example in the tutorial still works! And the link it refers to is the old style URL too
I'm baffled, please help if you can. All suggestions appreciated
The query string includes a parameter without a value, &sq=.
https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&sq=&callback=Tabletop.callbacks.tt140241226993949106
^^^^
Try this, with that parameter completely removed...
https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&callback=Tabletop.callbacks.tt140241226993949106
There is an updated version of this project. Any necessary updates are included here:
https://github.com/scottpham/tabletop-to-datatables
Try with the updated versions of all js libraries.
Check the link and remove the extra string after pub. That part of link is not necessary and may cause issues.
According to google:
The 400 Bad Request error is an HTTP status code that means that the request you sent to the website server, often something simple like a request to load a web page, was somehow incorrect or corrupted and the server couldn't understand it.
Good luck

Getting data using RESTful and backbone.js

I've been reading tons of tutorials, I really like this technology, but I am missing something.
Following this tutorial http://www.youtube.com/watch?v=FZSjvWtUxYk you get JSON data from this url, http://backbonejs-beginner.herokuapp.com/users then you set your model, and collection.
I am not sure how to set this url on my own (for either local storage or database storage), I obviously need to set it to where I can GET the data or PUT/POST/DELETE data. I need to mention that I dont want to use PHP to send the data to the database, because this is a cordova app. Maybe setting data is beyond just using a URL, hopefully some one can make this clear, this should be easy points for most.
I am missing something easy here, because there is a reason they are not covering this topic extensively (maybe they are and I am overlooking it), but oh well ill ask anyways maybe someone can point this out :)
Here is the ajaxPrefilter it kind of confuses me, I know it obviously prefilters our url to point to the data, but I am not sure how to apply an appropiate url for local storage/server side.
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
options.url = 'http://backbonejs-beginner.herokuapp.com' + options.url;
});
Edit: Also I noticed that when I run a POST request, this url changes http://backbonejs-beginner.herokuapp.com/users and adds my data, this is from the RESTful services right, and what is so special about that url that it allows me to do that? In the meantime I am going to keep rewatching the backbone tutorial videos, to see what I am missing lol.
Also watching this http://net.tutsplus.com/tutorials/javascript-ajax/understanding-backbone-js-and-the-server/ starting from the beginning he actually understands what I mean, but jeffery uses PHP, which maybe I can use with cordova (pointing to a script or something) but I would rather use javascript to send data to mysql and local storage.
EDIT: Okay I see heroku is a cloud based service https://www.heroku.com/ so inside that url we were using a dummy type of service to store the data.. Okay so now how do I point the url to local storage?
Finally got it!
I came across this Backbone.js + Java Wine Cellar Application. It is an application with a Backbone front end and a Java backend. You have just to download it, set up the environment and see how it works.
There is also a tutorial, the author wrote it also in PHP, just check his blog.
Okay, so I am a noob, I am sure the way I asked this question may have gotten confusing but here is what I did.
I spent a good amount of time figuring out how to use https://github.com/jeromegn/Backbone.localStorage what I learned is, models and collections are well models and collections of data. I didn't think of it like that(should have been transparent from the get go, but oh well) inside the model and collection you need some data and so from the tutorial I followed the method of getting data was via http://backbonejs-beginner.herokuapp.com/users it contained jSON data which we could work with.
So in using local storage, we need to change where our jSON data is by using localStorage: new Backbone.LocalStorage("choose-some-identifier"),
So understanding the model and collection really helps in knowing what to do. Now I just need to figure out how to add localstorage data to a server, and since I am using phonegap it would be cool to add an event listener for when the user connects to the internet and on that event submit the local storage data to the server.

Finding Dynamically generated parameter values to be sent with http post method to login

I want to login to hotmail email account with httpclient. For that I need to pass 21 parameters to http post method including username and password. I found this out through temper data addon in firefox. I also found out that few of them are generated dynamically.(i.e. their values change each time we reload the page). My problem is to how do I find these dynamically generated values of the parameters which have to be passed in http post. I tried to find them with firebug addon but it did not help ! I think values are generated by javascript. If it is, then how do I parse them ? I have used Html parser before but it seems that it does not support javascript parsing. I would appreciate any idea regarding this.
Thank you.
This might be some form of CSRF anti forgery token, in which case I don't think you going to come right. They might be stored in some cookie, or in a hidden element in the page.
More info: http://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/

Categories

Resources