Is there a way to programmatically download a web page, for offline viewing, using WebKit? - iphone

What I'd like to be able to do is download any web page, and be able to view it offline.
It seems like html WebKit views cannot be converted to PDFs (on the Mac, you could 'print' a PDF, but that isn't possible on iPhone?).
So, the only way is to save the actual resources - save the html, the step thru each image, css, js file and save it locally. Then maybe alter the urls within the code so they point to the right place...etc ...etc...
Is there a standard way to do this?
Or, is there an open source project (in any programming lang) which does this kind of thing?

There's an excellent webkit html to pdf converter appropriately called wkhtmltopdf. Given the reources available on the iphone and its toolkits, I think it'd be easy to compile a version for the i-Phone ('think' being the operative word). We've managed to use the tool in a Windows, Linux and Solaris environment with absolutely no bugs. Here's the link:
http://code.google.com/p/wkhtmltopdf/

Related

Load PDFs from local file share

I'm developing a web app for in-house use and I'm looking for a better way to display PDFs.
I've played around with Adobe's 'Work with Local File' example from GitHub, Adobe GitHub Example, and it works great using the file picker to display a PDF. Is it possible with Adobe's PDF Embed API to take a file located on a local file share and display the PDF?
I'm thinking I need to create a file promise but I'm not sure how to create that.
Unless you can make a network request to load the PDF, the answer is no. Browsers generally can't read from local files unless a user action actually picks the file. If your local share can be made accessible via HTTP, then you would be good to go.

Live manipulation to a Localhost Webpage or a Local Html File in Flutter

How can I show a HTML+CSS file in a Flutter widget, while being able to manipulate the HTML or CSS (in file) and viewing the changes live?
Manipulating HTML:
I could use JavaScript to manipulate the HTML DOM of a loaded webpage, probably through localhost? Is there a better way to do it instead?
Manipulating CSS:
Searching around the internet I find JavaScript like "dom.getElementById('something').style.color = color.red". Though, how could I go for loading css on every change of the css file, if possible?
I hope my question is not vague. Please let me know of any issues or suggestions on this question.
The app is meant for desktop installs, though I wouldn't mind switching to working with flutter-web if need be.
Kind regards.

is it possible to view a question with a browser before importing it to Moodle?

I have created a XML file using R-exams out of just a single exercise to be imported to Moodle. I would like to view it before uploading it in the Moodle question bank. I tried to open it with Firefox and I can see some code but not the output and a message appear saying that the XML file does not seem to have a style sheet associated to it. Is there a way to find this style sheet and to see how the question comes out just using a browser like Firefox or Chrome?
To emulate how the R/exams exercises are converted to HTML by exams2moodle() and how Moodle displays mathematical content, it's best to use
exams2html(..., converter = "pandoc-mathjax")
In recent versions of R/exams the resulting HTML file then automatically loads the MathJax Javascript that enables correct rendering of mathematical content in all modern browsers (including Google Chrome). See also http://www.R-exams.org/tutorials/math/ for some general advice about math in HTML.
To the best of my knowledge there is no tool that would quickly display Moodle XML files in such a way that you can easily assess them.

Presenting a website locally and offline in iOS

I am developing an application for a client where a requirement is that a series of complex (multi-file, JS, CSS, etc), websites must be presented offline, without any web connection required at all.
So I have all of the HTML content folders, and can add them into my XCode project... but now I need to show them.
The UIWebView is fine when you just have one HTML file... but the relative paths for the JS and CSS do not translate over.
What is the best way to do this. I've seen a couple of potential choices. One way is to run a super basic web server locally, dump all the files into /documents (or thereabouts) and serve it from there... the second is to somehow make UIWebView re-interpret the paths so that they point to the right place locally... which I am not sure if it's possible but I've seen it alluded to.
Seems like a lot of people just cover loading a single UIWebView page, and not so much discussing how to deal with CSS/JS dependencies.
Anyone have any bright ideas, links, etc?
Thanks
I think that if you add your HTML/CSS/JS tree to your Xcode project and select "Create folder references for any added folder" (instead of "Recursively create groups for any added folders"), then your bundle will contain the HTML/CSS/JS folder hierarchy (instead of the flattened-out list of all files). This would preserve relative paths.
As to the "reinterpreting" point, you can define
– webView:shouldStartLoadWithRequest:navigationType:
in your UIWebViewDelegate to intercept any attempt at loading any file. There you can change the url on the fly.
Also, have a look at this interesting article by Rob Napier: Drop-in offline caching for UIWebView.

GWT Toolkit: preprocessing files on client side

If there's a way for the client side GWT code to pre-process a file on the client computer?
For example, to calculate a checksum of it before submitting the file to the server.
No it is not possible. The manipulation of the file is done by the browser, not the HTML code.
Think about it, GWT is 100% javascript. And javascript has no access whatsoever of the file in your computer. That would be an pretty big security risk! GWT "wraps" the file input box so it can be displayed inside the GWT panel. But once you press the "upload" button, the upload is done by the browser.
You could do file manipulation with another technology however. Java applets for example. But that is outside of GWT area...
Using GWT, there is no way to read files on the client side yet. However, in HTML5, you can read files without uploading to a server using the "File API".
Links are provided below.
File API tutorial on html5rocks.com
Example of how to use File API in GWT via JSNI
I'm pretty sure that because GWT code compiles to pure JavaScript, there isn't a way without requiring some third-party browser plugin.
Do you mean from an <input type="file"...> file upload field in a form?
The short answer is no-- file uploads are handled by the browser, and are sent directly to the server (as an ENCODING_MULTIPART POST). And security restrictions on JavaScript mean there's no way to workaround that restriction.