Play framework external dynamic HTML handling - javascript

I'm developing a web application on a Play framework 2.2.0 (Scala). The application is generally taking some input from the user, and then calls external module which in turn processes the input and generates html report. The report has a rather complex structure with html, javascript and json data, all put into different files. Then I wish to be able to render this report to the user by the Play framework, without him having to download report in an archive.
I tried to put these report files to some directory in the assets, and Redirect, but this won't work in production. Then I tried to use Ok.sendFile inline, but since content depends on other files the report does not render correctly.
I wonder if there is any "intended" way to render such dynamically generated HTML to the user?

Related

Save compiled file in same path as initially opened file with web application

Currently, I'm working on a web-based configuration tool for a domain-specific language (DSL) implemented with Xtext. In the previous process, users configure devices using an XML file, which can be messy and often error-prone. Using the new DSL approach enables the automatic compilation of those XML files.
Since Xtext offers Web Editor support, I decided to go this route to prevent the installation of an additional application for the configuration process. The Servlet for the Xtext backend runs locally. Now here is my issue:
The user can either open an existing configuration or create a new one with the DSL editor and save it as a file to a specific path on the PC. Now I'd like to compile the result to the source file's location without the user having to navigate there. For this, the Xtext backend would need the exact location of the saved/opened file, but as the editor is running as a web application, I can't get the absolute path to the file due to security reasons.
The compile process works with a workaround by passing the config file content as text to the backend. The Xtext backend then returns the result to the web application as text, so now I'm asking, is there a way to save the result as a file in the same path as the initially loaded file?

Create .MSG or .OFT Outlook Files From HTML (via JavaScript)

The Need:
Essentially I have a tool that creates HTML Emails. A feature I would like to add for this tool is to create .MSG or .OFT files for use specifically in Outlook so the client doesn't have to load the HTML into outlook and create their own .MSG or .OFT files manually. This has to be done in either PHP or JS via my tool, NOT done manually in Outlook.
The Problem
It appears these files are Binary Files and I cannot find a JS Library that handles the conversion. If the client uploads the HTML directly into Outlook, then Outlook modifies the HTML in such a way that it often breaks the email. If I had more control over the conversation I could hopefully fix a few of the rendering issues.
What I've Tried
I exported .EML Files successfully, but once imported into Outlook and converted, these too break in the same manner as straight HTML.
Any thoughts greatly appreciated.

Performance between pure static html files and static html files with content loaded via JS & noSQL

Between the following setups, which one would be performing the fastest page load for a front end user. I am only interested in the speed performance for frontend users and not the maintenance requirement for backend developers.
A website that only uses static .html files, no JavaScript, no PHP, no server side programming language to render the html. Basically the origins of the internet, where each click on an internal link loads a static .html file. Each page is a pre-created physical .html file on the server.
A website with a physical pre-created .html file, however the main content (article) on each page is fetched via Javascript from a noSQL server (Google Cloud Firestore or Fauna DB). Each click on an internal link only replaces the main content of the page via database call. The rest of the website (menu, logo, sidebar, footer) is all static and never needs to reload.
A website with a physical pre-created .html file, but the main content (article) on each page itself is fetched via JavaScript from a local JSON file, no database, just a regular .json file in the same directory as the .html file on the same server. Each click on an internal link only replaces the main content of the page using JavaScript (probably vanilla JavaScript using fetch, unless react is somehow faster, which I doubt). The rest of the website (menu, logo, sidebar, footer) is all static and never needs to reload.
Of course server performance and user location does always play a role in speed tests, but for argument sake let’s assume it’s the same user visiting the same web server. Additionally in regards to noSQL, let's say it’s a fast and reliable performing 3rd party server such as Google Cloud Firestore.
Which one of these setups would be the fastest? Has anyone tested this? I heard some people argue that basic static .html files are always fastest, while others argue that a static html file where the content is loaded via JavaScript is faster when navigating internal links once the initial page load is done. Both arguments make sense.
Any major pros or cons for one of the mentioned setups, or past benchmarks?
The speed of the webpage has two big components:
A. How fast the server responds/the size of the response
B. How fast the browser can render whatever it fetched
So, static files without JS will be the fastest, there is no delay on the server side, and the browser is very efficient in rendering static assets
The third option is still fast, but slightly slower than the first one as there is some work for the browser exists (transforming the JSON to HTML via JS)
The second option will be the slowest, as it is the only option where the server is not responding instantly with a file, but needs to connect to a DB, fetch the results, transform them, and only then send back.
All of it is relevant only in case we are talking about exactly the same content, but in different forms.
The question is slightly flawed, but to answer
Static content is fastest, the browser will render the content and cache it.
Getting content from a database adds overhead to the call and retrieval, the main page will be downloaded once and cached on the client side, the calls for content can not be cached as the browser needs to make the call to see what the content is. The upside is that the call will only return the content that needs to be displayed and DB searches are pretty quick from the big cloud service providers
This option is probably slower than 2, because the whole JSON file will need to be downloaded for the JavaScript to pick out the content for one article from all the content.
I would suggest option 2 is best from a maintainability vs speed point of view as it will only send the required data across the network and the rest is cached.
If you like option 3, have a look at using the browser cache https://web.dev/cache-api-quick-guide/ to cache your JSON file, this way the user will only need to download an updated version when you change the content

Can a Vue application be bundled into single html file to be available offline

We have an application that uses VueJs and D3. The requirement for our users is that they wont have internet connection, so they can only accept a html file or a bunch of files(zipped folder).
My first question is if we go ahead with Vue, can we use html-webpack-plugin to bundle everything into a single html file?
My second question is: When I google bundling into a single html, Progressive Web Apps show up in search results. Are PWA's web applications that you can just open an html and it works or Or is PWA more about how to handle a webapp when it does not have access to network?
Thanks!

Possible download / upload manager embedded on html page with access to local filesystem

As the title indicates i want to have a certain application get access to the local file system. To describe why i will illustrate my situation:
I am a running a IIS WebApplication with the C# MVC 4 Framework as backend module. The site solely consists of HTML, CSS markup and some JS. The page will be loaded in IE11+ (Edge) only. For the standard procedure of displaying and accessing data from as well as sending data to the server this works quite fine.
On a certain page I want the user to be able to upload a file using a simple file dialog, like the one you can initiate with a simple <input type="file"> tag. I also want to offer the posibility to download files from the server but need to know where files has been saved / will be saved to.
As described on a lot of different websites, just like this one here, the HTML5 File API does a great job but will not be able to return the full qualified filename including the local path directions, same for JS accessing the file object.
As my research confirmed HTML5, JS and also SWF (Flash) will not report detailed information because they are all sandboxed applications or restricted by RFCs. I already unterstood and appreciate the effort to secure my trips to internet.
But in this case do need the paths where a file was upload from and the file has been downloaded to.
So my question is, what is the best way to expose the full path directions for a up- as well as downloaded file to report them back to the server?
Is it possible to embed a SWF object inside HTML which will run inside an Adobe AIR sandbox or is a signed JAVA Applet still the one and only solution to accomblish this security breaking task?
A solution i would also apreciate would be the possiblity to ask the user to get access the file system, like you grant access to the web push service to receive notifications.
Also if there is a possible solution which may suite my circumstances please let me know by adding some simeple examples / revealing some factful links, thanks in advance.

Categories