Hacker News new | comments | show | ask | jobs | submit login
DNC just open-sourced their voter registration platform (github.com)
113 points by kine 1484 days ago | hide | past | web | 31 comments | favorite

This application is very, very simple; it's a practically the starting skeleton of a modern Rails/Devise application.

One useful reason to bookmark it: it's a pretty good how-to for "any web application whose purpose is to spit out PDF files that need to follow a specific format". There are a LOT of business processes that work like that.

web application whose purpose is to spit out PDF files that need to follow a specific format

FWIW, I've found that "generate HTML and feed it through wkhtmltopdf" is a surprisingly effective way of doing this.

You lose control of pagination when you do this, but, more generally, we're talking about business processes where things need to look exactly the way they usually do.

That said: I used to do the same thing, and it works pretty well.

I managed to get the pagination I needed via judicious use of "page-break-before: always", but yes, this is more a strategy for "I need to programatically generate PDF files" than "I need to generate PDF files which look exactly like this".

> One useful reason to bookmark it: it's a pretty good how-to for "any web application whose purpose is to spit out PDF files that need to follow a specific format".

As others have pointed out, the (not really open source) license doesn't allow any uses for other purposes.

It would be silly to copy an application this simple verbatim, but that same property makes it very easy to read.

I don't think so, it isn't clear from the legalese what the intended purpose of the software is.

It could also be argued that because they have not warranted the product as fit for any purpose that there is no intended purpose.

Maybe you can't copy-paste it and replace part of its insides as with other apps, but it's still useful if learning and testing on local, I guess.

Read your comment (and other's) about the PDF filling and got interested into looking at the source.

I think doing it this way is wrong. It's essentially the same thing as putting your code and HTML together in a PHP file for example.

When the format of a PDF file is fixed and must be filled computationally, I'd advise to add PDF fields to the original and fill those by name through API calls instead of using coordinates.

That way, you can hope to write your code once and update the PDF when necessary.

But OK, it's all pretty dumb and maybe not worth a mention at all.

I think there's two things going into that: first, that Prawn's support for PDF forms is janky, and second, that the way they implemented the precise look/feel of the original PDF form was to use a cut-down version of the original as a template.

Which is a good thing to know how to do; I've had to deal with forms that were very annoying to reproduce with the tools available to Ruby programs.

I used Apache Fop (http://xmlgraphics.apache.org/fop/) to convert XML to PDF at a previous job. It was extremely painstaking work. On the other hand, it gives you a lot of fine-grained control over the appearance of your PDF.

I’ve found ODF is a very convenient format for generating documents. It has a little bit of a learning curve, but you can edit your templates in Libre Office and fill it using any kind of simple templating solution.

It really is quite neat — if you define all your styles declaratively then the markup you touch is very clean and simple, e.g. something like this:

    <office:document-content xmlns:office="…" xmlns:text="…">
          <text:p style-name="foo">Bar</text:p>
I’m sure OOXML can be used in a similar manner, but I don’t know that format very well.

I too used Fop at my last $job to generate PDF files. As you said, the source was extremely tedious to write but you can't beat FOP for the precise control. I would first look to other solutions, since they can be faster, but FOP will always come through.

Yeah, it changes the game when you need to fill out a pre-existing PDF form with user-supplied data (as opposed to free form PDF generation). In my experience, you pretty much have to use a Java library (such as iText) for this. So for a Rails app, that means JRuby, queue to a Java daemon processor, or something along those lines.

Though I see they're using the prawn gem to do it here: https://github.com/democrats/voter-registration/blob/master/...

Last time I checked, prawn wasn't quite powerful enough for this use case. I'll have to revisit that approach.

it is missing integration tests, though

The first part of the software license looks to be BSD/MIT-like with the to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,... sentence, but then there's this paragraph:

This permission does not include: (a) any use of the Software other than for its intended purpose; or (b) any use of the Software in any manner that violates applicable law. Any use of the Software other than as specifically authorized herein is strictly prohibited and will terminate the license granted herein.

In particular this means that this is anything but open source (at least if you go by the OSI definition, which I do).

It also precludes it from being free software, as defined by the FSF.

In particular this means that this is anything but open source (at least if you go by the OSI definition, which I do).

Yeah, I was thinking the same thing. I know some pedants argue that OSI don't have a registered trademark on "Open Source" and that they "don't get to decide what is or isn't open source." But in practice, many (most?) of us do acknowledge the OSI definition as being the de-facto definition of "Open Source."

I imagine that that's CYA; one thing both party organizations have in common: they are saturated with lawyers.

I can see how (b) gives them legal cover, since it says that you can't use the software to forge voter registrations. However, (a) implies that you can't reuse the code as the basis for software that's used to fill out some unrelated type of PDF form, like a tax form. So the terms of the license are really too restrictive to make the software legally safe for anyone else to use -- my employer's lawyers would never allow me to use this software as part of our commercial product. So while it may be technically "open source", it's not really a contribution to the free software community.

There's asset covering, and there's a license where you're assumed guilty until litigated.

And going against an organization that's "saturated with lawyers"?

Even if I were creating a voter registration web site, I'd likely not use this package, as reusing this PDF fulfillment package for any other use within that web site would potentially put the organization in licensing jeopardy. With this license, it'd be safer to re-implement rather than to re-use.

I'm not touching this license with a barge pole.

I like how the registration form shows the form validation errors inline: http://i.imgur.com/U5QL1.png

Looking at the source view(https://github.com/democrats/voter-registration/blob/master/...) it doesn't seems there is some extra markup, unless I am missing something.

So, How can I implement the same in my rails app?

That's simple_form at work. Great little gem.

Thanks for pointing that out :)

Wouldn't a better strategy be a Twilio app that calls voters and informs them that they are registered to vote already?

The point of this software is to make it easier for people who have never registered before to register. The Democratic party probably spent their resources on this because they think that a large percentage of unregistered voters come from demographic groups that tend to vote for Democrats, such as recent college grads who were not yet old enough to vote in the 2008 election.

How would your strategy improve the expected outcome for the Democrats?

I worked as a Rails dev at the DNC in 2010-2011. I pushed for open-sourcing our fully-featured voter reg. Rails app back then, but didn't find much support for the idea. The political world is pretty wary of "giving code away" because the opposition will use it, etc. So, progress?

We were allowed to open-source some infrastructure code back then: https://github.com/dnclabs

Hopefully they'll continue working on this tool and make it something worth using and contributing to. I've tried to convince several political orgs. I worked for in the past to do this, but so far none have bitten.

Maybe it's just my screen, but I find that shade of grey to be incredibly difficult to read.

I do like the trend towards technological openness though, hopefully we'll be seeing more of this sort of thing.

This will be helpful for the DNC to register the dead people and dogs needed to win elections this year with national unemployment at 8.3%.

Perfect handle.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact