• Stars
    star
    438
  • Rank 99,453 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A web app for visualizing the connections between Wikipedia pages.

Wikipedia Map

A web app for visualizing the connections between Wikipedia pages. Try it at wikipedia.luk.ke.

Screenshot of Wikipedia Map

Usage

Start by entering a topic into the text box, for example Cats. A single “node” will be generated, labeled Cat, which appears as a circle on the graph. Click this node to expand it.

Expanding a node creates a new node for each Wikipedia article linked in the first paragraph of the article you clicked. These new nodes will be connected to the node from which they were expanded. For example, expanding Cat will create eight nodes, including Fur, Mammal, Carnivore, and Domestication, each of which will be connected to Cat. These new nodes can also be expanded in the same way. By continuing to expand nodes, you can build a complex web of related topics.

You can also enter multiple articles to "compare" by pressing Comma, Tab, or Enter after each one you enter.

How it works

API

When you click to expand a node, a request is made to the Wikipedia API to download the full content of the Wikipedia article corresponding to that node. Wikipedia map uses this data to find the links in the first paragraph of the article.

HTML Parsing

wikipedia_parse.js uses the DOMParser API to parse wikipedia pages’ HTML (retrieved from calls to Wikipedia's API). The parser looks for the <p> tag corresponding to the first paragraph of the article, then extracts all of the <a> tag links within this paragraph. It then filters the links to include only those which link to other wikipedia articles.

You can see this in action yourself in your browser’s console. If you have Wikipedia Map open, open your browser’s developer tools and type await getSubPages('Cat'). After a second, you should see an array with the names of other related articles.

The graph

The front-end uses vis.js to display the graph. Every time a node is clicked, the app makes a XMLHttpRequest to the Node.js server. The resulting links are added as new nodes, colored according to their distance from the central node (as described above).

Cloning

To use the app locally, simply

git clone https://github.com/controversial/wikipedia-map/

and open index.html in a web browser. No compilation or server is necessary to run the front-end.

Design choices

Functional

Expanding a node creates nodes for each article linked in the first paragraph of the article for the node you expand. I've chosen to use links only from the first paragraph of an article for 2 reasons:

  1. There is usually a manageable number of these links, about 5-10 per page.
  2. These links tend to be more directly relevant to the article than links further down in the page.

Visual

Nodes are lighter in color when they are farther away from the central node. If it took 5 steps to reach Ancient Greek from Penguin, it will be a lighter color than a node like Birding, which only took 2 steps to reach. Thus, a node's color indicates how closely an article is related to the central topic.

Hovering the mouse over a node will highlight the path back to the central node: Traceback This is not necessarily the shortest path back; it is the path that you took to reach the node.

Roadmap

Stuff I'd like to implement soon(ish)

Interface

  • Build a GUI
    • Change input method to something other than prompt
    • Allow starting anew without refreshing page
    • Create small info button that explains the project, controls, etc.
      • Render this README into the help dialog
      • The area with the network should contain instructions when it is blank
      • Create a more thorough help dialog explaining controls, etc. which also includes the README
    • Add a "Random Article" button
    • Create a better help menu that pops up when a user first visits.
    • Make the tour better
      • Show users how to expand and trace back nodes. To do this, create a floating invisible div over a start node. Then, pin the Shepherd step to this div.
      • Don't allow users to advance to the next step until they've followed the instruction (entering articles, pressing Go)
      • Disappear the info box when the tour is started
  • Allow inputting of multiple starts
    • Build an interface for this
  • Implement saving + sharing
    • Saving a graph
    • Loading a graph from an id
    • Loading a graph from a URL parameter
    • Implement sharing UI

Interaction

  • Hovering over a node will show a traceback of how you arrived at that node, kind of like breadcrumbs
  • mobile optimization: Implement a separate set of controls for touch devices
  • On both desktop and mobile, double-click (or tap) a node to open the corresponding wikipedia page in a new tab
  • Improve efficiency of highlighting the nodes

Technical

  • .gitignore-ify the libraries directory, no reason for it to be in here when I didn't write that stuff
  • Remove dependance on some external libraries:
    • jQuery
    • wordwrap
    • tinycolor
  • Move JavaScript to separate files from HTML
  • Make API requests asynchronous
  • Add some kind of build system to make building local copies and contributing easier

Stuff it might be nice to implement sometime in the far future

  • Autocomplete names of Wikipedia articles in the top bar
  • Make the size of nodes reflect the number of backlinks
  • Support for other languages
  • Support for other MediaWiki wikis

Credits

This project is powered by Wikipedia, whose wealth of information makes this project possible.

The presentation of the graph is powered by vis.js.

More Repositories

1

livejson

A Python library providing effortless access to JSON files by mimicking an in-memory dict
Python
37
star
2

maze-cv

Solve a maze simply by pointing a camera at it
Python
34
star
3

Image2ASCII

Python application to convert images to ASCII art.
Python
27
star
4

Pythonista-Tweaks

A module that aims to provide easy access to hard-to-reach functionality in Pythonista
Python
23
star
5

ui2

Builds on Pythonista's UI module to provide extra functionality
Python
22
star
6

Pythonista-theme-utils

A library for working with themes in Pythonista
Python
17
star
7

Image2ASCII-iOS

An iOS app for converting images to ASCII art. Also see https://github.com/controversial/Image2ASCII
Python
15
star
8

Gif-Art

Python scripts using PIL and images2GIF to make animated generative art
Python
13
star
9

Pythonista-UI-Templates

Blank pyui files for all iOS device screen sizes, as well as an editor action for copying them to your current working directory.
Python
12
star
10

cmd-without-cmd

A dumb hack to make my school computers less painful
Batchfile
9
star
11

luk.ke

[IN PROGRESS] A modern portfolio site built with React and Next.js
JavaScript
9
star
12

404

404 page for my website
JavaScript
8
star
13

controversial.io

The previous iteration of my portfolio site (2016-2019)
JavaScript
6
star
14

sleeplater.co

Full-featured ecommerce site for clothing brand sleep later
JavaScript
6
star
15

arkis.io

Website for a project development group I formed with friends in high school
JavaScript
5
star
16

pynow

Python wrapper for the Zeit Now API
Python
5
star
17

bergerbot

Discord chatbot using discord.py. Powered by chatterbot.
Python
5
star
18

webpack-boilerplate

My starter for a website using webpack to compile SASS, ES6, and Pug
JavaScript
5
star
19

Python

Python scripts by me
Python
4
star
20

seek

A proof-of-concept implementation of an automated school attendance system
JavaScript
4
star
21

resume

Resume!
JavaScript
4
star
22

dont-tread-on-memes

Don't tread on me(mes)
Python
4
star
23

PyBB

A Python interface to NodeBB forums
Python
4
star
24

thedonald

A Markov text generator generating fake Trump quotes from Trump's tweets.
Python
3
star
25

vanity

Count the number of additions you've made on GitHub in the last year
Python
3
star
26

cs175-final-project

Final project for CS175
TypeScript
3
star
27

song-a-day

Data analysis of my “Song a Day” playlists using the Spotify API
Jupyter Notebook
2
star
28

codepen

My pens on CodePen
HTML
2
star
29

SPL-T

A Python implementation of and solution to the iOS game SPL-T.
Python
2
star
30

es4

Code for Tufts ES4 Intro to Digital Electronics
VHDL
2
star
31

TI-Spirograph

A spirograph program written on my TI-84 calculator in TI-BASIC. I get bored in math.
2
star
32

cs178-final-project

Jupyter Notebook
1
star
33

tutv-mock-api

Mock API for use in development of https://github.com/jumbocode/tutv
JavaScript
1
star
34

alexa-explain-xkcd

Explain XKCD for Alexa
JavaScript
1
star
35

edge-functions-redirect-bug

Reproduction for Next.js edge functions' API routes redirect bug
JavaScript
1
star
36

nextjs-edge-functions-ga-error-repro

TypeScript
1
star
37

mathquill-evaluate

Use the WolframAlpha API to evaluate MathQuill expressions
JavaScript
1
star
38

matlab-equalizer

A simple music equalizer in MATLAB
MATLAB
1
star
39

flow-field-webgl

Experiments with flow field visuals in webgl
TypeScript
1
star
40

boids

Experimental JS implementation of the Boids flocking algorithm
JavaScript
1
star
41

website-boilerplate

Basic code for a website using ES6 and SASS and compiled with Gulp
JavaScript
1
star
42

markov-js

Markov chains in JS
JavaScript
1
star
43

next-middleware-matcher-repro

Reproduction for Next.js midleware matcher issue
JavaScript
1
star
44

controversial

Repository for my profile README
JavaScript
1
star
45

20951-repro

Reproduction for vercel/next.js#20951
JavaScript
1
star
46

SPCS2017

My work for the Stanford Pre-Collegiate Studies Artificial Intelligence course
Jupyter Notebook
1
star