Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> ODFapper 0.04 for Django on Unix
zxq9
 Posted: Nov 19 2012, 05:49 AM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









Not sure if anyone here is into web development with Django or not, but I've extracted the common bits that I use for ODF rendering into a tiny app/lib that you can plug into other projects now. If there is any external interest I'll work on making the process a little more convenient and maybe documenting how ODF XML works.

Post & link to odfapper_django-0.04

This falls under "related software", as it is not yet a repo. If there is any demand I'll put it on pip and pypi and whatever else and probably make an RPM for it too. But not this week.
PMEmail PosterUsers Website
^
redman
 Posted: Nov 19 2012, 06:56 AM
Quote Post


Retired SLF Administrator
********

Group: Admins
Posts: 1276
Member No.: 2
Joined: 8-April 11









Although I don't have use for it now, it does sound interesting.
Am I correct that it can be used to generate odf files from a webpage (just like a pdf generator would)?

--------------------
"Sometimes the best helping hand you can give is a good, firm push."
PM
^
zxq9
 Posted: Nov 19 2012, 08:20 AM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









It can be used in a similar way, but that's what print-to-file is already good at.

ODFapper lets you make a text, presentation, spreadsheet, whatever and render the XML the same way you would the template HTML for a web page. The details of handling ODFs is a bit different than HTML, but I've got it abstracted away enough that you can pretty much let odfapper unpack your ODF and then do your template authoring in content.xml the same way you would in some_template.html. Instead of
CODE
render('template_name.html', {`context`: 'stuff'})
and then hoping that it sorta kinda fits a PDF you're generating you can now do
CODE
render_odf('template_name', 'destination_path', {'content': 'stuff'})
and get a for-real office document delivered to wherever "destination_path" pointed to.

The original use was exporting complete spreadsheets instead of dumb CSV. For people who learned accounting on spreadsheets instead of higher-powered accounting applications I can have a real accounting database backend render a complete spreadsheet with their functions and semantic declarations exported instead of just giving them a static snapshot that appears as though its a spreadsheet but is really just a big list.

Lately though, it has become obvious that the thing customers like the most about this is that they aren't just being given halfway PDF renderings from webpages. They are getting their own letterhead with good data in it instead -- and they can edit it before they actually print something out instead of just trying to make a PDF fit everywhere it doesn't really belong. Also, they are generally competent to do the WYSIWYG part of the template design themselves because office software is familiar to them -- which is a load off the developer's back (they aren't going to complain about something they made) and gives them a better sense of control.

From a developer's perspective, putting a page of data on the screen requires, at a minimum, that you write an HTML template and dress it up so that Django can render it for you. Adding a proper document export to that is only as hard as making another template and writing a few lines of view code (I think I could do it in three lines in trivial cases). Compared to convincing customers that PDF prints are "good enough" and that they should just learn to live with the uneditable/difficult-to-manipulate nature of a PDF expoort and doing all the typesetting poo necessary to ensure that a PDF will turn out the same size no matter what language the document export is requested in, this is a lot easier.

Oh yeah... and you can render a presentation with embedded movies, music, time-to-flip settings, etc. in them as if it were any other ODF, too... which is pretty slick. I still need to automate some of that away (write template tags specific to those uses) but literally anything is possible.

What would really help, though, is if I documented some of the most common tags used in ODF XML to demystify it the same way all the helper sites focused on HTML do.
PMEmail PosterUsers Website
^
redman
 Posted: Nov 19 2012, 11:31 AM
Quote Post


Retired SLF Administrator
********

Group: Admins
Posts: 1276
Member No.: 2
Joined: 8-April 11









Thanks for the additional info, sounds great!

--------------------
"Sometimes the best helping hand you can give is a good, firm push."
PM
^
zxq9
 Posted: Nov 19 2012, 12:21 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









I forgot to mention one really important thing... ODF is so much incredibly simpler than trying to export MS formats that its not even a consideration to try exporting actual MS documents. There are rickety libs that you can use that almost get it right, but you can actually read and understand what is happening in an ODF after odfapper unpacks it if you've ever written an HTML test page before. Most ODFs separate things like formula declarations from the content section, too.

I hate XML, but the more I've worked with ODF the more I actually enjoy that particular format. Probably because its the single example I can think of where XML has been used correctly (XHTML being a partial example of reasonable use, but not XSLT and all the other wazoo crap where people forgot what was code and what was presentation...). Contrast that with, say, virtlibs (and now parts of systemd... ugh!) saving flat or simple-tree settings data that you have to edit by hand later most of the time in XML when YAML would have been a vastly superior solution.
PMEmail PosterUsers Website
^
Nathan
 Posted: Nov 20 2012, 02:39 AM
Quote Post


SLF Geek
****

Group: Members
Posts: 243
Member No.: 928
Joined: 15-October 11









O...D...Fapper...

Okay.
PM
^
zxq9
 Posted: Nov 20 2012, 09:07 AM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









QUOTE (Nathan @ Nov 20 2012, 02:39 AM)
O...D...Fapper...

Okay.

I see that you see what I did there...
PMEmail PosterUsers Website
^
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll