Coding the Humanities

THATCamp 2014, The Hague

Programme

I. Programming and the Humanities

II. Hand-on JavaScript

Vision

Brief Survey

Relevance

  • what do you hope to get from this?
  • why are you here?

Motivation

Vision

  • Why are we doing this?
  • Unwarranted fear or wariness of programming in the Humanities
  • Address ownership of tools and collaboration

Coding

Vision

  • coding as form of arguing
    • Stephen Ramsay
  • programmatic approach to digital research

Data Visualisation

Vision

  • 7 steps of data visualisation
  • today we discuss only 2
    1. acquiring data
    2. visualising data

Web as Data

Vision

  • Web pages structured with HTML
  • HyperText Markup Language
  • Pages are documents with elements
  • DOM: Document Object Model

Document Object Model

Vision

HTML Example

Vision

Hands-on Javascript

Console

Hands-On

  • Programmatic access to HTML via console
  • Modern browser all have JavaScript console
  • JavaScript is native language of the web
  • We will use console for programming

JavaScript?

Hands-On

  • Databases give "documents" in JSON or XML format
  • JSON is JavaScript Object Notation
  • JavaScript is language of choice

Acquiring Data

Hands-On

  • API gives programmatic access to databases
  • Application Programmer Interface
  • Many datasets available via APIs
  • KB has many: Dataservices / APIs
  • Get data using REST queries

REST Queries

Hands-On

  • REST queries are URLs that contain request
  • consist of two parts separated by '?'
    1. base URL to identify the API
    2. query string

REST Example

Hands-On

jsru.kbl.nl/sru/sru?operation=searchRetrieve&x-collection=DPO_boekdeel&query=huygens

jQuery

Hands-On

  • jQuery is a JavaScript library to create, parse, and program dynamic HTML pages
  • we prepared JSON file with top 10 publishers with most books on Huygens

Bar Chart

Hands-On

  1. get publisher info from JSON document
  2. create HTML element for each publisher
  3. set element size based on books published
  4. add elements to HTML document

step by step script here

Work Slide

Hands-On

Resources