Wikimedia

Add support for Twitter cards metadata in html-metadata

See the full task at https://phabricator.wikimedia.org/T148835

Twitter cards are a type of metadata in a webpage that gives information about how to cite the resource. There is a good explanation about them here: https://dev.twitter.com/cards/overview

Here's an example of a page with Twitter metadata: view-view-source:http://www.aftenposten.no/kultur/Pinlig-for-Skaber-555558b.html

You should create a function called exports.twitter in https://github.com/wikimedia/html-metadata/blob/master/lib/index.js that scrapes all the twitter tags, and creates a javascript object. This object should contain all of the tag names as keys and contains the content of the tag as the value. If there are multiple values for the same tag name, these should be in an Array. You should also register the method in https://github.com/wikimedia/html-metadata/blob/master/index.js

You should also create tests for your new function. You can put tests of a live website in https://github.com/wikimedia/html-metadata/blob/master/test/scraping.js. You can also create tests of a static website in https://github.com/wikimedia/html-metadata/blob/master/test/static.js. You may find it helpful to write these tests early on in writing your function, as they will help you verify your function is working correctly. Tests can be run by doing

npm test

Task tags

  • node.js
  • javascript

Students who completed this task

mlsgrnt

Task type

  • code Code
close

2016