I have a Rails app that can generate PDFs using Prawn. Some of them can be fairly large (tens or hundreds of pages) and take some noticeable time to generate. What I would like to do is display some HTML page with a message like "Please wait while we create your document (spinning icon)", and then display the PDF once it is done.
I was thinking of using Rack Middleware to do this. Admittedly, I know nothing about Rack except having watched Railscasts Episode #151. It seems like I could intercept the request to these large PDFs, display the HTML waiting page, then intercept the response and replace the HTML with the generated PDF content.
Is this possible? Will this work with Rack? If not, what is something that might accomplish this? If it will work with Rack, can someone give me a generic explanation of the steps to do this? I've been searching the internet, and the Rack stuff I've found isn't very beginner-friendly (thus, I'm asking here).
Any help will be much appreciated.
Ian
Not sure that this is what you want, but you can send message to the browser via something like private_pub after PDF is ready and handle receiving of that message on the client side (show a link, start download etc).
Related
I have an web-application in RoR which calculates some energy values and investment money. I use ajax to send the data from the web-browser to the server. It is something like this: Browser-server-Browser-Server-Browser
This web-application is already integrated in typo3 and I want to implement a PDF button to send the results per email (in other words, a photo of the page with the results).
I have heard an option would be to generate some links in RoR to be used in typo3 (when clicking on it, it would open exactly the web-application with the results already calculated). But as a newbie, I do not really know which would be the best approach.
Any recommendation?
A screenshot of the page can be done client-side:
http://html2canvas.hertzen.com/
You could even have another page with the same results that you use only for the rendering of the result page what you use for making a clean screen-shot (you might not want to have the footer, menu and other elements on that page, only the results)
Once you have your screenshot, you can upload it to your server where you can use it to create a PDF of that image and then send it with any mail API you prefer to use.
info about TYPO3's mail api can be found here:
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Mail/Index.html
I'm new to rails and could use some help choosing the right rich text editor. I would like visitors to be able to add content (text, images, and video) to the site using one rich text editor form. Once submitted by the visitor I need to be able to sanitize content, save images/video to public folder, and save text and the path to those images/videos to the database for future retrieval. Is there a gem or combination of gems that can help me accomplish this.
I've already looked into tinymce, ckeditor, and mercury but none seems to meet my needs. Tinymce and ckeditor and their plugins require the URL of the image which means that users would first have to upload the image and then know the path to it. That's a little to complicated for my audience. Mercury is based in html5 and is currently unstable depending on the browser. Are there any other options out there?
http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors
I didn't look to deeply, but I'm assuming one of these jquery/javascript plugins is a WYSIWYG HTML editor.
Once you've got a good client side HTML editor running, the next part is parsing the HTML when sent to the rails app.
http://www.rubyinside.com/nokogiri-ruby-html-parser-and-xml-parser-1288.html
I've never used Nokogiri, but it's name is very familiar, It seems to be used a lot.
Sanitization is baked into Rails. The default sanitize will strip out ANY HTML, but you can call sanitize telling it which HTML elements NOT to block. Assuming you parse out the HTML you allow to pass through sanitize, using Nokogiri (or whatever HTNL parser you find), you'd be manually santitizing those elements as you extract values from them.
The tricky part would be eliminating the 'file select' operation on the client side as the user needs to select a local image to place in the HTML document. I don't think you can eliminate it, but hopefully HTML editor makes it as simple as possible. There not really much you can do about it, if the user will add one of HIS images to an HTML document he'll upload, he'll HAVE to select it at some point.
This is the closest I've come to something that you describe, I'm also looking for something similar so I'll keep you posted :)
http://youhack.me/2011/07/07/create-a-facebook-post-to-wall-system-using-php-and-jquery-part-2/
I have read many links in this forum and the asp.net forum and searched Google. I have found loads of progress upload bars, but not one that suits my specific needs. So i was hoping someone could help. I need an upload progress bar that does not use, flash, php, html 5 or any codebehindfiles, was hoping to find a javascript pure upload progress bar. Has anyone used anything like this before?
Thanks
Marcel.
Valums Uploader. It uses pure Javascript (uploads file using Iframe)
I'm not sure if that's possible with all the stipulations you've added. The upload is a purely server side process. You can use javascript to poll the progress using ajax, but that still requires a server side code file.
The file uploader I always use is http://slfileupload.codeplex.com/
This allows you to do multiple files, have progress bars, and hook into events with javascript. It is silverlight, so that might rule it out for you.
The only other thing I can think of, with the limits you've imposed, is showing a 'working' gif, like a spinner or something. It's not true progress, but it'll show the user that something is happening.
Here's one that doesn't use anything except Javascript/HTML/CSS
http://aquantum-demo.appspot.com/file-upload
I'm looking to get the title of a webpage, a common feature of many IRC bots that I'm wanting to incorporate into a IRC client I'm writing for fun.
The method that I currently have working basically connects and sends a GET request for the entire webpage then seeks out the tags and reads inbetween them. For larger webpages this can be slower than I'd like. An additional problem I've noticed is webpages with dynamic titles (such as some phpbb forums) will not return the accurate title as it would show in a browser because I don't do any execution of javascript ect..
It seems one way to get an accurate title is to dump the html into a browser control (such as the IE COM control) and pull the title, but this is just going to make it even more time consuming.
Is there a simple method I am un aware of?
In a word, no, not really.
I guess rather than downloading the whole document you could stream the HTTP file into your application and just stop downloading when you reach </title> - that would save you waiting for the whole HTML document to download.
However that doesn't help the situation if you need to read the title after it's been changed by some client-side javascript. As you say, the only way I can think of doing that is by using a browser control.
I've looked around but wasn't able to find what I was looking for. I'm looking for a way to automatically create short URLs displayed in the browser, not using a URL shortener. Basically I would like to re-create something like this:
idzr.org/1ptb
I upload screenshots to my server with "GrabUp" on a regular basis but it creates rather long URLs for example:
/2523e3c90d60f08e952215424e7c5d99.png
It's a bit annoying having to shorten them each time.
I have seen this method a lot lately with pretty much any file including html files. If this has been discussed already I'm sorry I'm posting it again. I just seem to be stuck.
Thanks in advance for any help & advice!
I don't know, what webserver do you use.
You write rule for rewrite
-- htaccess for Apache or equivalent for IIS
You push content to user thru your code, because browser doesn't know what content get from web server
-- use http header - MIME type