play framework 1.x to render rich text - ckeditor

I am using Play framework 1.x and in one case, we are saving rich text data (I am currently using using ckeditor-JS on client side but am open to other suggestions e.g. markdown etc). The data gets saved in the DB correctly i.e. with the HTML tags (unless I am misinterpreting how it ought to be saved). I need to be able to render this content as HTML in my view - should I be looking to use the same library for handling the conversion or is there something in play framework (1.x) itself that I could possibly use. Hope I explained the question properly and thanks in advance to any useful suggestions.

Related

Java PDF Generation iText Alternative

I am brand new to pdf generation or rendering. I am working on a application to replace iText and create kind of a RESTful endpoints using any Java related PDF APIs.
The library should be able to convert images and.., others to PDF.
Read/fill the data from PDF programmatically and also merge.
Also, if we can host it ourselves that would be the best choice.
Could you please provide some insight into this?
Not exactly a "Java related PDF API" but since you want to go REST anyway:
We use a headless Chrome in a docker container for generating PDFs. A good starting point is hc-pdf-server. We use it as an internal service using REST.
Note that this way, documents need to be designed using HTML and CSS. Also, you need to use a template engine in order to insert contents into your documents. We use Mustache. It is simple and does the job.

SEO-Friendly, Internationalized Polymer.dart

I am displaying internationalized strings within a Polymer element as follows:
<div>
<span class="content">{{myContent}}</span>
</div>
... and have the following dart code:
#observable String myContent;
//...
void onUpdateLocale(_locale) {
myContent = getMyContent();
}
//...
getMyContent() => Intl.message('All my content ...', name:'myContent',
desc: 'This is my content',
args: [],
examples: {'None' : 0});
However; when Google crawls the app, it only pulls "{{myContent}}" and not its interpolated value, the actual internationalized content. Is there a way to work around this and make an internationalized Polymer.dart app that is also SEO-friendly?
Its not really clear. Although recently Google announced that they are evaluating Javascript to index the page, I've not seen any deep evaluation of how this compares to the server rendered pages approach.
And then there is the issue of non Google search engines like Bing.
Polymer as it stands today doesn't really do server side rendering and as far as I can tell the team doesn't have plans to offer than in the near future.
If your project/business depends on SEO I would not risk using polymer.
You have two options to address this issue:
Use phantom.js to render the page on server side whenever a crawler is requesting the page.
Use a third party service like ajaxsnapshots.
Forget polymer and use react.js component framework. React has a way to render the virtual DOM on the server side. This will work seamlessly if you are using node.js frameworks. It should be possible with JVM frameworks as well as Java 6+ ships with a Javascript engine (vastly improved in Java 8. Google "nashhorn").
Google have a spec that lets you serve snapshots of your page's HTML after all necessary Javascript (or Dart) has run to search engines: https://developers.google.com/webmasters/ajax-crawling/
The basic idea is to render the pages on the server side and then follow a set of URL conventions that lets you serve search engines the pre-generated HTML in a way that they wont confuse with cloaking.
Google, Bing, Yandex and some social bots support this spec.
You can implement this spec yourself or use a service that does it for you (I work for one of these: https://ajaxsnapshots.com) The solution is typically plugged in at web server level so you don't need to make any changes to your app.
So, I don't know much about Polymer, aside from the documentation on databinding I just viewed. It seems fairly similar to AngularJS by Google, in that it is using JavaScript in a declarative way to render data into an HTML document. That being the case, the browser is still fundamentally seeing the underlying calls to {{something}} as just a raw string. The JS libraries are then what change that data into text on the screen.
That being the case, you might consider handling SEO like Angular developers do. Here is the definitive resource on the subject: http://www.yearofmoo.com/2012/11/angularjs-and-seo.html

Is it possible to retrieve Lotus notes rich text without using Lotus notes api?

I need to create a application which receives a lotus note document file . Is it possible to retrieve Lotus notes rich text without using Lotus notes api?
You also can get rich text via http/https, using web API. HTTP task should be turned on to use this method.
Just use a request as follows:
server/databasefilepath/databasename/viewname/selectionkey/richtextitemname?OpenField
This will return you rich text item, transformed into html, that is realy userful.
Yes you can by using Domino XML Language (DXL). This renders an XML style format that you can then work through however it is complex if the user has added lots of bullet points, bolding the odd image etc.
You will have to use CreateDXLExporter() either in your app or rendered via web from a notes agent however once you have built it, each document will be available to you and in fact the entire database.
HTH
If you can't use HTTP task as shiv suggested, you can try this tool by Julian Robichaux http://www.nsftools.com/tips/NotesTips.htm#richtexttohtml.
Notes from the author:
This database has a script library that describes a technique allowing
you to get the contents of a regular Rich Text field as MIME/HTML,
even if that field isn't set to store contents as MIME.

How do I use data stored in a Blob as a view?

We're currently doing a project that accepts user-provided html and has our own injected into it. This perfectly matches Play's abilities. However, I am at a loss as to how to use dynamic content as a view template without manual intervention. It seemed best to use a blob to store the information (given that there could be thousands of templates) and somehow load that way.
Any suggestions?
Thanks in advance.
If you really want to do this (I’m not convinced this is a good idea), have a look at the implementation of play.mvc.Controller.renderTemplate(String, Map<String,Object>) in the Play source, to see code that loads a template, binds variables and renders the template.

Javascript file upload mechanism

I need for users to upload files (mostly images) without leaving the current webpage. What's the best tool, library or mechanism for doing this? I'm using the latest jQuery and Spring webmvc (with JSP), so if there's already a mechanism within them then that's ideal.
It would also be really great to have some kind of progress bar. Does that mean it requires coordination with the server to read the progress (where Spring would have to come into play)? Or is there a mechanism within JavaScript for this?
You should check out Plupload.
Plupload offers a cross-browser
JavaScript File uploading API that
handles multiple file uploads,
client-side progress meters, type
filtering and even client-side image
resizing and drag-and-drop from the
desktop. It achieves all of this by
providing backends for Flash,
Silverlight, Google Gears, HTML5 and
Browserplus and picking the most
capable available option.
Its really neat! Here's a link to some of their Demos...
http://www.plupload.com/example_jquery_ui.php
... and a screenshot of the jQuery UI queue widget (it has a progress bar!):
I hope this helps.
Hristo
I use uploadify pretty regularly: http://www.uploadify.com/
However it does use flash for the upload mechanism and as a result may create some issues if the user is authenticated.
You should use AJAX on the client side
http://www.webtoolkit.info/ajax-file-upload.html This tutorial covers all client side.
Om the server side
This tutorlal covers most of this issue:
http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
Yopu can use jquery as well or any other JS framework.
But the mist important thing is the fact You need to remember that your tag on client side should have.
enctype='multipart/form-data'
property. it means that your request contains muultipart data.
Uploadify does that trick > http://www.uploadify.com/
All samples are php but you should be able to convert it to your platform.

Resources