How to display CMIS document in web browser - cmis

I get document from CMIS. I get document content stream (ContentStream), but I can't figure out how to display this content in browser. Only I know how to save as a file.

If you mean you want a URL that will display the content nicely on the browser, that can only happen with a limited set of MIME types, namely with the ones your browser supports rendering for.
For example, currently in cmis.alfresco.com there's a node with ID workspace:SpacesStore/i/6873cce7-73b1-4209-8d79-b16b694f02d3, for which the getObject document lists the following:
<content type="text/plain" src="http://cmis.alfresco.com:80/service/cmis/s/workspace:SpacesStore/i/6873cce7-73b1-4209-8d79-b16b694f02d3/content"/>
As it's set to be text/plain my browser (Chrome) displays it nicely on screen.

Related

How can I prevent an iframe displaying an email to load images and other email trackers?

We have a web admin panel in which the agents can see conversations with customers.
Those conversations are the result of importing normal emails thru an IMAP connection. We grab the "untouched" mailbox files and we store them in a database. Then we post-process the files to index by "from", "to", "date" and so on and so forth.
Up to here, okey. We can seek all the emails involved with a client and render them at will.
Then when the agent looks for a customer in the web admin panel and opens it, the full email conversation appears. And we display the HTML version of the email within an iframe (or the text version if the html version is not there). 90% of the customers send HTML.
What happens? Upon the agent opening the email in our web, the iframe loads the "full html" and renders it. This makes "remote loading" (images, sounds, styles if so, and whatever) to be downloaded. This allows customers to "track" if we opened the email by appending tracking id's to the assets (typical http://track.example.com/image.jpg?id=123456789)
I've tried the "sandbox" attribute of the iframe html tag with no luck (it still downloads the images).
Question
How can I programmatically tell the iframe to not load ANY remote content, and just render the initial HTML without any remote call?
Mozilla's iframe documentation listing all available attributes for the is here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
If you look at "sandbox" there is no restriction specific to image or other includes, just restrictions on things like running JavaScript. There are no other attributes that would restrict images and includes.
To solve the problem of images and includes in your HTML you will need to filter the HTML either at the server before sending it or in the client after it arrives.
Server:
Before storing it into the database.
In the code that retrieves the HTML and returns it to the iframe.
Client:
Use AJAX to fill the iframe with the HTML, with code that filters a
response. With this approach you could also use a div instead of an
iframe if that works better for your layout.
If all of your users will use Chrome or Firefox, you could look at writing a browser extension

Programatically retrieve the updated og:image of a page in an extension

There seem to be many pages where the the og:image does not change as I keep browsing from one page to another. The og:image always points to the first (landing) page. This is true of youtube videos, for instance. Of course, reloading the page provides the correct og:image
I am wondering if there is a way, within a custom extension on Chrome and Safari, to force refresh the og:image data without affecting user experience?
Dynamically updated sites (aka AJAX sites) change only a portion of the page with the new content on intra-site navigation. The meta information in head element like og:image isn't updated usually.
A universal workaround for any site with AJAX navigation would be to make a XMLHttpRequest for the current URL, convert the response into DOM via DOMParser API and extract the og:image tag.
Or you can write site-specific code and try to find an internal variable or element that contains the og:image. It requires some reverse-engineering, and your code would break on site changes.

How to capture PDF contents using Chrome Extension API

I'm writing a Google Chrome Extension, and I need a way of saving the contents of the current page, whether it's an HTML page or a PDF page.
For HTML, I can use chrome.pageCapture.saveAsMHTML, however, this does not work if the current page is a PDF document. I've been searching for a way to dump the PDF from Chrome's PDFViewer, but I've found absolutely no information on it.
The one requirement I have is that I can't issue a second request, as the PDF is the response from a form submission, and a second request would re-submit the form causing duplicate data. This system is out of my control, so I can't change the behavior.

xpages File Download control - open instead of save?

When you click on the link for an attachment in the File Download control in XPiNC, you are promoted to save the attachment. Is it possible to configure the File Download control to open the attachment directly instead of prompting the user to save it? We're using 8.5.2 FP3.
Handling of an "attachment" is primarily done by the Browser (XPiNC being a firefox browser inside Notes). If for example, a PDF plugin is installed in the browser and the servers sends the corresponding "application/pdf" mime-type with the file, the browser uses that plugin to display the file. The correlation between mime-type and plugin or external application in the browser is something the server/webapplication can not influence.
What you can do on the server side is sending the mime-type "application/octet-stream" instead of the one corresonding to the file type, causing the browser to display the "Select application or download" dialog. So in Xpages, you would have to redirect the download through a XPage, where you set the corresponding HTTP Headers as shown in Set cache headers on an XPage and How to force PDF files to open in browser?
I haven't used the file download control or XPINC, but it is definitely possible to make your xpage or view control open an attachment directly. This method bypasses the download control.
Please see this post from Stephan Wissel: http://www.wissel.net/blog/d6plinks/SHWL-86QKNM, which gives you some SSJS that you can use to build the URL. You can use it in the onClick method of a button. You are essentially duplicating the functionality of the download control in a way that does what you want it to do.
If you want to do the same thing from a view control, then see this post: http://notesspeak.blogspot.com/2013/02/how-to-launch-attachment-from-view.html
Note that different browsers behave slightly differently but it works in all the majors.
Michael,
Here is code I used:
var unid = rowValue.getUniversalID()
var url = getAttachmentURL(unid, "storetransfer.pdf", "Testing//test.nsf")
url = "/" + url + ";"
view.postScript("window.open('" + url + "', '_blank', 'height=120,width=650,top=10,left=10,resizable=yes');");
I did modify Stephan's code a bit since my data is in a different NSF than my code. You probably know this but the view.postScript allows you to call clientside javascript from SSJS. It always is the last thing to run, hence the name. This is the same code from the Notesin9 video mentioned in the comments. I just tested this and it works like I think you want, but in firefox it does try to block the popup, and then has to push "open". Hope this helps.

Is it possible to put links in chrome desktop notifications

I'm making a chrome extension which displays desktop notifications on particular events. I am receiving and displaying the desktop notifications just fine, but the problem comes when I try to put attribute tags into notification. Instead of being the text as tags to be appended to the notififcation's DOM, Chrome seems to just interpret them as plaintext, resulting in the content of the notification being just html source code.
Is there any way that I can have the body of my messages be appended as HTML instead of just text or am I just out of luck?
It used to be possible, but now it's not. But you could use a "Rich Notification" and put the link on a button. See https://stackoverflow.com/a/13328513/488287 for details.

Resources