Code and Hacks

Stuff I've stumbled on or figured out... mostly Perl, Linux, Mac and Cygwin.

My Photo
Name:
Location: CA, United States

Perl hacker, investor and entrepreneur.

Friday, April 2, 2010

Open Source Presentation Software

I am thinking about giving a presentation at one of my local Perl Monger meetings. So as usual, I have spent a bunch of time toying with new tools rather than getting work done! Which tools: open source presentation creation software. I wanted something that would take a simple text file and easily create an attractive and easy to use presentation.

Here is a quick summary of the options that I tried or looked into:

  • Vroom::Vroom - This is cool. If you like vim and aren’t hung up on the output format it might be for you. I had some trouble getting the key-bindings to work, but I would guess it was a conflict with another vim plugin.

    Vroom can present right in vim or output to html. Both are pretty plain looking, but I didn’t look into customizing the html output. I love that you can press RR and run the code on the slide. The input is a custom format but it is pretty similar to markdown.

  • Pod::S5 - I really wanted to like this one–it is written in Perl, uses a standard method input format, and it creates an HTML presentation. But I was hung up on a couple of things. While pod is great, it isn’t nearly as easy to use as markdown, and the text slides just aren’t that easy to read. Things like lists just take up too much room:

    =over 4
    
    =item *
    
    A Bullet
    
    =item *
    
    Another Bullet
    
    =back

    That’s just too much vertical whitespace.

    Second, the output is S5 which has been superseded by S6. The templates in S5 didn’t really appeal to me and had some issues in my browser.

  • Spork / Spork::S5 - I had some trouble installing this, but eventually realized I just needed to install Kwiki::Cache first. The default themes are not particularly attractive, but again I didn’t look into customizing the output. I do like that it automatically scales text. The ability to highlight sections of the text/code with underlining or colors sounds very cool. For example, this markup:

    .pretty.
     sub greet {
      print "Hello there\n";
    #             _______________
    #              RRRRR
     }    
    .pretty.

    Should underline and make “Hello there” red. I didn’t test this, but according to the documentation it is “coming soon”.

  • Slide Show (S9) - I ended up settling on Slide Show. While I was biased toward a Perl solution, and this is written in Ruby, it definitely seemed the most mature and robust solution. (Maybe I’ll end up learning a bit of Ruby as a side benefit.)

    Slide show can take either textile or markdown as input, it outputs S5 or S6, and has some nice (and simple) templates bundled. It will use any one of a number of markdown parsers so I am using Maruku which has some nice additions to the core markdown syntax (ie, add a css class declaration to an element).

    Installation was easy (once I googled for one error message):

    gem install slideshow
    gem install ultraviolet
    # got error: oniguruma.h: No such file or directory
    port install oniguruma
    gem install ultraviolet

    Slide show also handles syntax highlighting for your code and can import external files into the presentation.

    # Import a file
    <%= include 'help.txt' %>
    # Highlight and import code
    <% code 'test.pl', :lang => 'perl' %> 
    # Highlight inline code
    <% code :lang => 'perl' do %> 
     my $code = 'is simple';
    <% end %>

    All in all, it seems like it fits the bill.

Summary

I probably missed some very nice alternatives. I know there is spod5 on CPAN, but that seems very similar to Pod::S5. I’m sure there are more. Let me know if I should be trying out your favorite.

One other aspect that I’ve been tinkering with: printing the presentation. I don’t need it for the PM presentation I am working on, but if I were to try to switch from PowerPoint to Slide Share for my day job, I would definitely need a way to create .pdf files.

This seems like an issue that others are running into, but there is no great solution so far. It looks like the trick may be to customize the print.css file. The following should change the page layout and add page breaks:

@page {size: landscape;}  /* only works in Opera? */
.slide {page-break-after: always;}

But we are still missing the nice background and layout. I’ll need to spend some more time on this.

