Applying transformation on html string inside a json response of ajax in moovweb - moovweb

Hi I am new on moovweb and I got stuck on a requirement to apply transformation logic on ajax response which is coming in a json format containing html, which I have to add on my page.
A sample response
{
"success":true,
"html" :"<div>This can be a big html data</div>"
}
SO basically, I need to apply transformation on that html string. I gone through docs but I did't got anything to handle this kind of scenario.
Is there any way to do it?

If I understand your question correctly then there are several steps that you need to take in order to solve this issue.
Open your Moovweb project using Google Chrome, right click your mouse and choose Inspect Element which will open your Chrome Dev Tools.
Choose the Network Tab at the top of your Chrome Dev Tools which will be the second tab from the left.
Trigger the ajax call on your site and you will see under the Network Tab the response URL of the ajax call. Most of the time it will be in a format like www.yoursite.com/ajax/rest_of_url
Once you have found the ajax response URL then open your main.ts file in your tritium script and insert the following code if your response URL is similar to the format provided above:
match($path){
with(/ajax/){ #or wherever the site files for the ajax response are contained
log("--> importing ajax.ts")
#import ajax.ts
}
}
Now created a file in for your tritium code called ajax.ts. The file will be in the same location as your html.ts and main.ts files. With the code applied above to your main.ts, every time a URL is called that contains /ajax/ then the ajax.ts file will be applied.
Now you can open your new ajax.ts file that you created and start applying your tritium functions to transform the json format containing html to way you need it.

Related

Confluence Plugin: How to create space and pages programmatically from imported CSV?

I want to add a button to the system.header/left, which I already did. And when I click that button, I want a file picker popup to choose my CSV.
From the CSV content, I want to create space and pages.
I've browsed through the documents and tutorials, but I can't find anything alike.
Could you point a direction or steps for me? At least, point me to something relevant?.
Here's a short overview:
Your button will trigger a JavaScript.
That javaScript will open a dialog window containing the form elements allowing the file upload
The target of that form will be either a servlet or rest-endpoint
inside your plugin. Let's assume it's a servlet.
The servlet will
take the submitted file, split it using the defined separator and
create the page structure using the confluence API calls.
And forward to the start page of your new Space.
I'd suggest that you start with the servlet.
Provide a couple of lines of test data, to check if your code creates the page structure as expected.
Once this works, add the file handling part (from a dedicated html) and pass the data to your existing function.
Now, you have the backend and the frontend, so rendering the dialog when your button is clicked, is pretty straight forward.
Make sure to display the button only if the current user has the right to create a space.
Stuff that might help you:
confluence servlet module: https://developer.atlassian.com/server/confluence/servlet-module/
reading a CSV in java: https://www.baeldung.com/java-csv-file-array
Uploading a file in Java: https://www.baeldung.com/upload-file-servlet
How to create a new Space using Java API: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-create-a-Confluence-Space-with-Java-API/qaq-p/491588
Confluence API: SpaceManager: https://docs.atlassian.com/atlassian-confluence/6.6.0/index.html?com/atlassian/confluence/spaces/SpaceManager.html
Confluence API: PageManager: https://docs.atlassian.com/atlassian-confluence/6.6.0/index.html?com/atlassian/confluence/pages/PageManager.html
Hope this helps.

Generate multiple sheets in one pdf file

I am trying to generate a pdf from a Tableau workbook which has two sheets using the url method:
E.g: https://TableauServer/views/workbook/sheet1?:format=pdf&parameter=value
I am doing this in a program which will issue the url request to the url. The url works fine for one sheet. But the problem is how to generate one pdf file with both sheets in it?
If you first put your two sheets into a single dashboard and then use the URL for the published dashboard (still using the format=pdf parameter), this should work just fine.
We know it's possible because within the Tableau pages itself if you download a PDF it gives you several formatting options, including the option to put all the worksheets in a workbook into a single PDF.
I couldn't find any documentation on it though. What I ended up doing was looking at the network console in the browser (usually F12) when I downloaded the PDF from the browser by clicking the Download button. That showed me the URL end point and the JSON body the server expected in the request payload.
The endpoint URL wasn't too cryptic and ended with "commands/tabsrv/pdf-export-server". The challenge was to take the JSON in the request payload and find the right settings to get it into a single PDF.
This method is a more technical approach and requires very little coding skills; any language that has functions for http calls will work (I use python for it).
If you don't mind doing it outside a browser, tabcmd has lots of functionality to control PDF generation at the command line.

How to find out the source of a request (in chrome dev tools)?

I have a weird network request in my page, which refers to JavaScript files, which I removed from every html file earlier. Cache is cleared and there is no single reference to be found in the source html and the JavaScript files. For fixing that and also out of general curiosity I would like to know if there is a simple way to find out where a request was triggered, preferably using the chrome-devtools.
Update:
Thanks to jaredwilli I found the initator column under the network-tab. However this only shows Other. What I would like to know, is the (html or javascript) file where those Requests have been triggered.
On the Network panel, you can determine what the initiator of a request was by viewing the Initiator column. It gives you the file, line number and type of resource it was, either Script or something else.

How to read PDF file from right to left on iOS

I am working on a basic project that reads pdf files from a server and show them on the screen.
The issue is that i want to read that files from right to left as a page.
Like Massimo Cafaro say :
If you want to extract some content from a pdf file, then you may want to read the following:
Parsing PDF Content
from the Quartz 2D programming guide.
Basically, you will use a CGPDFScanner object to parse the contents, which works as follows. You register a few callbacks that will be automatically invoked by Quartz 2D upon encountering some pdf operators in the pdf stream. After this initial step, you then actually start parsing the pdf stream.
Taking a brief look at your code, it appears that you are not following the steps required to parse the pdf content of the page you get through CGPDFDocumentGetPage(). You need first to setup the callbacks using CGPDFOperatorTableCreate() and CGPDFOperatorTableSetCallback(), then you get the page, you need to create a content stream using that page (using CGPDFContentStreamCreateWithPage()) and then instantiate a CGPDFScanner through CGPDFScannerCreate() and actually start scanning through CGPDFScannerScan().
The "Parsing PDF Content" section of the document pointed out by the above URL gives you all of the information required to implement pdf parsing.
if you don't try anything you can start with this project link

viewing autocomplete.do files

i was trying to reverse engineer a website ("www.asklaila.com") to find out how their yahoo UI AutoComplete Widget is working. Upon finding the view source of it, i saw it is refering to a file called "/autocomplete.do", i wanted to know what does this autocomplete.do file mean and can i download and open it locally on my machine?
Hope my requisite is legitimate and ethical.
As explained by FileInfo.com, the .do extension represents a server side Java code file that runs on the server and outputs HTML to the response.
Therefore, you cannot download it and view its contents. Any requests to the file will either return the same HTML or an HTTP error if it requires parameters/form fields.