Putting the cat in the catalogue

A feline-inspired OPAC theme for Koha

Created by Galen Charlton / @gmcharlt

Implementation Manager at Equinox Software

Problem statement

  • Cats occupy librarians' laps
  • But they are not front-and-center in our catalogs.

This is sad

Sad Cat Diary by greyloch on Flickr (CC-BY-SA)

But we can haz happy

  • We can add animated cats to our catalog
  • And also do something just a bit more serious
  • ... like exposing unAPI
  • ... and supporting the Ada Initiative
  • Let's take a look at a Koha catalog

How it's built

  • jQuery
  • jQuery UI

Simple animation


        // it is proper that a cat be above it all
        $(cat_carrier).zIndex(1);

        // actually insert into into the document...

        $(this).append(cat_carrier);

        // ... and start kitty on her merry way
        $(cat_carrier).animate({
            height: 200,
            left: '40%',
            top: '40%'
        }, 7500);

Exposing unAPI


    function display_unapi_widget() {
        // see if we can find an unapi server
        var servers = $(document).find('link[rel="unapi-server"]');
        if (servers.length == 0) return;

        // then grab the formats
        $.get($(servers[0]).attr('href'), function(data) {
            var formats = new Array;
            $(data).find('format').each(function() {
                formats.push($(this).attr('name'));
            });

            // then make widgets
            $('abbr[class="unapi-id"]').each(function(index) {

Not just for Koha

  • Evergreen too!
  • And any catalog that lets one inject a bit of JavaScript

Where to find it

Adding to Koha

Add to the opacuserjs system preference:


$(document).ready(function(){ 
  // modern Koha already includes jQuery and jQuery UI
  $.getScript('/path/to/jquery.librarycat.js').done(function(){
      $(document).LibraryCat({
        cat_image: '/path/to/default_cat.jpg',
        cat_perch: '#opacmainuserblock',
        enable_unapi: true
      });
  }).fail(function() { alert('No cats :('); });
});


Adding to Evergreen

Override the opac/parts/js.tt2 template and add:



<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="http://opac.zadi.librarypolice.com/~gmc/LibraryCat/jquery.librarycat.js"></script>
<script type="text/javascript">
   $(document).LibraryCat({
      cat_image: '/path/to/default_cat.jpg',
      cat_perch: '#homesearch_main_logo',
      enable_unapi: true
   });
</script>

Thanks!

Galen Charlton