Last note: I stumbled into what may be a nice tool to convert a web page to .pdf from the command line: wkhtmltopdf. It barfed on my S6 presentation, but it printed a few other websites nicely.

Labels:

Thursday, June 11, 2009

Web testing

I have been stuck doing a lot of front-end web work lately and haven't had a chance to do much perl coding (I am planning on releasing an Mason based renderer for Email::MIME::Kit soon though). I'm very impressed with the power of CSS in modern browsers. The last time I looked at it, browser incompatibilities really made it difficult to use. It is much better still, I find most of the work to be trial and error, so I have a couple of tips that have saved me some time going back and forth...

Quick Browser Refresh

I do all of my coding in vim and have ton of mappings (maybe I'll share some in future). One I really like right now it ,u which saves the current file then runs my xrefresh perl script which finds my Firefox window and refreshes the current page. It is a simple script that is based on X11::GUITest. It works particularly well when I am using two monitors and can have the browser on in one of them. Here is the mapping, along with the ,U mapping which saves all files:

nmap <silent> ,u :w<cr>:! xrefresh 'Gran Paradiso'<cr>
nmap <silent> ,U :wa<cr>:! xrefresh 'Gran Paradiso'<cr>

It would probably be easy to extend this script to do things like refresh multiple browsers, refresh without using the cache, etc.

IE Testing with VBox

Next up is some fun with IE. (Oh, the hours wasted on you. Damn you IE!) Microsoft has actually been very helpful and provided disk images that you can use to test web pages in a virtual machine on different versions of their browser. They expire periodically and they are designed for Microsoft Virtual PC so it take a bit of work to set them up on linux using VirtualBox, so I created a bash script (create-ie-vbox) to do the heavy lifting.

Once you download the images run create-ie-vbox <path-to-image-.exe> and wait a while. The script uses perl and File::Spec to find the absolute path to the .exe file

exe_file=`echo $exe_file | perl -MFile::Spec -e'print File::Spec->rel2abs(<>)'`
then the unrar command (and perl) to find the .vhd file and unpack it
vhd_file=`unrar l $exe_file | perl -ne'/(\w[\s\w-]*\.vhd)/ && print $1'`
nice unrar e "$exe_file" "$vhd_file" >> $log 2>&1 \
   || die "Couldn't extract $vhd_file from $exe_file"
Then the big trick is to convert the .vhd file to a .vdi file. While VBox can work with .vhd files, Microsoft uses the same UUID for all of these disk images which VBox doesn't like. There is a command in VBoxManage to change the UUID(VBoxManage internalcommands setvdiuuid "$vhd") but there is an acknowledged bug that prevents it from being useful here. Instead we have to use qemu to convert it to a raw disk and then VBoxManage to convert that to a .vdi:
nice qemu-img convert -O raw -f vpc "$vhd" "$raw" || die "Error converting to raw"
nice VBoxManage convertdd "$raw" "$vdi" || die "Error converting to vdi"
Finally there are a number of VBoxManage commands to create and register the image and disk.

Once this is done, there is a bit more work that needs to be done within the vm to deal with some bugs and annoyances. The script prints out the remaining steps. Much thanks to George Ornbo who pointed the way on his blog. Note that this script only works on the XP disks at this point; I haven't bothered to test the Vista versions yet.

BTW, most of my bash scripts use the die() function (stolen from perl) which is very simple but handy:

function die() {
 echo $@
 exit 1
}

Browser Resize

Lastly, I like to check my pages in browsers at various widths. Most importantly (or is that annoyingly) 800px. Rather than change my screen resolution, I use this simple bash script to resize Firefox to the desire width (defaulting to 800 if nothing is supplied on the command line):

#!/bin/bash

SIZE=${1:-800}
echo Resize to $SIZE width
wmctrl -r "Firefox" -e 0,-1,-1,$SIZE,-1
Simple, but gets the job done quickly!

Hope these are helpful.

Labels: , , ,