angular-wiki-search | AngularJS module for consuming Wikipedia API

angular-wiki-search

angular-wiki-search

Stars : 10

Forks : 10

Created by Damjan Pavlica

Demo Download GitHub

Angular Wiki Search

AngularJS module for consuming Wikipedia API.

See it in action: mudroljub.github.io/angular-wiki-search

You can find an advanced version here: github.com/mudroljub/power-wiki-search

Install

Just download the directory and open index.html file:

$ git clone https://github.com/mudroljub/angular-wiki-search.git
$ bower install
$ open index.html

If you don't use Bower, you can manually resolve dependencies from bower.json file.

Documentation

The main WikiController consists of two main public methods: - wiki.openArticle(title) - wiki.searchWikipedia(term)

Those methods getting data from Wikipedia API in JSONP format (see API documentation).

Both methods have those common URL params:

var params = {
    action: 'query',
    prop: 'extracts|pageimages',    // get article's content and images
    format: 'json',
    formatversion: 2,  // support utf-8
    callback: 'JSON_CALLBACK'
}

Specific params for openArticle method are:

{
    titles: title,   // title is a variable
    redirects: ''  // auto-redirecting to an article
}

Specific params for searchWikipedia method are:

{
    generator: 'search',
    gsrsearch: term,  // term is a variable
    pilimit: 'max', // enable images for all results
    exlimit: 'max', // enable content for all results
    exintro: ''    // get only article's intro
}

To-do list

  • error handling

Javscript

Javascript plugin

Angular-js