Prawn: PDF generation with progress bar or spinner - ruby-on-rails

I'm using prawn and prawnto for PDF-generation in my rails-app. Is there a way to show the user a spinner or progress bar while the PDF is generated?? I think about showing a spinner-div in the document with the "generate-pdf-link" when starting the pdf-action and then removing it when the rendering finished (everything e.g. with jquery). How can I trigger that??
Thanks for your help!

Instead of generating the PDF immediately, you could display a result page with a spinner, and generate the pdf in a background job. I recommend the Gems DelayedJob or Resque for creating background jobs, placing them on multiple queues, and processing them later. There are good Railscasts for both. You can use a jQuery Timer plugin to check periodically if the PDF has been generated.

Related

How to add ChartKick chart as Mailer attachment?

The newer version of Chartkick has a download option that displays a button over the javascript chart, when clicked will open a new browser window and render the chart as an image. This is great. However, that method does not seem to help render an image to use as an email attachment. Unless there is a way to call/render the chart using a chartkick method inside the mailer, grab the image and attach it...As far as I can tell, this functionality does not exist.
Anyone know of a way to attach a chartkick chart as an image email attachment?
Natively? No. Chartkick performs a download using their script chartkick.js and chart.bundle.js. It happens entirely client-side, not server-side. And it should not be opening a new window. It should just download the file directly onto the client's machine. Example here: https://chartkick.com/react

Creating pdf with rails

I need to generate a pdf file and upload it to the AWS upon some action from my controller. I've never done this before with rails, neither created a pdf and then upload it to the aws.
So here is what I'm thinking, how to proceed.
When a action in my controller occurs and it invokes a method a, it will invoke the Job B which is a delayed job who will call the controller method c which has the respond_to and format pdf. And the job will save the .pdf file to the AWS.
The pdf that I'm using needs to be stored on the aws so it can be emailed to a user later. Not sure if this is relevant, just wanted to give more details.
I'm using prawn gem to generate the pdf
Is there a better way to do this, has anyone done something like this before?
http://rubygems.org/gems/wicked_pdf
"Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff."
I've done something similar using pdfkit. Essentially you just define your PDF layout in HTML/CSS, and when a user adds the .pdf suffic to a path, it attempts to generate the PDF. It's nice because you don't have to actually store generated PDF files, but they'll always be available if someone needs them.

Joomla 3 and Simple Image Gallery - doesn't parse {gallery}

I have a problem to make Simple Image Gallery to work in Joomla 3. It doesn't display any pictures, actually it doesn't even care about them.
I have this pages:
http://utsnorthsath.kangoowebs.com/gallery/images/34-short-course-cross-country
It looks like {gallery} tag is not recognized/parse and no gallery is displayed. Does this module SIG require any additional action after installing to tell Joomla that {gallery} tag should be parsed now?
I don't get any error message, just the content is not parsed.
Thank you for any help.
Don't want to teach you to suck eggs but when I find {plugincodes} rendered as is, it either means you haven't used the syntax correctly or you haven't enabled the plugin in Plugin Manager.
One other thing which may be affecting the plugin is that you load jquery before Mootools.
Best practice is to load these the other way around.
You could look for an excellent plugin called JQuery Easy which should fix that issue and possibly the Gallery issue too, if the above isn't it.

epub 3, how to prevent pages from running in background ? (iBooks / Readium)

I have created and validated an ePub 3 which I am currently testing. I am using a fixed layout..
<meta property="rendition:layout">pre-paginated</meta>
<meta property="rendition:orientation">portrait</meta>
<meta property="rendition:spread">none< /meta>
It works nicely, however multiple pages seems to load and run at once when testing in different readers. I'm using jQuery's document ready to kick things off and play audio, run animations, etc.
When testing in iBooks I open the book to page 1 which loads and begins to run, but then I start hearing audio from page 2.. so the document ready function has fired for page 2 (because it has been loaded) even though I am not viewing it yet. In Readium it seems load and run every single page...
Three questions:
Does anyone know why?
Is there a way to prevent an eReader from running or loading pages you are currently not viewing?
Is there a way to detect (with javascript) when a page is being viewed? (I have tried adding focus event listener to the window but it didn't work).
Document ready seems not to work in ePub. After testing a bit, I noticed that my javascript did not wait my document is ready to start its work. I tested on iPad 1 (iOS 5.1.1) with 3.1 iBooks version. The "solution" I have is to estimate the loading time of your HTML document by any tool which does this, then multiply it by 2 or 3 (because javascript on iOS device is clearly as slow) and use settimeout() function with the obtained time.
The problem is in Redium. you should manually set the settings to make it as two page.
into the Redium, go to settings then check the double pages

Cucumber, Webrat or RSpec testing file uploading

Background:
I need to perform file uploading. I am currently using Uploadify to push files directly to s3 (but would be happy to use plupload). The files that i am working with are large, and i need to show a progress bar. Everything works fine
Issue / Question: How do I set up a test (cucumber) for this?
Uploadify and Plupload both rely on flash (or silverliht) runtime to interact directly with s3. I am unaware of a way for cucumber or webrat to be able to interact with the flash (or silverlight) to click the "browse" button and select a file.
Has anyone found a solution that they are happy with?
Thanks!
Plupload is still based on an HTML form, which you can see if you turn off javascript and load your uploader page.
Then it's simply a matter of using webrat's 'click_button' in cucumber steps using a file fixture as the input to the file field.
Being brutal about it, this is possibly an example of a trusted externality. Ask yourself "do I trust Uploadify"? In the case that you answer yes, you omit actual upload tests for it and just assert that the form field elements you expect to see are present on the page, and then assuming a mocked response of success/fail that your application does the right thing.

Resources