A Bit of Character Counting Stupidity

When I’m using WordPress’ Status Post Format, I like to keep it to 140 characters, so it’s like a Tweet. But how many characters have I typed? Cos The Visual Editor only shows Word Count. So I took a look around and saw various ways of doing it, quite a few using regex to strip ‘unwanted characters’—but a space counts as a character! So I wrote my own, based loosely on what I’d been using for counting characters in the Excerpt, and from a few different plugins and bits of code. Turned out to be surprisingly easy and uncomplicated (I say that now, of course).

So, first I need a function to call a couple of files if I happen to be editing a Post or Page:

function supernaut_character_count( $charcount ) {
  if ( 'post.php' == $charcount || 'post-new.php' == $charcount ) {
    wp_enqueue_style( 'character-count-css', get_stylesheet_directory_uri() . '/css/char-count.css', array() );
    wp_enqueue_script( 'character-count-js', get_stylesheet_directory_uri() . '/js/char-count.js', array( 'jquery' ), '20160519', true );
  }
  else return;
}
add_action( 'admin_enqueue_scripts', 'supernaut_character_count' );

Then I slap together some jQuery:

jQuery( document ).ready( function( $ ) {
  if( $( '.post-php' ).length || $( '.post-new-php' ).length ) {
    $( '#post-formats-select input' ).click( function() {
      if ( $('#post-format-status').is(':checked') ) {
        $( '#post-status-info tr:first-child' ).after( 'Character count: ' );
        $( '#content_ifr' ).ready( function () {
          setInterval( function() {
            var tinymcebody = $( '#content_ifr' ).contents().find( 'body' );
            $( '#postdivrich .character-count' ).html( tinymcebody.text().length );
          }, 500 )
        });
      } else {
        $( '#post-status-info tr:first-child' ).nextAll().remove();
      }
    });
  }
});

Then a miniscule bit of CSS:

.post-php #wp-character-count {
  font-size: 12px;
  line-height: 1;
  display: block;
  padding: 0 10px 4px;
}

It’s a little bodgy, and if I had more than the 45 minutes to a) work out how the Visual Editor can be fiddled with, and b) write something that worked and looked ok—the bare minimum really—I’d do it slightly nice and maybe consider for a minute throwing it into a plugin (where it officially belongs). But I won’t. It does what I want: live updating of how many characters I’ve written in the Visual Editor, and shows it in a line underneath the Word Count (also aided me in delaying writing a residency application on the day it’s due).

supernaut Character Count
supernaut Character Count

Slight Improvements to Accessibility & Structured Data

Coding while sick!

Recent supernaut museum photography blogging got me thinking about image metadata (both Exif for camera-applied metadata, and IPTC for image-specific person-added metadata), and how I could set up a workflow to better implement this – particularly IPTC which is something I’d need to add and can partially automate, rather than Exif, which the camera adds – and how to persuade WordPress (or straight PHP / some method of database demonology) to scrape that and output it into Schema structured data.

I started doing heavy Schema work on tiptree.org as a way of making the huge amount of data comprehensible to search engines, and by extension, to humans, and have grown to like it a lot (also microformats, which WordPress uses) for making sense of what is otherwise a string of decontextualised words and media. I’d already schema-fied Dasniya’s blog, so mostly it was copy-pasting, then combining into supernaut’s structure – where the design had taken far too many liberties with accessibility and structured data.

So, now all posts spit out at least minimally useful structured data, and posts with images, galleries, or video spit out additional Schema structured data for those objects. Once I start using IPTC for my images, I’ll look at a way of including that in the Schema as well. (Though combining all that into useful objects from experience with Tiptree can be hilariously obtuse.)

On the accessibility side, I’d realised sometime in the past I’d been seriously shitty in supernaut’s design, basically a fucking horrible website to get around for anyone using keyboard navigation, screen-readers, or other methods non-trackpad + eyeballs. Accessibility is something I’ve been increasingly enjoying coding and designing for, along with structured data, particularly for websites that are highly designed and plain fucking arty – I find it gratifying to make hugely complex sites that remain structurally coherent and accessible no matter what device or method a person uses to access it – because there’s often an inverse relationship between design ‘woo!’ and usability ‘yay!’

So, keyboard navigation now is useable and hopefully much clearer, visual styling of user interaction also. Not as good as it could be, but getting there, and vaguely aiming for all of supernaut to be at least somewhat accessible – including and especially my museum visits.

Musée du Louvre

I went to the Louvre. Two months later, I’m still trying to get out.

It helps me to think of it as several museums, as Museuminsel in Berlin—which owes Musée du Louvre plenty in the spirit of what it wishes to become. You can run through both in a single long day; I’m not sure that’s especially healthy though.

I went to the Louvre, and saw slightly less than two-thirds of it. On any day, various salles in rotation are closed, something to do with lack of staff. So I missed some important northern European art on the second and first floors of the Richelieu and Sully wings; saw entirely nothing of any of the Antiquities Collections on any of the three floors; pretty sure I missed the Arts of Africa, Asia, Oceania, and the Americas, buried as it is down some stairs 500 metres along the Denon wing; also none of the Islamic Arts. And besides the mediæval sculpture—which obviously I saw, why else do I go to museums?—roundly ignored the rest of the sculpture collection (with five exceptions below).

All of which magically consumed 731 clicks of my camera. On a single, well-used battery. (I was turning it off between each shot. Amazement!) And has since magically consumed scores of hours while I edited those images down to something not so ridiculous. Approximately half: 312 images.

I really didn’t know how to deal with Aéroport du Louvre, so I looked for the furthest corner from the chaos under the pyramid and started there: 2nd floor Richelieu wing, old northern European stuff. It just goes on and on and on; it’s fucking massive. Any one of the wings on any one of the floors is bigger than plenty of museums I’ve been in, but the Louvre has to have three wings and three floors. I do a good run in museum endurance and there’s no possible way anyone could have a meaningful experience and see everything even on a Friday with 12 hours up your sleeve. I was slayed by the end, limping and claggy-mouthed, it ruined me for the next couple of days, and two months later I’m still dealing with it.

Done.

In vaguely the order I saw everything, and trying to split stuff up into manageable posts, here is Frances visiting Musée du Louvre:

  1. Musée du Louvre, Aile Richelieu 2e étage: Northern European Painting 14th-16th Centuries
  2. Musée du Louvre, Aile Richelieu 2e étage: Northern European Painting 16th-17th Centuries
  3. Musée du Louvre, Aile Sully 2e étage: French Painting 17th-19th Centuries
  4. Musée du Louvre, Aile Denon 1er étage: Italian & French Painting 13th-16th Centuries
  5. Musée du Louvre, Aile Denon 1er étage: Italian & French Painting 16th-19th Centuries
  6. Musée du Louvre, Aile Richelieu Rez-de-Chaussée & Entresol: French & Northern European Sculpture 12th-16th Centuries

Also five sculptures I blogged earlier, plus some Louvre architecture:

  1. Louvre: Diane, dite La Zingarella ou Petite Bohémienne, and Vieux pêcheur, dit Sénèque mourant
  2. Louvre: Maure, dit Le Moro
  3. The Louvre Itself (Bits of it)
  4. Louvre: Narcisse, dit Hermaphrodite Mazarin ou le Génie du repos éternel
  5. Louvre: Hermaphrodite endormi

And a few more images plus blog noise:

  1. Slow Progress through the Louvre
  2. I did not do Le Louvre. Le Louvre did me. 9 hours,…
  3. I’m in Paris (4)
  4. I’m in Paris (3)
  5. I’m in Paris (2)